diff --git a/lib/api/login_api_client.dart b/lib/api/login_api_client.dart index cd6a948..79b7783 100644 --- a/lib/api/login_api_client.dart +++ b/lib/api/login_api_client.dart @@ -135,4 +135,14 @@ class LoginApiClient { return responseData; }, url, postParams); } + + Future changePasswordFromActiveSession(String pOldPassword, String pNewPassword, String pConfirmNewPassword) async { + String url = "${ApiConsts.erpRest}ChangePassword_FromActiveSession"; + Map postParams = {"P_OLD_PASSWORD": pOldPassword, "P_Confirm_NEW_PASSWORD": pConfirmNewPassword, "P_NEW_PASSWORD": pNewPassword}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + return responseData; + }, url, postParams); + } } diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index c61fcff..9d9dc21 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:easy_localization/easy_localization.dart'; import 'package:mohem_flutter_app/models/itg_forms_models/request_detail_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; @@ -30,17 +32,27 @@ class AppState { String? get getForgetPasswordTokenID => forgetPasswordTokenID; //Wifi info - String? mohemmWifiSSID; + String? _mohemmWifiSSID; + + set setMohemmWifiSSID(v) => _mohemmWifiSSID = v; - set setMohemmWifiSSID(v) => mohemmWifiSSID = mohemmWifiSSID; + String? get getMohemmWifiSSID => _mohemmWifiSSID; - String? get getMohemmWifiSSID => mohemmWifiSSID; + String? _mohemmWifiPassword; - String? mohemmWifiPassword; + set setMohemmWifiPassword(v) => _mohemmWifiPassword = v; - set setMohemmWifiPassword(v) => mohemmWifiPassword = v; + String? get getMohemmWifiPassword => _mohemmWifiPassword; - String? get getMohemmWifiPassword => mohemmWifiPassword; + final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 5.0, mobileType: Platform.isAndroid ? "android" : "ios"); + + void setPostParamsInitConfig() { + isAuthenticated = false; + isLogged = false; + _memberLoginList = null; + _memberInformationList = null; + _postParams = _postParamsInitConfig; + } PostParamsModel? _postParams; diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index f77f998..94bcc18 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -129,9 +129,10 @@ class Utils { static Widget getNoDataWidget(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ SvgPicture.asset('assets/images/not_found.svg', width: 110.0, height: 110.0), - Container(margin: const EdgeInsets.only(top: 15.0), child: LocaleKeys.noDataAvailable.tr().toText16().center), + LocaleKeys.noDataAvailable.tr().toText16().paddingOnly(top: 15), ], ).center; } diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 5f78298..ffafbc7 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -7,6 +7,7 @@ import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart'; import 'package:mohem_flutter_app/ui/landing/today_attendance_screen.dart'; import 'package:mohem_flutter_app/ui/leave_balance/add_leave_balance_screen.dart'; import 'package:mohem_flutter_app/ui/leave_balance/leave_balance_screen.dart'; +import 'package:mohem_flutter_app/ui/login/change_password_screen.dart'; import 'package:mohem_flutter_app/ui/login/forgot_password_screen.dart'; import 'package:mohem_flutter_app/ui/login/login_screen.dart'; import 'package:mohem_flutter_app/ui/login/new_password_screen.dart'; @@ -16,6 +17,7 @@ import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/services_menu_list_screen.dart'; + // import 'package:mohem_flutter_app/ui/my_attendance/my_attendance_screen.dart'; import 'package:mohem_flutter_app/ui/my_team/create_request.dart'; import 'package:mohem_flutter_app/ui/my_team/employee_details.dart'; @@ -57,8 +59,6 @@ import 'package:mohem_flutter_app/ui/work_list/item_history_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/itg_detail_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/work_list_screen.dart'; import 'package:mohem_flutter_app/ui/work_list/worklist_detail_screen.dart'; -import 'package:mohem_flutter_app/ui/my_team/my_team.dart'; -import 'package:mohem_flutter_app/ui/my_team/create_request.dart'; import 'package:mohem_flutter_app/ui/work_list/worklist_settings.dart'; class AppRoutes { @@ -148,6 +148,7 @@ class AppRoutes { //performance evaluation static const String performanceEvaluation = "/performanceEvaluation"; + //My Team static const String myTeam = "/myTeam"; static const String employeeDetails = "/employeeDetails"; @@ -157,6 +158,8 @@ class AppRoutes { static const String createRequest = "/createRequest"; static const String subordinateLeave = "/subordinateLeave"; + static const String changePassword = "/changePassword"; + static final Map routes = { login: (context) => LoginScreen(), verifyLogin: (context) => VerifyLoginScreen(), @@ -247,5 +250,7 @@ class AppRoutes { teamMembers: (context) => TeamMembers(), createRequest: (context) => CreateRequest(), subordinateLeave: (context) => SubordinateLeave(), + + changePassword: (context) => ChangePasswordScreen(), }; } diff --git a/lib/main.dart b/lib/main.dart index 8bc0ecf..d5869fb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,7 +6,6 @@ import 'package:logger/logger.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/generated/codegen_loader.g.dart'; -import 'package:mohem_flutter_app/models/post_params_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/provider/eit_provider_model.dart'; import 'package:mohem_flutter_app/theme/app_theme.dart'; @@ -30,9 +29,7 @@ class MyHttpOverrides extends HttpOverrides { Future main() async { WidgetsFlutterBinding.ensureInitialized(); await EasyLocalization.ensureInitialized(); - AppState().setPostParamsModel( - PostParamsModel(channel: 31, versionID: 5.0, mobileType: Platform.isAndroid ? "android" : "ios"), - ); + AppState().setPostParamsInitConfig(); HttpOverrides.global = MyHttpOverrides(); runApp( EasyLocalization( diff --git a/lib/models/member_information_list_model.dart b/lib/models/member_information_list_model.dart index 0050fed..4225905 100644 --- a/lib/models/member_information_list_model.dart +++ b/lib/models/member_information_list_model.dart @@ -88,86 +88,86 @@ class MemberInformationListModel { MemberInformationListModel( {this.aCTUALTERMINATIONDATE, - this.aSSIGNMENTENDDATE, - this.aSSIGNMENTID, - this.aSSIGNMENTNUMBER, - this.aSSIGNMENTSTARTDATE, - this.aSSIGNMENTSTATUSTYPEID, - this.aSSIGNMENTTYPE, - this.bUSINESSGROUPID, - this.bUSINESSGROUPNAME, - this.businessCardQR, - this.cURRENTEMPLOYEEFLAG, - this.eMPLOYEEDISPLAYNAME, - this.eMPLOYEEDISPLAYNAMEAr, - this.eMPLOYEEDISPLAYNAMEEn, - this.eMPLOYEEEMAILADDRESS, - this.eMPLOYEEIMAGE, - this.eMPLOYEEMOBILENUMBER, - this.eMPLOYEENAME, - this.eMPLOYEENAMEAr, - this.eMPLOYEENAMEEn, - this.eMPLOYEENUMBER, - this.eMPLOYEEWORKNUMBER, - this.eMPLOYMENTCATEGORY, - this.eMPLOYMENTCATEGORYMEANING, - this.employeeQR, - this.fREQUENCY, - this.fREQUENCYMEANING, - this.fROMROWNUM, - this.gRADEID, - this.gRADENAME, - this.hIREDATE, - this.jOBID, - this.jOBNAME, - this.jOBNAMEAr, - this.jOBNAMEEn, - this.lEDGERID, - this.lOCATIONID, - this.lOCATIONNAME, - this.mANUALTIMECARDFLAG, - this.mANUALTIMECARDMEANING, - this.mobileNumberWithZipCode, - this.nATIONALITYCODE, - this.nATIONALITYMEANING, - this.nATIONALIDENTIFIER, - this.nORMALHOURS, - this.nOOFROWS, - this.oRGANIZATIONID, - this.oRGANIZATIONNAME, - this.pAYROLLCODE, - this.pAYROLLID, - this.pAYROLLNAME, - this.pERSONID, - this.pERSONTYPE, - this.pERSONTYPEID, - this.pERINFORMATIONCATEGORY, - this.pOSITIONID, - this.pOSITIONNAME, - this.pRIMARYFLAG, - this.rOWNUM, - this.sERVICEDAYS, - this.sERVICEMONTHS, - this.sERVICEYEARS, - this.sUPERVISORASSIGNMENTID, - this.sUPERVISORDISPLAYNAME, - this.sUPERVISOREMAILADDRESS, - this.sUPERVISORID, - this.sUPERVISORMOBILENUMBER, - this.sUPERVISORNAME, - this.sUPERVISORNUMBER, - this.sUPERVISORWORKNUMBER, - this.sWIPESEXEMPTEDFLAG, - this.sWIPESEXEMPTEDMEANING, - this.sYSTEMPERSONTYPE, - this.tKEMAILADDRESS, - this.tKEMPLOYEEDISPLAYNAME, - this.tKEMPLOYEENAME, - this.tKEMPLOYEENUMBER, - this.tKPERSONID, - this.tOROWNUM, - this.uNITNUMBER, - this.uSERSTATUS}); + this.aSSIGNMENTENDDATE, + this.aSSIGNMENTID, + this.aSSIGNMENTNUMBER, + this.aSSIGNMENTSTARTDATE, + this.aSSIGNMENTSTATUSTYPEID, + this.aSSIGNMENTTYPE, + this.bUSINESSGROUPID, + this.bUSINESSGROUPNAME, + this.businessCardQR, + this.cURRENTEMPLOYEEFLAG, + this.eMPLOYEEDISPLAYNAME, + this.eMPLOYEEDISPLAYNAMEAr, + this.eMPLOYEEDISPLAYNAMEEn, + this.eMPLOYEEEMAILADDRESS, + this.eMPLOYEEIMAGE, + this.eMPLOYEEMOBILENUMBER, + this.eMPLOYEENAME, + this.eMPLOYEENAMEAr, + this.eMPLOYEENAMEEn, + this.eMPLOYEENUMBER, + this.eMPLOYEEWORKNUMBER, + this.eMPLOYMENTCATEGORY, + this.eMPLOYMENTCATEGORYMEANING, + this.employeeQR, + this.fREQUENCY, + this.fREQUENCYMEANING, + this.fROMROWNUM, + this.gRADEID, + this.gRADENAME, + this.hIREDATE, + this.jOBID, + this.jOBNAME, + this.jOBNAMEAr, + this.jOBNAMEEn, + this.lEDGERID, + this.lOCATIONID, + this.lOCATIONNAME, + this.mANUALTIMECARDFLAG, + this.mANUALTIMECARDMEANING, + this.mobileNumberWithZipCode, + this.nATIONALITYCODE, + this.nATIONALITYMEANING, + this.nATIONALIDENTIFIER, + this.nORMALHOURS, + this.nOOFROWS, + this.oRGANIZATIONID, + this.oRGANIZATIONNAME, + this.pAYROLLCODE, + this.pAYROLLID, + this.pAYROLLNAME, + this.pERSONID, + this.pERSONTYPE, + this.pERSONTYPEID, + this.pERINFORMATIONCATEGORY, + this.pOSITIONID, + this.pOSITIONNAME, + this.pRIMARYFLAG, + this.rOWNUM, + this.sERVICEDAYS, + this.sERVICEMONTHS, + this.sERVICEYEARS, + this.sUPERVISORASSIGNMENTID, + this.sUPERVISORDISPLAYNAME, + this.sUPERVISOREMAILADDRESS, + this.sUPERVISORID, + this.sUPERVISORMOBILENUMBER, + this.sUPERVISORNAME, + this.sUPERVISORNUMBER, + this.sUPERVISORWORKNUMBER, + this.sWIPESEXEMPTEDFLAG, + this.sWIPESEXEMPTEDMEANING, + this.sYSTEMPERSONTYPE, + this.tKEMAILADDRESS, + this.tKEMPLOYEEDISPLAYNAME, + this.tKEMPLOYEENAME, + this.tKEMPLOYEENUMBER, + this.tKPERSONID, + this.tOROWNUM, + this.uNITNUMBER, + this.uSERSTATUS}); MemberInformationListModel.fromJson(Map json) { aCTUALTERMINATIONDATE = json['ACTUAL_TERMINATION_DATE']; @@ -339,6 +339,19 @@ class MemberInformationListModel { return data; } + String getPositionName() { + String positionName = ""; + List list = pOSITIONNAME?.split(".") ?? []; + if (list.isNotEmpty) { + if (list.length > 1) { + positionName = list[0] + " " + list[1]; + } else { + positionName = list.first; + } + } + return positionName; + } + static Future> getFromPrefs() async { SharedPreferences prefs = await SharedPreferences.getInstance(); List encodedList = prefs.getStringList(SharedPrefsConsts.memberInformation) ?? []; @@ -350,4 +363,4 @@ class MemberInformationListModel { List encodedList = list.map((e) => jsonEncode(e.toJson())).toList(); await prefs.setStringList(SharedPrefsConsts.memberInformation, encodedList); } -} \ No newline at end of file +} diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 17f90d2..78ceeaa 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -56,17 +56,13 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future fetchAttendanceTracking(context) async { try { attendanceTracking = await DashboardApiClient().getAttendanceTracking(); - print("attendanceTracking:" + (attendanceTracking!.pRemainingHours).toString()); isAttendanceTrackingLoading = false; // isTimeRemainingInSeconds = calculateSeconds( "00:00:00"); if (attendanceTracking?.pSwipeIn != null) { isTimeRemainingInSeconds = calculateSeconds(attendanceTracking!.pRemainingHours ?? "00:00:00"); int totalShiftTimeInSeconds = calculateSeconds(attendanceTracking!.pScheduledHours ?? "00:00:00"); - print("totalShiftTimeInSeconds: " + totalShiftTimeInSeconds.toString()); - print("isTimeRemainingInSeconds: " + isTimeRemainingInSeconds.toString()); progress = (isTimeRemainingInSeconds / totalShiftTimeInSeconds); endTime = DateTime.now().millisecondsSinceEpoch + Duration(seconds: isTimeRemainingInSeconds).inMilliseconds; - print("endTime " + endTime.toString()); } notifyListeners(); @@ -155,17 +151,17 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { DrawerMenuItem("assets/images/drawer/performance_evaluation.svg", LocaleKeys.performanceEvaluation.tr(), AppRoutes.performanceEvaluation), DrawerMenuItem("assets/images/drawer/mowadhafi.svg", LocaleKeys.mowadhafhi.tr(), AppRoutes.mowadhafhi), DrawerMenuItem("assets/images/drawer/pending_trasactions.svg", LocaleKeys.pendingTransactions.tr(), AppRoutes.pendingTransactions), - DrawerMenuItem("assets/images/drawer/change_password.svg", LocaleKeys.changePassword.tr(), ""), + DrawerMenuItem("assets/images/drawer/change_password.svg", LocaleKeys.changePassword.tr(), AppRoutes.changePassword), ]; void fetchListMenu() async { try { List menuList = await DashboardApiClient().getListMenu(); - List findMyRequest = menuList.where((element) => element.menuName == "My Requests").toList(); + List findMyRequest = menuList.where((element) => element.menuType == "E").toList(); if (findMyRequest.isNotEmpty) { drawerMenuItemList.insert(3, DrawerMenuItem("assets/images/drawer/my_requests.svg", LocaleKeys.myRequest.tr(), AppRoutes.myRequests)); } - List findMyTeam = menuList.where((element) => element.menuName == "My Team").toList(); + List findMyTeam = menuList.where((element) => element.menuType == "M").toList(); if (findMyTeam.isNotEmpty) { drawerMenuItemList.insert(2, DrawerMenuItem("assets/images/drawer/my_team.svg", LocaleKeys.myTeamMembers.tr(), AppRoutes.myTeam)); } diff --git a/lib/ui/dialogs/id/business_card_dialog.dart b/lib/ui/dialogs/id/business_card_dialog.dart index 3488958..141abbd 100644 --- a/lib/ui/dialogs/id/business_card_dialog.dart +++ b/lib/ui/dialogs/id/business_card_dialog.dart @@ -1,65 +1,67 @@ import 'package:flutter/material.dart'; -import 'package:mohem_flutter_app/extensions/int_extensions.dart'; -import 'package:mohem_flutter_app/extensions/string_extensions.dart'; - import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/extensions/int_extensions.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; class BusinessCardDialog extends StatelessWidget { @override Widget build(BuildContext context) { return RotatedBox( quarterTurns: 1, - child: Container( - width: MediaQuery.of(context).size.height / 2, - color: Colors.white, - margin: EdgeInsets.all(20), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Image.asset( - "assets/images/logos/bn_cloud_soloution.jpg", - width: 80, - height: 80, - ), - 12.height, - (AppState().memberInformationList!.eMPLOYEENAME ?? "").toText20(), - ], + child: AspectRatio( + aspectRatio: 3.5 / 2, + child: Container( + // width: MediaQuery.of(context).size.height / 2, + color: Colors.white, + margin: EdgeInsets.all(21), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Image.asset( + "assets/images/logos/bn_cloud_soloution.jpg", + width: 80, + height: 80, + ), + 12.height, + (AppState().memberInformationList!.eMPLOYEENAME ?? "").toText20(isBold: true), + ], + ), + ), + Image.memory( + Utils.getPostBytes(AppState().memberInformationList!.businessCardQR ?? ""), + width: 100, + height: 100, ), - ), - Image.memory( - Utils.getPostBytes(AppState().memberInformationList!.businessCardQR ?? ""), - width: 100, - height: 100, - ), - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - 1.height, - (AppState().memberInformationList!.pOSITIONNAME ?? "").toText12(isBold: false), - 12.height, - (AppState().memberInformationList!.eMPLOYEENUMBER ?? "").toText12(isBold: false), - 1.height, - (AppState().memberInformationList!.eMPLOYEEEMAILADDRESS ?? "").toText12(isBold: false), - 1.height, - (AppState().memberInformationList!.jOBNAME ?? "").toText12(isBold: false), - ], - ), - ], + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + 1.height, + (AppState().memberInformationList!.getPositionName() ?? "").toText13(), + 12.height, + (AppState().memberInformationList!.eMPLOYEENUMBER ?? "").toText13(), + 1.height, + (AppState().memberInformationList!.eMPLOYEEEMAILADDRESS ?? "").toText13(), + 1.height, + (AppState().memberInformationList!.jOBNAME ?? "").toText13(), + ], + ), + ], + ), ), ), ); diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index 2971b24..b86fc4e 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -5,6 +5,7 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; @@ -15,6 +16,7 @@ import 'package:mohem_flutter_app/ui/dialogs/id/business_card_dialog.dart'; import 'package:mohem_flutter_app/ui/dialogs/id/employee_digital_id_dialog.dart'; import 'package:mohem_flutter_app/widgets/dialogs/dialogs.dart'; import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class AppDrawer extends StatefulWidget { @override @@ -43,22 +45,23 @@ class _AppDrawerState extends State { ).paddingOnly(left: 4, right: 14), Row( children: [ - AppState().memberInformationList!.eMPLOYEEIMAGE == null - ? SvgPicture.asset( - "assets/images/user.svg", - height: 52, - width: 52,) - : CircleAvatar( - radius: 52 / 2, - backgroundImage: MemoryImage(Utils.getPostBytes(AppState().memberInformationList!.eMPLOYEEIMAGE)), - backgroundColor: Colors.black, - ), + AppState().memberInformationList!.eMPLOYEEIMAGE == null + ? SvgPicture.asset( + "assets/images/user.svg", + height: 52, + width: 52, + ) + : CircleAvatar( + radius: 52 / 2, + backgroundImage: MemoryImage(Utils.getPostBytes(AppState().memberInformationList!.eMPLOYEEIMAGE)), + backgroundColor: Colors.black, + ), 12.width, Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppState().memberInformationList!.eMPLOYEENAME!.toText18(isBold: true), - AppState().memberInformationList!.jOBNAME!.toText14(weight: FontWeight.w500), + AppState().memberInformationList!.getPositionName().toText14(weight: FontWeight.w500), ], ).expanded ], @@ -83,7 +86,7 @@ class _AppDrawerState extends State { }), menuItem("assets/images/drawer/employee_id.svg", LocaleKeys.employeeDigitalID.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: EmployeeDigitialIdDialog())), menuItem("assets/images/drawer/view_business_card.svg", LocaleKeys.viewBusinessCard.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: BusinessCardDialog())), - menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: () {}), + menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: performLogout), ], ).expanded, const Divider( @@ -128,7 +131,12 @@ class _AppDrawerState extends State { : onPress!); } - void drawerNavigator(context, routeName) { - Navigator.of(context).pushNamed(routeName); + void performLogout() async { + AppState().isAuthenticated = false; + AppState().isLogged = false; + AppState().setPostParamsInitConfig(); + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.clear(); + Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route route) => false, arguments: false); } } diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index d2e9208..5b2a207 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -39,13 +39,7 @@ class ServicesWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - data.homeMenus![parentIndex].menuEntry.prompt!.toSectionHeading().expanded, - LocaleKeys.viewAllServices.tr().toText12(isUnderLine: true), - ], - ).paddingOnly(left: 21, right: 21), + data.homeMenus![parentIndex].menuEntry.prompt!.toSectionHeading().paddingOnly(left: 21, right: 21), SizedBox( height: 105 + 26, child: ListView.separated( diff --git a/lib/ui/login/change_password_screen.dart b/lib/ui/login/change_password_screen.dart new file mode 100644 index 0000000..0409500 --- /dev/null +++ b/lib/ui/login/change_password_screen.dart @@ -0,0 +1,174 @@ +import 'package:easy_localization/src/public_ext.dart'; +import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/api/login_api_client.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/extensions/int_extensions.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/input_widget.dart'; + +class ChangePasswordScreen extends StatefulWidget { + ChangePasswordScreen({Key? key}) : super(key: key); + + @override + _ChangePasswordScreenState createState() { + return _ChangePasswordScreenState(); + } +} + +class _ChangePasswordScreenState extends State { + TextEditingController oldPassword = TextEditingController(); + TextEditingController password = TextEditingController(); + TextEditingController confirmPassword = TextEditingController(); + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void setNewPassword() async { + Utils.showLoading(context); + try { + var genericResponseModel = await LoginApiClient().changePasswordFromActiveSession(oldPassword.text, password.text, confirmPassword.text); + Utils.hideLoading(context); + Utils.showToast(LocaleKeys.passwordChangedSuccessfully.tr()); + Navigator.pop(context); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, (msg) { + Utils.confirmDialog(context, msg); + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.transparent, + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor), + onPressed: () => Navigator.pop(context), + ), + ), + body: Column( + children: [ + ListView( + padding: const EdgeInsets.all(21), + children: [ + "Change Password".toText24(isBold: true), + "Type Your Current password below".toText16(), + 16.height, + InputWidget( + "Current password", + "**********", + oldPassword, + onChange: (value) { + setState(() {}); + }, + ), + 16.height, + LocaleKeys.typeYourNewPasswordBelow.tr().toText16(), + 16.height, + InputWidget( + LocaleKeys.password.tr(), + "**********", + password, + onChange: (value) { + setState(() {}); + }, + ), + 12.height, + InputWidget( + LocaleKeys.confirmPassword.tr(), + "**********", + confirmPassword, + isObscureText: true, + onChange: (value) { + setState(() {}); + }, + ), + 16.height, + passwordConstraintsUI(LocaleKeys.doNotUseRecentPassword.tr(), true), + 8.height, + passwordConstraintsUI(LocaleKeys.atLeastOneLowercase.tr(), checkRegEx(r'[a-z]')), + 8.height, + passwordConstraintsUI(LocaleKeys.atLeastOneUppercase.tr(), checkRegEx(r'[A-Z]')), + 8.height, + passwordConstraintsUI(LocaleKeys.atLeastOneNumeric.tr(), checkRegEx(r'[0-9]')), + 8.height, + passwordConstraintsUI(LocaleKeys.minimum8Characters.tr(), password.text.length >= 8), + 8.height, + passwordConstraintsUI(LocaleKeys.doNotAddRepeatingLetters.tr(), checkRepeatedChars(password.text)), + 8.height, + passwordConstraintsUI(LocaleKeys.itShouldContainSpecialCharacter.tr(), checkRegEx(r'[!@#$%^&*(),.?":{}|<>]')), + 8.height, + passwordConstraintsUI(LocaleKeys.confirmPasswordMustMatch.tr(), password.text.isNotEmpty && password.text == confirmPassword.text), + ], + ).expanded, + DefaultButton(LocaleKeys.changePassword.tr(), (!isPasswordCompliant(password.text, 8)) ? null : setNewPassword).insideContainer + ], + ), + ); + } + + bool checkRegEx(String pattern) { + return RegExp(pattern).hasMatch(password.text); + } + + String recentPassword = ""; + + bool isPasswordCompliant(String? password, int minLength) { + if (password == null || password.isEmpty) { + return false; + } + + bool hasUppercase = password.contains(RegExp(r'[A-Z]')); + bool hasDigits = password.contains(RegExp(r'[0-9]')); + bool hasLowercase = password.contains(RegExp(r'[a-z]')); + bool hasSpecialCharacters = password.contains(RegExp(r'[!@#$%^&*(),.?":{}|<>]')); + bool hasMinLength = password.length >= minLength; + bool isMatched = password == confirmPassword.text; + + return hasDigits && hasUppercase && hasLowercase && hasSpecialCharacters && hasMinLength && isMatched && checkRepeatedChars(password); + } + + bool checkRepeatedChars(String password) { + bool isNonRepeatedLetters = true; + if (password.length > 2) { + for (int i = 0; i < password.length; i++) { + String char = password[i]; + try { + if (char == password[i + 1]) { + isNonRepeatedLetters = false; + break; + } + } catch (ex) {} + } + } + return isNonRepeatedLetters; + } + + Widget passwordConstraintsUI(String description, bool check) { + return Row( + children: [ + 4.width, + SizedBox( + width: 12, + height: 12, + child: Checkbox(fillColor: MaterialStateProperty.all(MyColors.gradiantEndColor), shape: const CircleBorder(), value: check, onChanged: null), + ), + 8.width, + description.toText14() + ], + ); + } +} diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index 7cccca8..f0f2c48 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -45,11 +45,12 @@ class _LoginScreenState extends State { bool _autoLogin = false; + bool? isAppOpenBySystem; + @override void initState() { super.initState(); - checkFirebaseToken(); - //checkPrefs(); + // checkFirebaseToken(); } @override @@ -57,18 +58,6 @@ class _LoginScreenState extends State { super.dispose(); } - Future checkPrefs() async { - String username = await Utils.getStringFromPrefs(SharedPrefsConsts.username); - if (username.isNotEmpty) { - String password = await Utils.getStringFromPrefs(SharedPrefsConsts.password); - // String firebaseToken = await Utils.getStringFromPrefs(SharedPrefsConsts.firebaseToken); - // print("firebaseToken:$firebaseToken"); - this.username.text = username; - this.password.text = password; - _autoLogin = true; - } - } - String? firebaseToken; GetMobileLoginInfoListModel? loginInfo; @@ -90,16 +79,21 @@ class _LoginScreenState extends State { } } catch (ex) { Utils.hideLoading(context); - Utils.handleException(ex, context, (errorMsg){}); + Utils.handleException(ex, context, (errorMsg) {}); } } - // Future getFirebaseToken() async { - // String? firebaseToken = await _firebaseMessaging.getToken(); - // if (firebaseToken != null) { - // await Utils.saveStringFromPrefs(SharedPrefsConsts.firebaseToken, firebaseToken); - // } - // } + Future checkPrefs() async { + String username = await Utils.getStringFromPrefs(SharedPrefsConsts.username); + if (username.isNotEmpty) { + String password = await Utils.getStringFromPrefs(SharedPrefsConsts.password); + // String firebaseToken = await Utils.getStringFromPrefs(SharedPrefsConsts.firebaseToken); + // print("firebaseToken:$firebaseToken"); + this.username.text = username; + this.password.text = password; + _autoLogin = true; + } + } void performLogin() async { Utils.showLoading(context); @@ -114,8 +108,8 @@ class _LoginScreenState extends State { AppState().setPrivilegeListModel = await PrivilegeListModel.getFromPrefs(); String mohemmWifiSSID = await Utils.getStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID); String mohemmWifiPassword = await Utils.getStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword); - AppState().mohemmWifiSSID = mohemmWifiSSID; - AppState().mohemmWifiPassword = mohemmWifiPassword; + AppState().setMohemmWifiSSID = mohemmWifiSSID; + AppState().setMohemmWifiPassword = mohemmWifiPassword; } Utils.hideLoading(context); if (_autoLogin) { @@ -124,7 +118,6 @@ class _LoginScreenState extends State { Navigator.pushNamed(context, AppRoutes.verifyLogin, arguments: "$firebaseToken"); } } catch (ex) { - print(ex); Utils.hideLoading(context); Utils.handleException(ex, context, (msg) { Utils.confirmDialog(context, msg); @@ -134,8 +127,14 @@ class _LoginScreenState extends State { @override Widget build(BuildContext context) { - username.text = "15153"; - password.text = "Abcd@12345"; + if (isAppOpenBySystem == null) { + isAppOpenBySystem = (ModalRoute.of(context)!.settings.arguments ?? true) as bool; + print('isAppOpenBySystem:$isAppOpenBySystem'); + username.text = "15153"; + password.text = "Abcd@12345"; + if (isAppOpenBySystem!) checkFirebaseToken(); + } + // username.text = "15444"; return Scaffold( diff --git a/lib/ui/login/new_password_screen.dart b/lib/ui/login/new_password_screen.dart index 7f011e7..e2ef55d 100644 --- a/lib/ui/login/new_password_screen.dart +++ b/lib/ui/login/new_password_screen.dart @@ -46,7 +46,7 @@ class _NewPasswordScreenState extends State { } catch (ex) { print(ex); Utils.hideLoading(context); - Utils.handleException(ex, context, (msg) { + Utils.handleException(ex, context, (msg) { Utils.confirmDialog(context, msg); }); } @@ -66,54 +66,48 @@ class _NewPasswordScreenState extends State { ), body: Column( children: [ - //const SizedBox(height: 23), - Expanded( - child: ListView( - // mainAxisSize: MainAxisSize.min, - // crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisAlignment: MainAxisAlignment.center, - children: [ - LocaleKeys.setTheNewPassword.tr().toText24(isBold: true), - LocaleKeys.typeYourNewPasswordBelow.tr().toText16(), - 16.height, - InputWidget( - LocaleKeys.password.tr(), - "**********", - password, - onChange: (value) { - setState(() {}); - }, - ), - 12.height, - InputWidget( - LocaleKeys.confirmPassword.tr(), - "**********", - confirmPassword, - isObscureText: true, - onChange: (value) { - setState(() {}); - }, - ), - 12.height, - passwordConstraintsUI(LocaleKeys.doNotUseRecentPassword.tr(), true), - 8.height, - passwordConstraintsUI(LocaleKeys.atLeastOneLowercase.tr(), checkRegEx(r'[a-z]')), - 8.height, - passwordConstraintsUI(LocaleKeys.atLeastOneUppercase.tr(), checkRegEx(r'[A-Z]')), - 8.height, - passwordConstraintsUI(LocaleKeys.atLeastOneNumeric.tr(), checkRegEx(r'[0-9]')), - 8.height, - passwordConstraintsUI(LocaleKeys.minimum8Characters.tr(), password.text.length >= 8), - 8.height, - passwordConstraintsUI(LocaleKeys.doNotAddRepeatingLetters.tr(), checkRepeatedChars(password.text)), - 8.height, - passwordConstraintsUI(LocaleKeys.itShouldContainSpecialCharacter.tr(), checkRegEx(r'[!@#$%^&*(),.?":{}|<>]')), - 8.height, - passwordConstraintsUI(LocaleKeys.confirmPasswordMustMatch.tr(), password.text.isNotEmpty && password.text == confirmPassword.text), - 12.height, - ], - ).paddingAll(21), - ), + ListView( + padding: const EdgeInsets.all(21), + children: [ + LocaleKeys.setTheNewPassword.tr().toText24(isBold: true), + LocaleKeys.typeYourNewPasswordBelow.tr().toText16(), + 16.height, + InputWidget( + LocaleKeys.password.tr(), + "**********", + password, + onChange: (value) { + setState(() {}); + }, + ), + 12.height, + InputWidget( + LocaleKeys.confirmPassword.tr(), + "**********", + confirmPassword, + isObscureText: true, + onChange: (value) { + setState(() {}); + }, + ), + 16.height, + passwordConstraintsUI(LocaleKeys.doNotUseRecentPassword.tr(), true), + 8.height, + passwordConstraintsUI(LocaleKeys.atLeastOneLowercase.tr(), checkRegEx(r'[a-z]')), + 8.height, + passwordConstraintsUI(LocaleKeys.atLeastOneUppercase.tr(), checkRegEx(r'[A-Z]')), + 8.height, + passwordConstraintsUI(LocaleKeys.atLeastOneNumeric.tr(), checkRegEx(r'[0-9]')), + 8.height, + passwordConstraintsUI(LocaleKeys.minimum8Characters.tr(), password.text.length >= 8), + 8.height, + passwordConstraintsUI(LocaleKeys.doNotAddRepeatingLetters.tr(), checkRepeatedChars(password.text)), + 8.height, + passwordConstraintsUI(LocaleKeys.itShouldContainSpecialCharacter.tr(), checkRegEx(r'[!@#$%^&*(),.?":{}|<>]')), + 8.height, + passwordConstraintsUI(LocaleKeys.confirmPasswordMustMatch.tr(), password.text.isNotEmpty && password.text == confirmPassword.text), + ], + ).expanded, DefaultButton( LocaleKeys.update.tr(), (!isPasswordCompliant(password.text, 8)) diff --git a/lib/ui/login/verify_last_login_screen.dart b/lib/ui/login/verify_last_login_screen.dart index f9bfd97..f47b2a4 100644 --- a/lib/ui/login/verify_last_login_screen.dart +++ b/lib/ui/login/verify_last_login_screen.dart @@ -58,116 +58,113 @@ class _VerifyLastLoginScreenState extends State { ), body: Column( children: [ - Expanded( - child: ListView( - padding: const EdgeInsets.all(21), - physics: const BouncingScrollPhysics(), - children: [ - //12.height, - if (true) - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.welcomeBack.tr().toText12(), - mobileLoginInfoListModel!.employeeName!.toText24(isBold: true), - 10.height, - LocaleKeys.wouldYouLikeToLoginWithCurrentUsername.tr().toText16(), - Container( - height: 72, - margin: const EdgeInsets.only(top: 23, bottom: 23), - alignment: Alignment.center, - padding: const EdgeInsets.only(left: 17, right: 12), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - border: Border.all( - color: const Color(0xffefefef), - width: 1, - ), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - LocaleKeys.lastLoginDetails.tr().toText16(), - DateUtil.formatDateToDate(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn!), false).toText12(), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - LocaleKeys.verificationType.tr().toText10(color: MyColors.grey57Color), - getVerificationType(mobileLoginInfoListModel!.loginType!).toText12(), - Expanded(child: SizedBox()), - DateUtil.formatDateToTime(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn!)).toText12(), - ], - ) - ], + ListView( + padding: const EdgeInsets.all(21), + physics: const BouncingScrollPhysics(), + children: [ + //12.height, + if (true) + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.welcomeBack.tr().toText12(), + mobileLoginInfoListModel!.employeeName!.toText24(isBold: true), + 10.height, + LocaleKeys.wouldYouLikeToLoginWithCurrentUsername.tr().toText16(), + Container( + height: 72, + margin: const EdgeInsets.only(top: 23, bottom: 23), + alignment: Alignment.center, + padding: const EdgeInsets.only(left: 17, right: 12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + border: Border.all( + color: const Color(0xffefefef), + width: 1, ), ), - LocaleKeys.pleaseVerify.tr().toText16(), - GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), - physics: const NeverScrollableScrollPhysics(), - padding: const EdgeInsets.only(top: 9), - shrinkWrap: true, + child: Column( + mainAxisSize: MainAxisSize.min, children: [ - getButton(3), - getButton(4), - getButton(2), - getButton(1), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + LocaleKeys.lastLoginDetails.tr().toText16(), + DateUtil.formatDateToDate(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn!), false).toText12(), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + LocaleKeys.verificationType.tr().toText10(color: MyColors.grey57Color), + getVerificationType(mobileLoginInfoListModel!.loginType!).toText12(), + Expanded(child: SizedBox()), + DateUtil.formatDateToTime(DateUtil.convertStringToDate(mobileLoginInfoListModel!.editedOn!)).toText12(), + ], + ) ], - ) - ], - ) - // else - // Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Image.asset( - // 'assets/images/habib-logo.png', - // height: 90, - // width: 90, - // ), - // SizedBox(height: 23), - // this.onlySMSBox == false - // ? Text( - // TranslationBase.of(context).verifyLoginWith, - // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), - // ) - // : Text( - // TranslationBase.of(context).verifyFingerprint2, - // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), - // ), - // SizedBox(height: 23), - // Text( - // TranslationBase.of(context).pleaseVerify, - // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), - // ), - // GridView( - // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), - // physics: NeverScrollableScrollPhysics(), - // padding: EdgeInsets.only(top: 9), - // shrinkWrap: true, - // children: [ - // if (onlySMSBox == false) getButton(3), - // if (onlySMSBox == false) getButton(2), - // getButton(1), - // getButton(4), - // ], - // ), - // ]), - ], - ), - ), - 12.height, + ), + ), + LocaleKeys.pleaseVerify.tr().toText16(), + GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.only(top: 9), + shrinkWrap: true, + children: [ + getButton(3), + getButton(4), + getButton(2), + getButton(1), + ], + ) + ], + ) + // else + // Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ + // Image.asset( + // 'assets/images/habib-logo.png', + // height: 90, + // width: 90, + // ), + // SizedBox(height: 23), + // this.onlySMSBox == false + // ? Text( + // TranslationBase.of(context).verifyLoginWith, + // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), + // ) + // : Text( + // TranslationBase.of(context).verifyFingerprint2, + // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), + // ), + // SizedBox(height: 23), + // Text( + // TranslationBase.of(context).pleaseVerify, + // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), + // ), + // GridView( + // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), + // physics: NeverScrollableScrollPhysics(), + // padding: EdgeInsets.only(top: 9), + // shrinkWrap: true, + // children: [ + // if (onlySMSBox == false) getButton(3), + // if (onlySMSBox == false) getButton(2), + // getButton(1), + // getButton(4), + // ], + // ), + // ]), + ], + ).expanded, DefaultButton( LocaleKeys.useAnotherAccount.tr(), - () => { - //Navigator.of(context).pushNamed(LOGIN_TYPE) + () { + Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route route) => false,arguments: false); }, ).insideContainer, ], diff --git a/lib/ui/login/verify_login_screen.dart b/lib/ui/login/verify_login_screen.dart index 4a3249b..d03fb71 100644 --- a/lib/ui/login/verify_login_screen.dart +++ b/lib/ui/login/verify_login_screen.dart @@ -13,14 +13,12 @@ import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/dialogs/otp_dialog.dart'; -import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/basic_member_information_model.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/member_information_list_model.dart'; import 'package:mohem_flutter_app/models/privilege_list_model.dart'; -import 'package:mohem_flutter_app/widgets/button/default_button.dart'; class VerifyLoginScreen extends StatefulWidget { VerifyLoginScreen({Key? key}) : super(key: key); @@ -56,142 +54,23 @@ class _VerifyLoginScreenState extends State { ), // actions: [Center(child: "Employee Digital ID".toText12(color: MyColors.textMixColor, isUnderLine: true).onPress(() {})), 21.width], ), - body: Column( + body: ListView( + padding: const EdgeInsets.all(21), + physics: const BouncingScrollPhysics(), children: [ - Expanded( - child: ListView( - padding: const EdgeInsets.all(21), - physics: const BouncingScrollPhysics(), - children: [ - //12.height, - if (true) - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // LocaleKeys.welcomeBack.tr().toText12(), - // "Mohammad Hussain".toText24(isBold: true), - // 10.height, - // LocaleKeys.wouldYouLikeToLoginWithCurrentUsername.tr().toText16(), - // Container( - // height: 72, - // margin: const EdgeInsets.only(top: 23, bottom: 23), - // alignment: Alignment.center, - // padding: EdgeInsets.only(left: 17, right: 12), - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10), - // color: Colors.white, - // border: Border.all( - // color: Color(0xffefefef), - // width: 1, - // ), - // ), - // child: Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // LocaleKeys.lastLoginDetails.tr().toText16(), - // // Text( - // // user.editedOn != null - // // ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user.editedOn)) - // // : user.createdOn != null - // // ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user.createdOn)) - // // : '--', - // // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), - // // ), - // ], - // ), - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // LocaleKeys.verificationType.tr().toText10(color: MyColors.grey57Color), - // Text( - // "SMS", - // // " " + getType(user.logInType, context), - // style: TextStyle( - // fontSize: 12, - // fontWeight: FontWeight.w600, - // color: Color(0xff2B353E), - // ), - // ), - // Expanded(child: SizedBox()), - // // Text( - // // user.editedOn != null - // // ? DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(user.editedOn), false) - // // : user.createdOn != null - // // ? DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(user.createdOn), false) - // // : '--', - // // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.48), - // // ), - // ], - // ) - // ], - // ), - // ), - LocaleKeys.pleaseVerify.tr().toText16(), - GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), - physics: const NeverScrollableScrollPhysics(), - padding: const EdgeInsets.only(top: 9), - shrinkWrap: true, - children: [ - getButton(3), - getButton(4), - getButton(2), - getButton(1), - ], - ) - ], - ) - // else - // Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Image.asset( - // 'assets/images/habib-logo.png', - // height: 90, - // width: 90, - // ), - // SizedBox(height: 23), - // this.onlySMSBox == false - // ? Text( - // TranslationBase.of(context).verifyLoginWith, - // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), - // ) - // : Text( - // TranslationBase.of(context).verifyFingerprint2, - // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), - // ), - // SizedBox(height: 23), - // Text( - // TranslationBase.of(context).pleaseVerify, - // style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), - // ), - // GridView( - // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), - // physics: NeverScrollableScrollPhysics(), - // padding: EdgeInsets.only(top: 9), - // shrinkWrap: true, - // children: [ - // if (onlySMSBox == false) getButton(3), - // if (onlySMSBox == false) getButton(2), - // getButton(1), - // getButton(4), - // ], - // ), - // ]), - ], - ), - ), - 12.height, - DefaultButton( - LocaleKeys.useAnotherAccount.tr(), - () => { - //Navigator.of(context).pushNamed(LOGIN_TYPE) - }, - ).insideContainer, + LocaleKeys.pleaseVerify.tr().toText16(), + GridView( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.only(top: 9), + shrinkWrap: true, + children: [ + getButton(3), + getButton(4), + getButton(2), + getButton(1), + ], + ) ], ), ); @@ -686,8 +565,8 @@ class _VerifyLoginScreenState extends State { print(element.serviceName.toString() + " " + element.previlege.toString()); // Check availability }); PrivilegeListModel.saveToPrefs(genericResponseModel.privilegeList ?? []); - AppState().mohemmWifiSSID = genericResponseModel.mohemmWifiSSID; - AppState().mohemmWifiPassword = genericResponseModel.mohemmWifiPassword; + AppState().setMohemmWifiSSID = genericResponseModel.mohemmWifiSSID; + AppState().setMohemmWifiPassword = genericResponseModel.mohemmWifiPassword; Utils.saveStringFromPrefs(SharedPrefsConsts.username, AppState().getUserName!); Utils.saveStringFromPrefs(SharedPrefsConsts.password, AppState().password!); Utils.saveStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID, genericResponseModel.mohemmWifiSSID!); @@ -707,7 +586,6 @@ class _VerifyLoginScreenState extends State { }, ).displayDialog(context); } catch (ex) { - print(ex); Utils.hideLoading(context); Utils.handleException(ex, context, null); } diff --git a/lib/ui/profile/basic_details.dart b/lib/ui/profile/basic_details.dart index a2896a5..7aad54b 100644 --- a/lib/ui/profile/basic_details.dart +++ b/lib/ui/profile/basic_details.dart @@ -44,8 +44,16 @@ class _BasicDetailsState extends State { super.initState(); memberInformationList = AppState().memberInformationList!; List menuData = Provider.of(context, listen: false).getMenuEntriesList!; + for( int i=0;i e.requestType == 'BASIC_DETAILS').toList(); + if(filterList.isNotEmpty) { + menuEntries = filterList.first; + } - menuEntries = menuData.where((e) => e.requestType == 'BASIC_DETAILS').toList()[0]; getEmployeeBasicDetails(); } diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index 4bc3fa1..eb23a93 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -44,8 +44,16 @@ class _ContactDetailsState extends State { super.initState(); List menuData = Provider.of(context, listen: false).getMenuEntriesList!; - menuEntriesPhone = menuData.where((GetMenuEntriesList e) => e.requestType == 'PHONE_NUMBERS').toList()[0]; - menuEntriesAddress = menuData.where((GetMenuEntriesList e) => e.requestType == 'ADDRESS').toList()[0]; + var filterList = menuData.where((GetMenuEntriesList e) => e.requestType == 'PHONE_NUMBERS').toList(); + + if (filterList.isNotEmpty) { + menuEntriesPhone = filterList.first; + } + filterList = menuData.where((GetMenuEntriesList e) => e.requestType == 'ADDRESS').toList(); + if (filterList.isNotEmpty) { + menuEntriesAddress = filterList.first; + } + getEmployeePhones(); } diff --git a/lib/ui/profile/widgets/profile_info.dart b/lib/ui/profile/widgets/profile_info.dart index 2be854e..1ac5f93 100644 --- a/lib/ui/profile/widgets/profile_info.dart +++ b/lib/ui/profile/widgets/profile_info.dart @@ -30,7 +30,7 @@ class ProfileInFo extends StatelessWidget { children: [ 16.height, memberInfo.eMPLOYEENAME!.toText22(), - ("${memberInfo.eMPLOYEENUMBER!} | ${memberInfo.jOBNAME!}").toText13(color: MyColors.grey80Color), + ("${memberInfo.eMPLOYEENUMBER!} | ${memberInfo.getPositionName()}").toText13(color: MyColors.grey80Color), memberInfo.eMPLOYEEEMAILADDRESS!.toText13(), 12.height, const Divider(height: 8, thickness: 8, color: MyColors.lightGreyEFColor), diff --git a/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart b/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart index 45d881f..0002c51 100644 --- a/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart +++ b/lib/ui/screens/mowadhafhi/mowadhafhi_home.dart @@ -50,56 +50,54 @@ class _MowadhafhiHomeState extends State { context, title: LocaleKeys.mowadhafhiRequest.tr(), ), - body: getTicketsByEmployeeList == null - ? const SizedBox() - : (getTicketsByEmployeeList!.isEmpty) + body: Column( + children: [ + (getTicketsByEmployeeList == null + ? const SizedBox() + : (getTicketsByEmployeeList!.isEmpty) ? Utils.getNoDataWidget(context) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - ListView.separated( - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.all(21), - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - Navigator.pushNamed(context, AppRoutes.mowadhafhiDetails, arguments: getTicketsByEmployeeList![index].ticketId); - }, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - getTicketsByEmployeeList![index].ticketTypeName!.toText14(color: MyColors.darkTextColor).expanded, - getTicketsByEmployeeList![index].created!.split(" ")[0].toText12(color: MyColors.grey70Color), - ], - ), - getTicketsByEmployeeList![index].description!.toText12(color: MyColors.grey57Color), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - getTicketsByEmployeeList![index].ticketStatusInternalName!.toText14(color: MyColors.textMixColor), - SvgPicture.asset( - "assets/images/arrow_next.svg", - color: MyColors.darkIconColor, - ) - ], - ), - ], - ).objectContainerView(), - ); - }, - separatorBuilder: (BuildContext context, int index) => 12.height, - itemCount: getTicketsByEmployeeList!.length) - .expanded, - DefaultButton(LocaleKeys.createRequest.tr(), () async { - await Navigator.pushNamed(context, AppRoutes.mowadhafhiHRRequest); - getOpenTickets(); - }).insideContainer - ], - ), + : ListView.separated( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.all(21), + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, AppRoutes.mowadhafhiDetails, arguments: getTicketsByEmployeeList![index].ticketId); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + getTicketsByEmployeeList![index].ticketTypeName!.toText14(color: MyColors.darkTextColor).expanded, + getTicketsByEmployeeList![index].created!.split(" ")[0].toText12(color: MyColors.grey70Color), + ], + ), + getTicketsByEmployeeList![index].description!.toText12(color: MyColors.grey57Color), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + getTicketsByEmployeeList![index].ticketStatusInternalName!.toText14(color: MyColors.textMixColor), + SvgPicture.asset( + "assets/images/arrow_next.svg", + color: MyColors.darkIconColor, + ) + ], + ), + ], + ).objectContainerView(), + ); + }, + separatorBuilder: (BuildContext context, int index) => 12.height, + itemCount: getTicketsByEmployeeList!.length)) + .expanded, + DefaultButton(LocaleKeys.createRequest.tr(), () async { + await Navigator.pushNamed(context, AppRoutes.mowadhafhiHRRequest); + getOpenTickets(); + }).insideContainer + ], + ), ); } } diff --git a/lib/widgets/app_bar_widget.dart b/lib/widgets/app_bar_widget.dart index 770494e..51bee9c 100644 --- a/lib/widgets/app_bar_widget.dart +++ b/lib/widgets/app_bar_widget.dart @@ -5,7 +5,7 @@ import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; -AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeButton = false, bool showNotificationButton = false, bool showMemberButton = false}) { +AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeButton = true, bool showNotificationButton = false, bool showMemberButton = false}) { return AppBar( leadingWidth: 0, // leading: GestureDetector( @@ -32,11 +32,7 @@ AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeB if (showHomeButton) IconButton( onPressed: () { - // Navigator.pushAndRemoveUntil( - // context, - // MaterialPageRoute(builder: (context) => LandingPage()), - // (Route route) => false, - // ); + Navigator.popUntil(context, ModalRoute.withName(AppRoutes.dashboard)); }, icon: const Icon(Icons.home, color: MyColors.darkIconColor), ), @@ -47,7 +43,7 @@ AppBar AppBarWidget(BuildContext context, {required String title, bool showHomeB }, icon: const Icon(Icons.notifications, color: MyColors.textMixColor), ), - if(showMemberButton) + if (showMemberButton) IconButton( onPressed: () { Navigator.pushNamed(context, AppRoutes.subordinateLeave); diff --git a/lib/widgets/dialogs/dialogs.dart b/lib/widgets/dialogs/dialogs.dart index 9a5a822..8c65a20 100644 --- a/lib/widgets/dialogs/dialogs.dart +++ b/lib/widgets/dialogs/dialogs.dart @@ -1,9 +1,6 @@ import 'package:flutter/material.dart'; -void showMDialog( - context, { - Widget? child, -}) async { +void showMDialog(context, {Widget? child}) async { return showDialog( context: context, barrierDismissible: true, diff --git a/lib/widgets/mark_attendance_widget.dart b/lib/widgets/mark_attendance_widget.dart index 449fd97..a3ed0d5 100644 --- a/lib/widgets/mark_attendance_widget.dart +++ b/lib/widgets/mark_attendance_widget.dart @@ -155,10 +155,11 @@ class _MarkAttendanceWidgetState extends State { print("wifi not location enabled"); } - bool v = await WiFiForIoTPlugin.connect(AppState().mohemmWifiSSID ?? "", password: AppState().mohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false); - if (v) { + bool isConnected = + await WiFiForIoTPlugin.connect(AppState().getMohemmWifiSSID ?? "", password: AppState().getMohemmWifiPassword ?? "", joinOnce: true, security: NetworkSecurity.WPA, withInternet: false); + if (isConnected) { await WiFiForIoTPlugin.forceWifiUsage(true); - print("connected"); + Utils.showLoading(context); try { GenericResponseModel? g = await DashboardApiClient().markAttendance(pointType: 3, nfcValue: "", isGpsRequired: isWifiLocationEnabled, lat: lat, long: lng); @@ -166,7 +167,6 @@ class _MarkAttendanceWidgetState extends State { Utils.hideLoading(context); await closeWifiRequest(); } catch (ex) { - print(ex); await closeWifiRequest(); Utils.hideLoading(context); Utils.handleException(ex, context, (msg) {