diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 161bde6..f5d9495 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -419,6 +419,8 @@ "adult": "بالغ", "updateMember": "هل انت متأكد تريد تحديث بيانات هذا العضو؟", "fieldIsEmpty": "'{data}' الحقل فارغ. الرجاء التحديد", + "pleaseEnterComments": "الرجاء إدخال التعليقات", + "skip": "يتخطى", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index b88b14c..640afdb 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -419,6 +419,8 @@ "adult": "Adult", "updateMember": "Are You Sure You Want to Update this Member?", "fieldIsEmpty": "'{data}' Field is empty. Please select", + "pleaseEnterComments": "Please enter comments", + "skip": "skip", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index ceb4881..44de36f 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -73,6 +73,8 @@ class AppState { bool isArabic(context) => EasyLocalization.of(context)?.locale.languageCode == "ar"; + int getLanguageID(context) => EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; + String? _username; // todo ''sikander' added password for now, later will remove & improve diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index b17f5ba..d2fae58 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -420,6 +420,8 @@ abstract class LocaleKeys { static const adult = 'adult'; static const updateMember = 'updateMember'; static const fieldIsEmpty = 'fieldIsEmpty'; + static const pleaseEnterComments = 'pleaseEnterComments'; + static const skip = 'skip'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/models/post_params_model.dart b/lib/models/post_params_model.dart index b44bec9..05356c2 100644 --- a/lib/models/post_params_model.dart +++ b/lib/models/post_params_model.dart @@ -1,3 +1,5 @@ +import 'package:mohem_flutter_app/app_state/app_state.dart'; + class PostParamsModel { double? versionID; int? channel; diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index cf14b3a..beaf2d3 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -169,11 +169,14 @@ class _DashboardScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 9.height, - CountdownTimer( - endTime: model.endTime, - onEnd: null, - endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), - textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + Directionality( + textDirection: TextDirection.ltr, + child: CountdownTimer( + endTime: model.endTime, + onEnd: null, + endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), + textStyle: const TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold), + ), ), LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white), 9.height, @@ -206,16 +209,18 @@ class _DashboardScreenState extends State { .toText14(color: Colors.white, isBold: true), 4.height, ], - ).paddingOnly(left: 12), + ).paddingOnly(left: 12, right: 12), ), Container( + margin: EdgeInsets.only(top: AppState().isArabic(context) ? 6 : 0), width: 45, height: 45, padding: const EdgeInsets.only(left: 14, right: 14), - decoration: const BoxDecoration( + decoration: BoxDecoration( color: Color(0xff259EA4), borderRadius: BorderRadius.only( - bottomRight: Radius.circular(15), + bottomRight: AppState().isArabic(context) ? Radius.circular(0) : Radius.circular(15), + bottomLeft: AppState().isArabic(context) ? Radius.circular(15) : Radius.circular(0), ), ), child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), @@ -257,7 +262,7 @@ class _DashboardScreenState extends State { border: Border.all(color: MyColors.lightGreyEDColor, width: 1), ), child: Column( - mainAxisSize: MainAxisSize.min, + mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -360,7 +365,7 @@ class _DashboardScreenState extends State { ], ), drawer: SafeArea( - child: AppDrawer(), + child: AppDrawer(onLanguageChange: _onRefresh), ), bottomNavigationBar: SizedBox( height: Platform.isAndroid ? 70 : 100, diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index d828270..67adfcb 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -18,6 +18,10 @@ import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; import 'package:provider/provider.dart'; class AppDrawer extends StatefulWidget { + final Function onLanguageChange; + + AppDrawer({required this.onLanguageChange}); + @override _AppDrawerState createState() => _AppDrawerState(); } @@ -65,6 +69,28 @@ class _AppDrawerState extends State { ).expanded ], ).paddingOnly(left: 14, right: 14, top: 21, bottom: 21), + Row( + children: [ + Row( + children: [ + LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { + context.setLocale(const Locale("en", "US")); + postLanguageChange(context); + }), + Container( + width: 1, + color: MyColors.darkWhiteColor, + height: 16, + margin: const EdgeInsets.only(left: 10, right: 10), + ), + LocaleKeys.arabic.tr().toText14(color: !AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() { + context.setLocale(const Locale("ar", "SA")); + postLanguageChange(context); + }), + ], + ), + ], + ).paddingOnly(left: 14, right: 14, bottom: 14), const Divider( height: 1, thickness: 1, @@ -132,6 +158,14 @@ class _AppDrawerState extends State { : onPress!); } + void postLanguageChange(BuildContext context) { + var obj = AppState().postParamsObject; + obj?.languageID = EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; + AppState().setPostParamsModel(obj!); + Navigator.pop(context); + widget.onLanguageChange(); + } + void performLogout() async { AppState().isAuthenticated = false; AppState().isLogged = false; diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index ecb0641..80328a1 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -49,7 +49,6 @@ class ServicesWidget extends StatelessWidget { padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), scrollDirection: Axis.horizontal, itemBuilder: (cxt, index) { - return AspectRatio( aspectRatio: 105 / 105, child: data.isServicesMenusLoading @@ -77,11 +76,7 @@ class ServicesWidget extends StatelessWidget { Expanded( child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText10(isBold: true), ), - RotatedBox( - quarterTurns: AppState().isArabic(context) ? 2:4, - child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4) - ), - + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)), ], ) ], @@ -119,7 +114,7 @@ class ServicesWidget extends StatelessWidget { Navigator.of(context).pushNamed(AppRoutes.profile); return; } - List menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; + List menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION")).toList() ?? []; menuEntry.icon = ""; if (menuList.isEmpty) { if (menuEntry.requestType == "EIT") { @@ -128,7 +123,9 @@ class ServicesWidget extends StatelessWidget { Navigator.pushNamed(context, AppRoutes.monthlyPaySlip); } } else { - Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, menuList)); + List _menuList = + pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; + Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList)); } return; } diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 81cfe0f..e1c58c2 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -175,7 +175,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.startDateT.tr() + "*", - startDateTime == null ? "Select date" : startDateTime.toString().split(' ')[0], + startDateTime == null ? LocaleKeys.pleaseSelectDate.tr() : startDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, onTap: () async { @@ -189,7 +189,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.endDateT.tr() + "*", - endDateTime == null ? "Select date" : endDateTime.toString().split(' ')[0], + endDateTime == null ? LocaleKeys.pleaseSelectDate.tr() : endDateTime.toString().split(' ')[0], suffixIconData: Icons.calendar_today, isEnable: false, isReadOnly: selectedAbsenceType == null || startDateTime == null, @@ -206,7 +206,7 @@ class _AddLeaveBalanceScreenState extends State { 12.height, DynamicTextFieldWidget( LocaleKeys.totalDays.tr(), - totalDays?.toString() ?? "Calculated days", + totalDays?.toString() ?? LocaleKeys.calculatedDays.tr(), isInputTypeNum: true, isEnable: false, onChange: (input) { diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index 3b65954..e33dad8 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -73,7 +73,7 @@ class _EmployeeDetailsState extends State { Container( height: 200, margin: EdgeInsets.only(top: 30), - decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates!.eMPLOYEEIMAGE)), fit: BoxFit.cover)), + decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), fit: BoxFit.cover)), child: new BackdropFilter( filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: new Container( diff --git a/lib/ui/my_team/my_team.dart b/lib/ui/my_team/my_team.dart index bbdce84..6e83972 100644 --- a/lib/ui/my_team/my_team.dart +++ b/lib/ui/my_team/my_team.dart @@ -141,7 +141,7 @@ class _MyTeamState extends State { width: 34, child: CircleAvatar( radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSListOnSearch[index].eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ).paddingOnly(top: 4), ), diff --git a/lib/ui/my_team/team_members.dart b/lib/ui/my_team/team_members.dart index 7ba015f..50bf7e7 100644 --- a/lib/ui/my_team/team_members.dart +++ b/lib/ui/my_team/team_members.dart @@ -85,7 +85,7 @@ class _TeamMembersState extends State { width: 34, child: CircleAvatar( radius: 25, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinatesList[index].eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ).paddingOnly(top: 4), ), diff --git a/lib/ui/profile/profile_screen.dart b/lib/ui/profile/profile_screen.dart index e72d3a9..690633b 100644 --- a/lib/ui/profile/profile_screen.dart +++ b/lib/ui/profile/profile_screen.dart @@ -50,7 +50,7 @@ class _ProfileScreenState extends State { decoration: BoxDecoration( image: DecorationImage( image: MemoryImage( - Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE), + Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!), ), fit: BoxFit.cover), ), diff --git a/lib/ui/profile/widgets/profile_panel.dart b/lib/ui/profile/widgets/profile_panel.dart index 2678599..5018171 100644 --- a/lib/ui/profile/widgets/profile_panel.dart +++ b/lib/ui/profile/widgets/profile_panel.dart @@ -49,7 +49,7 @@ class ProfilePanel extends StatelessWidget { width: 68,) : CircleAvatar( radius: 68, - backgroundImage: MemoryImage(Utils.getPostBytes(memberInformationList.eMPLOYEEIMAGE)), + backgroundImage: MemoryImage(Utils.dataFromBase64String(memberInformationList.eMPLOYEEIMAGE!)), backgroundColor: Colors.black, ); } diff --git a/lib/ui/work_list/itg_detail_screen.dart b/lib/ui/work_list/itg_detail_screen.dart index 491672f..c9329a1 100644 --- a/lib/ui/work_list/itg_detail_screen.dart +++ b/lib/ui/work_list/itg_detail_screen.dart @@ -203,7 +203,7 @@ class _ItgDetailScreenState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ - myFab("Skip", "assets/images/skip.svg").onPress(() { + myFab(LocaleKeys.pleaseEnterComments.tr(), "assets/images/skip.svg").onPress(() { if (AppState().requestAllList!.length - 1 > AppState().itgWorkListIndex!) { AppState().itgWorkListIndex = AppState().itgWorkListIndex! + 1; requestDetails = null; @@ -356,7 +356,18 @@ class _ItgDetailScreenState extends State { ITGRequest? itgRequest = await WorkListApiClient().rejectITGRequest(requestType, taskId, itemId, employeeNumber, comments); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); - Navigator.pop(context, "delegate_reload"); + // Navigator.pop(context, "delegate_reload"); + AppState().workList!.removeAt(AppState().workListIndex!); + if (AppState().workList!.isEmpty) { + Navigator.pop(context, "delegate_reload"); + } else { + if (AppState().workList!.length <= AppState().workListIndex!) { + Navigator.pop(context, "delegate_reload"); + } else { + requestDetails = null; + getDataFromState(); + } + } } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); @@ -369,7 +380,18 @@ class _ItgDetailScreenState extends State { ITGRequest? itgRequest = await WorkListApiClient().approveITGRequest(requestType, taskId, itemId, employeeNumber, comments); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); - Navigator.pop(context, "delegate_reload"); + // Navigator.pop(context, "delegate_reload"); + AppState().workList!.removeAt(AppState().workListIndex!); + if (AppState().workList!.isEmpty) { + Navigator.pop(context, "delegate_reload"); + } else { + if (AppState().workList!.length <= AppState().workListIndex!) { + Navigator.pop(context, "delegate_reload"); + } else { + requestDetails = null; + getDataFromState(); + } + } } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index 35c3c17..369bf0c 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -442,6 +442,8 @@ class _WorkListScreenState extends State { calculateCounter(); if (mounted) setState(() {}); } + } else { + if (mounted) setState(() {}); } }, child: Container( diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 508ce04..7aea35e 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -93,95 +93,77 @@ class _WorkListDetailScreenState extends State { } void getData() async { - try { - Utils.showLoading(context); - if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") { - memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!); - } - if (workListData!.iTEMTYPE == "HRSSA") { - if (workListData!.rEQUESTTYPE == "EIT") { - getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "PHONE_NUMBERS") { - getPhonesNotificationBodyList = await WorkListApiClient().getPhonesNotificationBodyList(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "BASIC_DETAILS") { - getBasicDetNtfBodyList = await WorkListApiClient().getBasicDetNtfBodyList(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "ABSENCE") { - getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID); - } else if (workListData!.rEQUESTTYPE == "CONTACT") { - getContactNotificationBodyList = await WorkListApiClient().getContactNotificationBodyList(workListData!.nOTIFICATIONID); - } - - // getBasicNTFBody = await WorkListApiClient().getBasicDetNTFBody(workListData!.nOTIFICATIONID!, -999); - // getAbsenceCollectionNotifications = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID!, -999); - // subordinatesLeavesModel = await WorkListApiClient().getSubordinatesLeaves("", ""); - } - if (workListData!.iTEMTYPE == "STAMP") { - if (workListData!.rEQUESTTYPE == "STAMP_MS") { - getStampMsNotifications = await WorkListApiClient().getStampMsNotificationBody(workListData!.nOTIFICATIONID!, -999); - } else { - getStampNsNotifications = await WorkListApiClient().getStampNsNotificationBody(workListData!.nOTIFICATIONID!, -999); - } - } - if (workListData!.iTEMTYPE == "INVMOA") { - getMoNotificationBodyList = await WorkListApiClient().getMoNotificationBody(workListData!.nOTIFICATIONID!, -999); - } - if (workListData!.iTEMTYPE == "INVITEM") { - getItemCreationNtfBody = await WorkListApiClient().getItemCreationNtfBody(workListData!.nOTIFICATIONID!, -999); - } - if (workListData!.iTEMTYPE == "POAPPRV") { - getPoNotificationBody = await WorkListApiClient().getPoNotificationBody(workListData!.nOTIFICATIONID!, -999); - } - if (workListData!.iTEMTYPE == "REQAPPRV") { - getPrNotificationBody = await WorkListApiClient().getPRNotificationBody(workListData!.nOTIFICATIONID!, -999); - } - getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!); - if (getNotificationRespondAttributes.isNotEmpty) { - notificationNoteInput = getNotificationRespondAttributes.first; + // try { + // Utils.showLoading(context); + if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") { + getUserInformation(); + } + if (workListData!.iTEMTYPE == "HRSSA") { + if (workListData!.rEQUESTTYPE == "EIT") { + getEitNotificationBody(); + } else if (workListData!.rEQUESTTYPE == "PHONE_NUMBERS") { + getPhonesNotificationBody(); + } else if (workListData!.rEQUESTTYPE == "BASIC_DETAILS") { + getBasicDetNtfBody(); + } else if (workListData!.rEQUESTTYPE == "ABSENCE") { + getAbsenceNotificationBody(); + } else if (workListData!.rEQUESTTYPE == "CONTACT") { + getContactNotificationBody(); } + // getBasicNTFBody = await WorkListApiClient().getBasicDetNTFBody(workListData!.nOTIFICATIONID!, -999); + // getAbsenceCollectionNotifications = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID!, -999); + // subordinatesLeavesModel = await WorkListApiClient().getSubordinatesLeaves("", ""); + } + if (workListData!.iTEMTYPE == "STAMP") { + getStampNotificationBody(); + } + if (workListData!.iTEMTYPE == "INVMOA") { + getMoNotificationBody(); + } + if (workListData!.iTEMTYPE == "INVITEM") { + getItemCreationNtf(); + } + if (workListData!.iTEMTYPE == "POAPPRV") { + getPoNotification(); + } + if (workListData!.iTEMTYPE == "REQAPPRV") { + getPRNotification(); + } - List dataToFetch = await Future.wait([ - WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!), - WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!), - WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!), - ]); - - notificationButtonsList = dataToFetch[0]; - actionHistoryList = dataToFetch[1]; - getAttachmentList = dataToFetch[2]; + notificationGetRespondAttributes(); - // List futureRequest = []; - // List futureObject = []; - // - // addRequestInFuture(notificationButtonsList, WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!)); - // addRequestInFuture(actionHistoryList, WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!)); - // addRequestInFuture(getAttachmentList, WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!)); + // List dataToFetch = await Future.wait([ + // + // WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!), + // WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!), + // ]); + // + // notificationButtonsList = dataToFetch[0]; + // actionHistoryList = dataToFetch[1]; + // getAttachmentList = dataToFetch[2]; - // List dataToFetch = await Future.wait(futureRequest); - // for(int i=0;i element.bUTTONACTION == "CLOSE"); - isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); - isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED"); - } - Utils.hideLoading(context); - setState(() {}); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); - setState(() {}); - } + // if (notificationButtonsList.isNotEmpty) { + // isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE"); + // isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); + // isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED"); + // } + // Utils.hideLoading(context); + // setState(() {}); + // } catch (ex) { + // Utils.hideLoading(context); + // Utils.handleException(ex, context, null); + // setState(() {}); + // } } List futureRequest = []; List futureObject = []; - void addRequestInFuture(data, request) { - futureObject.add(data); - futureRequest.add(request); - } + int apiCallCount = 0; void getDataFromState() { if (workListData == null) { @@ -325,7 +307,7 @@ class _WorkListDetailScreenState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ - myFab("Skip", "assets/images/skip.svg").onPress(() { + myFab(LocaleKeys.pleaseEnterComments.tr(), "assets/images/skip.svg").onPress(() { if (AppState().workList!.length - 1 > AppState().workListIndex!) { AppState().setWorkListIndex = AppState().workListIndex! + 1; workListData = null; @@ -489,9 +471,7 @@ class _WorkListDetailScreenState extends State { child: isIconAsset ? SvgPicture.asset(icon) : Image.memory( - Utils.dataFromBase64String( - icon, - ), + Utils.dataFromBase64String(icon), fit: BoxFit.cover, ), ) @@ -501,6 +481,7 @@ class _WorkListDetailScreenState extends State { void performAction(String actionMode) { TextEditingController textEditingController = TextEditingController(); + print("actionMode:$actionMode"); showDialog( context: context, builder: (cxt) => AcceptRejectInputDialog( @@ -508,24 +489,26 @@ class _WorkListDetailScreenState extends State { notificationGetRespond: notificationNoteInput, textEditingController: textEditingController, onTap: (note) { - if(note.isNotEmpty && (actionMode == "APPROVED" || actionMode == "APPROVE")) { - Map payload = { - "P_ACTION_MODE": actionMode, - "P_APPROVER_INDEX": null, - "P_COMMENTS": note, - "P_FORWARD_TO_USER_NAME": "", - "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, - "RespondAttributeList": [ - if (notificationNoteInput != null) - { - "ATTRIBUTE_NAME": notificationNoteInput!.attributeName, - if (notificationNoteInput!.attributeType == "number") "ATTRIBUTE_NUMBER_VALUE": note else if (notificationNoteInput!.attributeType == "VARCHAR2") "ATTRIBUTE_TEXT_VALUE": note - } - ], - }; + Map payload = { + "P_ACTION_MODE": actionMode, + "P_APPROVER_INDEX": null, + "P_COMMENTS": note, + "P_FORWARD_TO_USER_NAME": "", + "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, + "RespondAttributeList": [ + if (notificationNoteInput != null) + { + "ATTRIBUTE_NAME": notificationNoteInput!.attributeName, + if (notificationNoteInput!.attributeType == "number") "ATTRIBUTE_NUMBER_VALUE": note else if (notificationNoteInput!.attributeType == "VARCHAR2") "ATTRIBUTE_TEXT_VALUE": note + } + ], + }; + if (actionMode == "APPROVED" || actionMode == "APPROVE") { + performNotificationAction(payload); + } else if (note.isNotEmpty && (actionMode != "APPROVED" || actionMode != "APPROVE")) { performNotificationAction(payload); } else { - Utils.showToast("Please enter comments"); + Utils.showToast(LocaleKeys.pleaseEnterComments.tr()); } }, ), @@ -538,10 +521,287 @@ class _WorkListDetailScreenState extends State { GenericResponseModel model = await WorkListApiClient().postNotificationActions(payload); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); - Navigator.pop(context, true); + AppState().workList!.removeAt(AppState().workListIndex!); + if (AppState().workList!.isEmpty) { + Navigator.pop(context, "delegate_reload"); + } else { + if (AppState().workList!.length <= AppState().workListIndex!) { + Navigator.pop(context, "delegate_reload"); + } else { + workListData = null; + getDataFromState(); + } + } } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); } } + + void getEitNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getUserInformation() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getPhonesNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getPhonesNotificationBodyList = await WorkListApiClient().getPhonesNotificationBodyList(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getBasicDetNtfBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getBasicDetNtfBodyList = await WorkListApiClient().getBasicDetNtfBodyList(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getAbsenceNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getContactNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getContactNotificationBodyList = await WorkListApiClient().getContactNotificationBodyList(workListData!.nOTIFICATIONID); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getStampNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + if (workListData!.rEQUESTTYPE == "STAMP_MS") { + getStampMsNotifications = await WorkListApiClient().getStampMsNotificationBody(workListData!.nOTIFICATIONID!, -999); + } else { + getStampNsNotifications = await WorkListApiClient().getStampNsNotificationBody(workListData!.nOTIFICATIONID!, -999); + } + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getMoNotificationBody() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getMoNotificationBodyList = await WorkListApiClient().getMoNotificationBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getItemCreationNtf() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getItemCreationNtfBody = await WorkListApiClient().getItemCreationNtfBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getPoNotification() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getPoNotificationBody = await WorkListApiClient().getPoNotificationBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getPRNotification() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getPrNotificationBody = await WorkListApiClient().getPRNotificationBody(workListData!.nOTIFICATIONID!, -999); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void notificationGetRespondAttributes() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!); + if (getNotificationRespondAttributes.isNotEmpty) { + notificationNoteInput = getNotificationRespondAttributes.first; + } + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getNotificationButtons() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + notificationButtonsList = await WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!); + if (notificationButtonsList.isNotEmpty) { + isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE"); + isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); + isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED"); + } + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getActionHistory() async { + try { + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; + actionHistoryList = await WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); + setState(() {}); + } + } catch (ex) { + apiCallCount--; + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } + + void getAttachments() async { + try { + // if (apiCallCount == 0) Utils.showLoading(context); + // apiCallCount++; + getAttachmentList = await WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!); + // apiCallCount--; + // if (apiCallCount == 0) { + // Utils.hideLoading(context); + setState(() {}); + // } + } catch (ex) { + // apiCallCount--; + // Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } } diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart index 2ccd98b..90c57e3 100644 --- a/lib/widgets/mark_attendance_widget.dart +++ b/lib/widgets/mark_attendance_widget.dart @@ -85,7 +85,8 @@ class _MarkAttendanceWidgetState extends State { physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, padding: const EdgeInsets.only(bottom: 14, top: 21), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: (MediaQuery.of(context).size.width < 400) ? 3 : 5, childAspectRatio: 1 / 1, crossAxisSpacing: 8, mainAxisSpacing: 8), children: [ // if (isNfcEnabled) attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { @@ -238,7 +239,7 @@ class _MarkAttendanceWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SvgPicture.asset(image, color: Colors.white).expanded, + SvgPicture.asset(image, color: Colors.white, alignment: Alignment.topLeft).expanded, title.toText17(isBold: true, color: Colors.white), ], ),