Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ignore_for_file: use_build_context_synchronously
- import 'dart:ui';
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_animate/flutter_animate.dart';
- import 'package:flutter_bloc/flutter_bloc.dart';
- import 'package:walalangi_mobile/components/consts/colors_cons.dart';
- import 'package:walalangi_mobile/components/consts/const.dart';
- import 'package:walalangi_mobile/components/container.dart';
- import 'package:walalangi_mobile/components/extensions/date_extension.dart';
- import 'package:walalangi_mobile/components/extensions/word_extention.dart';
- import 'package:walalangi_mobile/components/toast.dart';
- import 'package:walalangi_mobile/core/bloc/cubit/all_leave_list_cubit/all_leave_list_cubit.dart';
- import 'package:walalangi_mobile/core/bloc/cubit/leave_available_cubit/leave_available_cubit.dart';
- import 'package:walalangi_mobile/core/bloc/cubit/leaves_cubit/leaves_cubit.dart';
- import 'package:walalangi_mobile/core/bloc/cubit/leaves_list_cubit/leaves_list_cubit.dart';
- import 'package:walalangi_mobile/core/bloc/cubit/workflow_cubit/workflow_cubit.dart';
- import 'package:walalangi_mobile/flutter_flow/flutter_flow_animations.dart';
- import 'package:walalangi_mobile/flutter_flow/flutter_flow_calendar.dart';
- import 'package:walalangi_mobile/flutter_flow/flutter_flow_theme.dart';
- import 'package:walalangi_mobile/flutter_flow/flutter_flow_util.dart';
- import 'package:walalangi_mobile/pages/page_leave_apply/page_leave_apply_body.dart';
- import 'package:walalangi_mobile/pages/page_leave_apply/page_leave_apply_header.dart';
- import 'package:walalangi_mobile/pages/page_leave_apply/page_leave_apply_model.dart';
- import 'package:walalangi_mobile/widgets/common_modal_porgress.dart';
- import 'package:walalangi_mobile/widgets/common_notification_widget.dart';
- export 'page_leave_apply_model.dart';
- class PageLeaveApplyWidget extends StatefulWidget {
- const PageLeaveApplyWidget({super.key});
- @override
- State<PageLeaveApplyWidget> createState() => _PageLeaveApplyWidgetState();
- }
- class _PageLeaveApplyWidgetState extends State<PageLeaveApplyWidget>
- with TickerProviderStateMixin {
- late PageLeaveApplyModel _model;
- final scaffoldKey = GlobalKey<ScaffoldState>();
- final animationsMap = <String, AnimationInfo>{};
- final GlobalKey<AnimatedWidgetBaseState> _animatedKey =
- GlobalKey<AnimatedWidgetBaseState>();
- @override
- void initState() {
- super.initState();
- _model = createModel(context, () => PageLeaveApplyModel());
- animationsMap.addAll({
- 'columnOnPageLoadAnimation': AnimationInfo(
- trigger: AnimationTrigger.onPageLoad,
- effectsBuilder: () => [
- FadeEffect(
- curve: Curves.easeInOut,
- delay: 0.0.ms,
- duration: 1200.0.ms,
- begin: 0.0,
- end: 1.0,
- ),
- ],
- ),
- 'blurOnPageLoadAnimation1': AnimationInfo(
- trigger: AnimationTrigger.onPageLoad,
- effectsBuilder: () => [
- VisibilityEffect(duration: 1.ms),
- MoveEffect(
- curve: Curves.easeInOut,
- delay: 0.0.ms,
- duration: 600.0.ms,
- begin: const Offset(100.0, 0.0),
- end: const Offset(0.0, 0.0),
- ),
- ],
- ),
- 'iconOnPageLoadAnimation1': AnimationInfo(
- loop: true,
- reverse: true,
- trigger: AnimationTrigger.onPageLoad,
- effectsBuilder: () => [
- FadeEffect(
- curve: Curves.linear,
- delay: 0.0.ms,
- duration: 700.0.ms,
- begin: 0.2,
- end: 1.0,
- ),
- ],
- ),
- 'blurOnPageLoadAnimation2': AnimationInfo(
- trigger: AnimationTrigger.onPageLoad,
- effectsBuilder: () => [
- VisibilityEffect(duration: 100.ms),
- MoveEffect(
- curve: Curves.easeInOut,
- delay: 100.0.ms,
- duration: 600.0.ms,
- begin: const Offset(200.0, 0.0),
- end: const Offset(0.0, 0.0),
- ),
- ],
- ),
- 'blurOnPageLoadAnimation3': AnimationInfo(
- trigger: AnimationTrigger.onPageLoad,
- effectsBuilder: () => [
- VisibilityEffect(duration: 100.ms),
- MoveEffect(
- curve: Curves.easeInOut,
- delay: 100.0.ms,
- duration: 600.0.ms,
- begin: const Offset(200.0, 0.0),
- end: const Offset(0.0, 0.0),
- ),
- ],
- ),
- 'iconOnPageLoadAnimation2': AnimationInfo(
- loop: true,
- trigger: AnimationTrigger.onPageLoad,
- effectsBuilder: () => [
- ShakeEffect(
- curve: Curves.easeInOut,
- delay: 6000.0.ms,
- duration: 1000.0.ms,
- hz: 4,
- offset: const Offset(2.0, 0.0),
- rotation: -0.122,
- ),
- ],
- ),
- 'iconOnPageLoadAnimation3': AnimationInfo(
- loop: true,
- trigger: AnimationTrigger.onPageLoad,
- effectsBuilder: () => [
- ShakeEffect(
- curve: Curves.easeInOut,
- delay: 6000.0.ms,
- duration: 1000.0.ms,
- hz: 4,
- offset: const Offset(2.0, 0.0),
- rotation: -0.122,
- ),
- ],
- ),
- });
- WidgetsBinding.instance.addPostFrameCallback((_) => setState(() {}));
- }
- onBtnApply() async {
- _model.isAsync = true;
- setState(() {});
- context.read<LeavesCubit>().addLeave(
- _model.leaveNote.text,
- _model.startDateField.text,
- _model.endDateField.text,
- _model.annualId.value!.id!,
- _model.annualId.value!.id == 1 ? _model.leaveNote.text : '',
- _model.dateType.value == 'Range'
- ? null
- : _model.datePickField
- .map(
- (e) => e.text,
- )
- .toList(),
- _model.dateType.value.toString().toLowerCase());
- Future.delayed(
- const Duration(seconds: 3),
- () async {
- if (log.getInt(STATUSCODE) == 200) {
- _model.isAsync = false;
- // showSuccessBottom(context, LOGGEDBOX.get(MESSAGE));
- showSuccessBottom(context, 'apply leave success'.toCapitalize()).then(
- (value) => context.pop(),
- );
- context.pushNamed('Page-Leave');
- context
- .read<LeavesListCubit>()
- .getleaveList(context, '', null, null, 1);
- context
- .read<AllLeaveListCubit>()
- .getAllLeaveList(context, '', 1, todayDate.toStripID(), null);
- context
- .read<LeavesListCubit>()
- .getleaveList(context, '', null, null, 1);
- context.read<WorkflowCubit>().getWorkflow(context, 'leaves');
- context.read<LeaveAvailableCubit>().getLeaveAvailable(context, '20');
- } else {
- _model.isAsync = false;
- showConfirmationDialog(
- // context: context, message: LOGGEDBOX.get(MESSAGE).toString());
- context: context,
- message: log.getString(MESSAGE).toString());
- }
- setState(() {});
- },
- );
- }
- @override
- void dispose() {
- _model.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: () => FocusScope.of(context).unfocus(),
- child: Scaffold(
- key: scaffoldKey,
- backgroundColor: Colors.black,
- body: ModalProgress(
- inAsyncCall: _model.isAsync,
- child: Stack(
- key: _animatedKey,
- children: [
- log.getString(AVA) == defaultAva
- ? Image.asset(
- 'assets/images/kolintang_2.jpg',
- width: MediaQuery.sizeOf(context).width * 1.0,
- height: MediaQuery.sizeOf(context).height * 1.0,
- fit: BoxFit.cover,
- opacity: const AlwaysStoppedAnimation(.4),
- )
- : CachedNetworkImage(
- imageUrl: log.getString(AVA).toString(),
- width: MediaQuery.sizeOf(context).width * 1.0,
- height: MediaQuery.sizeOf(context).height * 1.0,
- fit: BoxFit.cover,
- placeholder: (context, url) => const SizedBox(),
- imageBuilder: (context, imageProvider) => Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- image: imageProvider,
- opacity: 0.4,
- fit: BoxFit.cover,
- ),
- ),
- width: MediaQuery.sizeOf(context).width * 1.0,
- height: MediaQuery.sizeOf(context).height * 1.0,
- ),
- errorWidget: (context, url, error) => Image.asset(
- 'assets/images/kolintang_2.jpg',
- width: MediaQuery.sizeOf(context).width * 1.0,
- height: MediaQuery.sizeOf(context).height * 1.0,
- fit: BoxFit.cover,
- opacity: const AlwaysStoppedAnimation(.4),
- ),
- ),
- ClipRRect(
- borderRadius: BorderRadius.circular(0.0),
- child: BackdropFilter(
- filter: ImageFilter.blur(
- sigmaX: 15.0,
- sigmaY: 15.0,
- ),
- child: Container(
- width: MediaQuery.sizeOf(context).width * 1.0,
- height: MediaQuery.sizeOf(context).height * 1.0,
- decoration: const BoxDecoration(
- color: Color(0xBC101213),
- ),
- ),
- ),
- ),
- Padding(
- padding: EdgeInsetsDirectional.fromSTEB(
- 0.0, MediaQuery.of(context).size.height / 20, 0.0, 0.0),
- child: Container(
- width: MediaQuery.sizeOf(context).width * 1.0,
- decoration: const BoxDecoration(),
- child: SingleChildScrollView(
- physics: const NeverScrollableScrollPhysics(),
- child: Column(
- children: [
- Padding(
- padding: const EdgeInsetsDirectional.fromSTEB(
- 15.0, 0.0, 15.0, 0.0),
- child: Row(
- mainAxisSize: MainAxisSize.max,
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- decoration: const BoxDecoration(),
- child: Column(
- mainAxisSize: MainAxisSize.max,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- InkWell(
- onTap: () => context.pop(),
- child: const Icon(
- Icons.arrow_back_ios_outlined,
- size: 25,
- color: white,
- ),
- ).bottomPadded12(),
- Text(
- 'Leave\nApplication',
- style: FlutterFlowTheme.of(context)
- .displaySmall
- .override(
- fontFamily: 'Libre Baskerville',
- color: FlutterFlowTheme.of(context)
- .primaryText,
- fontSize: 22.0,
- letterSpacing: 1.2,
- fontWeight: FontWeight.w300,
- lineHeight: 1.2,
- ),
- ),
- ],
- ),
- ),
- CommonNotificationWidget(
- animationsMap: animationsMap)
- ],
- ),
- ),
- Container(
- height: MediaQuery.of(context).size.height / 1.3,
- padding: EdgeInsets.only(
- bottom: MediaQuery.of(context).viewInsets.bottom),
- child: SingleChildScrollView(
- child: Column(
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(0.0),
- child: BackdropFilter(
- filter: ImageFilter.blur(
- sigmaX: 5.0,
- sigmaY: 5.0,
- ),
- child: Container(
- width: MediaQuery.sizeOf(context).width *
- 1.0,
- decoration: BoxDecoration(
- gradient: const LinearGradient(
- colors: [
- Color(0x06FFFFFF),
- Color(0x1CFFFFFF)
- ],
- stops: [0.0, 0.9],
- begin: AlignmentDirectional(0.0, 1.0),
- end: AlignmentDirectional(0, -1.0),
- ),
- borderRadius:
- BorderRadius.circular(10.0),
- ),
- child: Padding(
- padding: const EdgeInsetsDirectional
- .fromSTEB(10.0, 0.0, 10.0, 10.0),
- child: FlutterFlowCalendar(
- color: FlutterFlowTheme.of(context)
- .primary,
- iconColor:
- FlutterFlowTheme.of(context)
- .secondaryText,
- weekFormat: true,
- weekStartsMonday: true,
- rowHeight: 32.0,
- onChange:
- (DateTimeRange? newSelectedDate) {
- setState(() =>
- _model.calendarSelectedDay =
- newSelectedDate);
- },
- titleStyle: FlutterFlowTheme.of(
- context)
- .headlineSmall
- .override(
- fontFamily: 'Poppins',
- color:
- FlutterFlowTheme.of(context)
- .primary,
- fontSize: 14.0,
- letterSpacing: 0.0,
- fontWeight: FontWeight.w600,
- ),
- dayOfWeekStyle: FlutterFlowTheme.of(
- context)
- .labelLarge
- .override(
- fontFamily: 'Poppins',
- color:
- FlutterFlowTheme.of(context)
- .primary,
- fontSize: 13.0,
- letterSpacing: 0.0,
- fontWeight: FontWeight.normal,
- lineHeight: 1.0,
- ),
- dateStyle: FlutterFlowTheme.of(
- context)
- .bodyMedium
- .override(
- fontFamily: 'Poppins',
- color:
- FlutterFlowTheme.of(context)
- .primaryText,
- fontSize: 12.0,
- letterSpacing: 0.0,
- fontWeight: FontWeight.normal,
- ),
- selectedDateStyle:
- FlutterFlowTheme.of(context)
- .titleSmall
- .override(
- fontFamily: 'Poppins',
- color: FlutterFlowTheme.of(
- context)
- .primaryText,
- fontSize: 11.0,
- letterSpacing: 0.0,
- ),
- inactiveDateStyle:
- FlutterFlowTheme.of(context)
- .labelMedium
- .override(
- fontFamily: 'Poppins',
- color: FlutterFlowTheme.of(
- context)
- .accent3,
- letterSpacing: 0.0,
- ),
- ),
- ),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsetsDirectional.fromSTEB(
- 0.0, 10.0, 0.0, 0.0),
- child: Container(
- width:
- MediaQuery.sizeOf(context).width * 1.0,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- ),
- child: Column(
- children: [
- PageLeaveApplyHeader(
- animationMap: animationsMap,
- )
- ].divide(const SizedBox(height: 7.0)),
- ),
- ),
- ),
- PageLeaveApplyBody(
- model: _model,
- ),
- Padding(
- padding: const EdgeInsetsDirectional.fromSTEB(
- 0.0, 20.0, 05.0, 20.0),
- child: Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- Expanded(
- flex: 2,
- child: InkWell(
- onTap: () => context.pop(),
- child: Container(
- width: MediaQuery.sizeOf(context)
- .width *
- 1.0,
- height: 45.0,
- decoration: BoxDecoration(
- color: const Color(0x80363636),
- borderRadius:
- BorderRadius.circular(8.0),
- border: Border.all(
- color: Colors.transparent,
- width: 0.0,
- ),
- ),
- child: Align(
- alignment:
- const AlignmentDirectional(
- 0.0, 0.0),
- child: Text(
- 'CANCEL',
- textAlign: TextAlign.end,
- style:
- FlutterFlowTheme.of(context)
- .bodyMedium
- .override(
- fontFamily: 'Poppins',
- color: FlutterFlowTheme
- .of(context)
- .primaryText,
- fontSize: 15.0,
- letterSpacing: 0.0,
- fontWeight:
- FontWeight.w600,
- lineHeight: 1.0,
- ),
- ),
- ),
- ),
- ),
- ),
- Expanded(
- flex: 2,
- child: InkWell(
- splashColor: Colors.transparent,
- focusColor: Colors.transparent,
- hoverColor: Colors.transparent,
- highlightColor: Colors.transparent,
- onTap: () async {
- if (_model.dateType.value == null ||
- _model.annualId.value?.id ==
- null ||
- _model.startDateField.text
- .isEmpty ||
- _model.endDateField.text
- .isEmpty ||
- _model.leaveNote.text.isEmpty) {
- if (_model.dateType.value == 'Custom' &&
- _model.datePickField.last
- .text.isEmpty ||
- _model.annualId.value?.id ==
- null ||
- _model
- .leaveNote.text.isEmpty) {
- toast(context,
- 'form can\'t be empty');
- } else if (_model
- .dateType.value ==
- 'Range' ||
- _model.annualId.value?.id ==
- null ||
- _model
- .leaveNote.text.isEmpty) {
- toast(context,
- 'form can\'t be empty');
- } else {
- _animatedKey.currentState
- ?.dispose();
- onBtnApply();
- }
- } else {
- _animatedKey.currentState
- ?.dispose();
- onBtnApply();
- }
- },
- child: Container(
- width: MediaQuery.sizeOf(context)
- .width *
- 1.0,
- height: 45.0,
- decoration: BoxDecoration(
- color:
- FlutterFlowTheme.of(context)
- .primary,
- borderRadius:
- BorderRadius.circular(8.0),
- border: Border.all(
- width: 0.0,
- ),
- ),
- child: Align(
- alignment:
- const AlignmentDirectional(
- 0.0, 0.0),
- child: Text(
- 'APPLY NOW',
- textAlign: TextAlign.end,
- style:
- FlutterFlowTheme.of(context)
- .bodyMedium
- .override(
- fontFamily: 'Poppins',
- color: FlutterFlowTheme
- .of(context)
- .primaryText,
- fontSize: 15.0,
- letterSpacing: 0.0,
- fontWeight:
- FontWeight.w600,
- lineHeight: 1.0,
- ),
- ),
- ),
- ),
- ),
- ),
- ].divide(const SizedBox(width: 15.0)),
- ),
- ),
- ],
- ),
- ).paddedLTRB(top: 20, left: 15, right: 15),
- ),
- ],
- ),
- ),
- ),
- ),
- /* Align(
- alignment: const AlignmentDirectional(0.0, 1.0),
- child: wrapWithModel(
- model: _model.footerMenuModel,
- updateCallback: () => setState(() {}),
- child: const FooterMenuWidget(),
- ),
- ), */
- ],
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement