From f1beefbc46f4eacb7fd1dddeeb349b183d16e47c Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 19 Jan 2022 17:03:59 +0300 Subject: [PATCH] login apis, models & forgot password screen added. --- assets/langs/ar-SA.json | 91 +++++------ assets/langs/en-US.json | 3 + lib/api/api_client.dart | 3 +- lib/api/login_api_client.dart | 81 ++++++++-- lib/app_state/app_state.dart | 32 ++-- lib/classes/consts.dart | 3 +- lib/classes/utils.dart | 5 +- lib/config/routes.dart | 3 + lib/dialogs/otp_dialog.dart | 71 ++++----- lib/generated/codegen_loader.g.dart | 94 ++++++------ lib/main.dart | 9 +- lib/models/generic_response_model.dart | 184 +++++++++++------------ lib/models/post_params_model.dart | 34 +++++ lib/ui/login/forgot_password_screen.dart | 114 ++++++++++++++ lib/ui/login/login_screen.dart | 39 ++++- lib/ui/login/new_password_screen.dart | 3 +- lib/ui/login/verify_login_screen.dart | 22 ++- 17 files changed, 534 insertions(+), 257 deletions(-) create mode 100644 lib/models/post_params_model.dart create mode 100644 lib/ui/login/forgot_password_screen.dart diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index fee81e6..1d9e8bc 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -2,50 +2,53 @@ "mohemm": "Mohemm", "english": "English", "arabic": "Arabic", - "login": "Login", - "pleaseEnterLoginDetails": "Please enter the detail below to login", - "username": "Username", - "password": "Password", - "welcomeBack": "Welcome back", - "wouldYouLikeToLoginWithCurrentUsername": "Would you like to login with current Username?", - "lastLoginDetails": "Last Login Details:", - "verificationType": "Verification Type:", - "pleaseVerify": "Please Verify", - "verifyThroughFace": "Verify Through Face", - "verifyThroughFingerprint": "Verify Through Fingerprint", - "verifyThroughSMS": "Verify Through SMS", - "verifyThroughWhatsapp": "Verify Through Whatsapp", - "useAnotherAccount": "Use Another Account", - "pleaseEnterTheVerificationCodeSentTo": "Please enter the verification code sent to ", - "theVerificationCodeWillExpireIn": "The verification code will expire in ", - "goodMorning": "Good Morning", - "markAttendance": "Mark Attendance", - "timeLeftToday": "Time Left Today", - "checkIn": "Check In", - "workList": "Work List", - "leaveBalance": "Leave Balance", - "missingSwipes": "Missing Swipes", - "ticketBalance": "Ticket Balance", - "other": "Other", - "services": "Services", - "viewAllServices": "View All Services", - "monthlyAttendance": "Monthly Attendance", - "workFromHome": "Work From Home", - "ticketRequest": "Ticket Request", - "viewAllOffers": "View All Offers", - "offers": "Offers & ", - "discounts": "Discounts", - "newString": "New", - "setTheNewPassword": "Set the new password", - "typeYourNewPasswordBelow": "Type your new password below", - "confirmPassword": "Confirm Password", - "update": "Update", - "title": "Title", - "home": "Home", - "mySalary": "My Salary", - "createRequest": "Create Request", - "forgotPassword": "Forgot Password", - "itemsForSale": "Items for Sale", + "login": "تسجيل الدخول", + "pleaseEnterLoginDetails": "الرجاء إدخال التفاصيل أدناه لتسجيل الدخول", + "username": "اسم المستخدم", + "password": "كلمة المرور", + "welcomeBack": "مرحبا بعودتك", + "wouldYouLikeToLoginWithCurrentUsername": "هل ترغب في تسجيل الدخول باسم المستخدم الحالي؟", + "lastLoginDetails": "تفاصيل تسجيل الدخول الأخير:", + "verificationType": "نوع التحقق:", + "pleaseVerify": "ارجوك تحقق", + "verifyThroughFace": "تحقق من خلال الوجه", + "verifyThroughFingerprint": "تحقق من خلال بصمة الإصبع", + "verifyThroughSMS": "تحقق من خلال الرسائل القصيرة", + "verifyThroughWhatsapp": "تحقق من خلال Whatsapp", + "useAnotherAccount": "استخدم حسابا آخر", + "pleaseEnterTheVerificationCodeSentTo": "الرجاء إدخال رمز التحقق المرسل إلى ", + "theVerificationCodeWillExpireIn": "ستنتهي صلاحية رمز التحقق في ", + "goodMorning": "صباح الخير", + "markAttendance": "علامة الحضور", + "timeLeftToday": "الوقت المتبقي اليوم", + "checkIn": "تحقق في", + "workList": "قائمة العمل", + "leaveBalance": "رصيد الاجازات", + "missingSwipes": "الضربات الشديدة في عداد المفقودين", + "ticketBalance": "رصيد التذكرة", + "other": "آخر", + "services": "خدمات", + "viewAllServices": "عرض جميع الخدمات", + "monthlyAttendance": "الحضور الشهري", + "workFromHome": "العمل من المنزل", + "ticketRequest": "طلب تذكرة", + "viewAllOffers": "مشاهدة جميع العروض", + "offers": "عروض & ", + "discounts": "الخصومات", + "newString": "جديد", + "setTheNewPassword": "قم بتعيين كلمة المرور الجديدة", + "typeYourNewPasswordBelow": "اكتب كلمة المرور الجديدة أدناه", + "confirmPassword": "تأكيد كلمة المرور", + "update": "تحديث", + "title": "عنوان", + "home": "مسكن", + "mySalary": "راتبي", + "createRequest": "إنشاء طلب", + "forgotPassword": "هل نسيت كلمة السر", + "employeeId": "هوية الموظف", + "loginCodeWillSentToMobileNumber": "الرجاء إدخال معرف الموظف الخاص بك ، وسيتم إرسال رمز تسجيل الدخول إلى رقم هاتفك المحمول", + "changePassword": "تغيير كلمة المرور", + "itemsForSale": "سلع للبيع", "msg": "Hello {} in the {} world ", "msg_named": "{} are written in the {lang} language", "clickMe": "Click me", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index fee81e6..9c812ce 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -45,6 +45,9 @@ "mySalary": "My Salary", "createRequest": "Create Request", "forgotPassword": "Forgot Password", + "employeeId": "Employee ID", + "loginCodeWillSentToMobileNumber": "Please Enter your Employee ID, A login code will be sent to your mobile number", + "changePassword": "Change Password", "itemsForSale": "Items for Sale", "msg": "Hello {} in the {} world ", "msg_named": "{} are written in the {lang} language", diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index afba61e..fc289c0 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -70,6 +70,7 @@ class ApiClient { var jsonData = jsonDecode(response.body); return factoryConstructor(jsonData); } catch (ex) { + print(ex); throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); } } @@ -103,7 +104,7 @@ class ApiClient { var queryString = new Uri(queryParameters: queryParameters).query; url = url + '?' + queryString; } - var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(seconds: 15)); + var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(seconds: 60)); if (response.statusCode >= 200 && response.statusCode < 300) { return response; diff --git a/lib/api/login_api_client.dart b/lib/api/login_api_client.dart index be1509e..1811414 100644 --- a/lib/api/login_api_client.dart +++ b/lib/api/login_api_client.dart @@ -1,10 +1,11 @@ import 'dart:async'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; +import 'package:mohem_flutter_app/models/basic_member_information_model.dart'; import 'package:mohem_flutter_app/models/check_mobile_app_version_model.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart'; -import 'package:mohem_flutter_app/models/surah_model.dart'; import 'api_client.dart'; @@ -16,20 +17,78 @@ class LoginApiClient { factory LoginApiClient() => _instance; Future checkMobileAppVersion() async { - String url = "${ApiConsts.rest}CheckMobileAppVersion"; - var postParams = {}; + String url = "${ApiConsts.utilitiesRest}CheckMobileAppVersion"; + Map postParams = {}; + postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) => CheckMobileAppVersionModel.fromJson(json), url, postParams); } - Future memberLogin() async { - String url = "${ApiConsts.rest}MemberLogin"; - var postParams = {}; - return await ApiClient().postJsonForObject((json) => GenericResponseModel.fromJson(json).memberLoginList, url, postParams); + Future memberLogin(String username, String password) async { + String url = "${ApiConsts.erpRest}MemberLogin"; + Map postParams = {"P_APP_VERSION": "CS", "P_LANGUAGE": "US", "P_PASSWORD": password, "P_USER_NAME": username}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + AppState().postParamsObject?.setLogInTokenID = responseData.logInTokenID; + return responseData.memberLoginList; + }, url, postParams); } - Future mohemmSendActivationCodeByOTPNotificationType() async { - String url = "${ApiConsts.rest}Mohemm_SendActivationCodebyOTPNotificationType"; - var postParams = {}; - return await ApiClient().postJsonForObject((json) => GenericResponseModel.fromJson(json), url, postParams); + Future mohemmSendActivationCodeByOTPNotificationType(int isMobileFingerPrint, String? mobileNumber, int optSendType, String? pUserName) async { + String url = "${ApiConsts.erpRest}Mohemm_SendActivationCodebyOTPNotificationType"; + Map postParams = {"IsMobileFingerPrint": isMobileFingerPrint, "MobileNumber": mobileNumber, "OTP_SendType": optSendType, "P_USER_NAME": pUserName}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) => GenericResponseModel.fromJson(json).basicMemberInformation, url, postParams); + } + + Future checkActivationCode(bool isDeviceNFC, String? mobileNumber, String activationCode, String? pUserName) async { + String url = "${ApiConsts.erpRest}CheckActivationCode"; + Map postParams = {"isDeviceNFC": isDeviceNFC, "MobileNumber": mobileNumber, "activationCode": activationCode, "P_USER_NAME": pUserName}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + AppState().postParamsObject?.setTokenID = responseData.tokenID; + return responseData; + }, url, postParams); + } + + Future getBasicUserInformation(String pAppVersion, String pUsername) async { + String url = "${ApiConsts.erpRest}Get_BasicUserInformation"; + Map postParams = {"P_APP_VERSION": pAppVersion, "P_USER_NAME": pUsername}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) => GenericResponseModel.fromJson(json).basicMemberInformation, url, postParams); + } + + Future sendPublicActivationCode(String? mobileNumber, String? pUsername) async { + String url = "${ApiConsts.erpRest}SendPublicActivationCode"; + Map postParams = {"MobileNumber": mobileNumber, "P_MOBILE_NUMBER": mobileNumber, "P_USER_NAME": pUsername}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + AppState().postParamsObject?.setLogInTokenID = responseData.logInTokenID; + return responseData; + }, url, postParams); + } + + Future checkPublicActivationCode(String activationCode, String? pUserName) async { + String url = "${ApiConsts.erpRest}checkPublicActivationCode"; + Map postParams = {"activationCode": activationCode, "P_USER_NAME": pUserName}; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel responseData = GenericResponseModel.fromJson(json); + AppState().setForgetPasswordTokenID = responseData.tokenID; + return responseData; + }, url, postParams); + } + + Future changePasswordForget(String forgetPasswordTokenID, String pNewPassword, String pConfirmNewPassword, String? pUserName) async { + String url = "${ApiConsts.erpRest}ChangePassword_Forget"; + Map postParams = {"P_USER_NAME": pUserName, "ForgetPasswordTokenID": forgetPasswordTokenID, "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 9303802..2af87d8 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -1,5 +1,5 @@ -import 'package:mohem_flutter_app/models/content_info_model.dart'; -import 'package:mohem_flutter_app/models/surah_model.dart'; +import 'package:mohem_flutter_app/models/member_login_list_model.dart'; +import 'package:mohem_flutter_app/models/post_params_model.dart'; class AppState { static final AppState _instance = AppState._internal(); @@ -8,19 +8,29 @@ class AppState { factory AppState() => _instance; - SurahModel? _surahModel; + String? forgetPasswordTokenID; - SurahModel? get getSurahModel => _surahModel; + set setForgetPasswordTokenID(token) => forgetPasswordTokenID = token; - void setSurahModel(SurahModel _surahModel) { - this._surahModel = _surahModel; - } + String? get getForgetPasswordTokenID => forgetPasswordTokenID; + + PostParamsModel? _postParams; - ContentInfoDataModel? _copyRight; + PostParamsModel? get postParamsObject => _postParams; - ContentInfoDataModel? get getContentInfoModel => _copyRight; + Map get postParamsJson => _postParams?.toJson() ?? {}; - void setContentInfoModel(ContentInfoDataModel _copyRight) { - this._copyRight = _copyRight; + void setPostParamsModel(PostParamsModel _postParams) { + this._postParams = _postParams; } + + String? username; + + set setUserName(_username) => username = _username; + + MemberLoginListModel? _memberLoginList; + + MemberLoginListModel? get memberLoginList => _memberLoginList; + + set setMemberLoginListModel(MemberLoginListModel? _memberLoginList) => this._memberLoginList = _memberLoginList; } diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index ecf8b40..b0453c0 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -3,7 +3,8 @@ class ApiConsts { static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server static String baseUrlServices = baseUrl + "/services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server - static String rest = baseUrlServices + "Utilities.svc/REST/"; + static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; + static String erpRest = baseUrlServices + "ERP.svc/REST/"; static String user = baseUrlServices + "api/User/"; } diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 4d26ed6..94fd87b 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; // import 'package:fluttertoast/fluttertoast.dart'; import 'package:mohem_flutter_app/exceptions/api_exception.dart'; @@ -9,8 +10,8 @@ class Utils { static bool get isLoading => _isLoadingVisible; static void showToast(String message) { - // Fluttertoast.showToast( - // msg: message, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0); + Fluttertoast.showToast( + msg: message, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black54, textColor: Colors.white, fontSize: 16.0); } static dynamic getNotNullValue(List list, int index) { diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 4e72b26..39a4ebc 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/ui/landing/dashboard.dart'; import 'package:mohem_flutter_app/ui/landing/today_attendance_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'; import 'package:mohem_flutter_app/ui/login/verify_login_screen.dart'; @@ -13,6 +14,7 @@ class AppRoutes { static const String loginVerifyAccount = "/loginVerifyAccount"; static const String login = "/login"; static const String verifyLogin = "/verifyLogin"; + static const String forgotPassword = "/forgotPassword"; static const String newPassword = "/newPassword"; static const String loginVerification = "/loginVerification"; static const String dashboard = "/dashboard"; @@ -28,6 +30,7 @@ class AppRoutes { verifyLogin: (context) => VerifyLoginScreen(), dashboard: (context) => Dashboard(), newPassword: (context) => NewPasswordScreen(), + forgotPassword: (context) => ForgotPasswordScreen(), todayAttendance: (context) => TodayAttendanceScreen(), //Work List diff --git a/lib/dialogs/otp_dialog.dart b/lib/dialogs/otp_dialog.dart index f589211..d82cf9c 100644 --- a/lib/dialogs/otp_dialog.dart +++ b/lib/dialogs/otp_dialog.dart @@ -11,7 +11,7 @@ import 'package:mohem_flutter_app/widgets/otp_widget.dart'; class OtpDialog { final int type; - final int mobileNo; + final int? mobileNo; final Function(String) onSuccess; final Function onFailure; final BuildContext context; @@ -57,10 +57,11 @@ class OtpDialog { String displayTime = ''; String? _code; dynamic setState; + bool stopTimer = false; // static String signature; - displayDialog(BuildContext context) async { + void displayDialog(BuildContext context) async { return showDialog( context: context, barrierColor: Colors.black.withOpacity(0.63), @@ -68,8 +69,8 @@ class OtpDialog { // projectProvider = Provider.of(context); return Dialog( backgroundColor: Colors.white, - shape: RoundedRectangleBorder(), - insetPadding: EdgeInsets.only(left: 21, right: 21), + shape: const RoundedRectangleBorder(), + insetPadding: const EdgeInsets.only(left: 21, right: 21), child: StatefulBuilder(builder: (context, setState) { if (displayTime == '') { startTimer(setState); @@ -91,14 +92,13 @@ class OtpDialog { width: 50, ), IconButton( - padding: EdgeInsets.zero, - icon: const Icon(Icons.close), - constraints: const BoxConstraints(), - onPressed: () { - Navigator.pop(context); - this.onFailure(); - }, - ) + padding: EdgeInsets.zero, + icon: const Icon(Icons.close), + constraints: const BoxConstraints(), + onPressed: () { + stopTimer = true; + onFailure(); + }) ], ), 22.height, @@ -150,22 +150,20 @@ class OtpDialog { InputDecoration buildInputDecoration(BuildContext context) { return InputDecoration( counterText: " ", - // ts/images/password_icon.png - // contentPadding: EdgeInsets.only(top: 20, bottom: 20), - enabledBorder: OutlineInputBorder( + enabledBorder: const OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10)), borderSide: BorderSide(color: Colors.black), ), focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderRadius: const BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Theme.of(context).primaryColor), ), errorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderRadius: const BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Theme.of(context).errorColor), ), focusedErrorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderRadius: const BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Theme.of(context).errorColor), ), ); @@ -181,33 +179,27 @@ class OtpDialog { // } // } - checkValue() { - //print(verifyAccountFormValue); - // if (verifyAccountForm?.currentState!.validate()) { - // onSuccess(digit1.text.toString() + digit2.text.toString() + digit3.text.toString() + digit4.text.toString()); - // } - } - - getSecondsAsDigitalClock(int inputSeconds) { - var sec_num = int.parse(inputSeconds.toString()); // don't forget the second param - var hours = (sec_num / 3600).floor(); - var minutes = ((sec_num - hours * 3600) / 60).floor(); - var seconds = sec_num - hours * 3600 - minutes * 60; - var minutesString = ""; - var secondsString = ""; + String getSecondsAsDigitalClock(int inputSeconds) { + int secNum = int.parse(inputSeconds.toString()); // don't forget the second param + int hours = (secNum / 3600).floor(); + int minutes = ((secNum - hours * 3600) / 60).floor(); + double seconds = secNum - hours * 3600 - minutes * 60; + String minutesString = ""; + String secondsString = ""; minutesString = minutes < 10 ? "0" + minutes.toString() : minutes.toString(); - secondsString = seconds < 10 ? "0" + seconds.toString() : seconds.toString(); + secondsString = seconds < 10 ? "0" + seconds.toStringAsFixed(0) : seconds.toStringAsFixed(0); return minutesString + ":" + secondsString; } - startTimer(setState) { - this.remainingTime--; + void startTimer(setState) { + remainingTime--; + if (stopTimer) return; setState(() { - displayTime = this.getSecondsAsDigitalClock(this.remainingTime); + displayTime = getSecondsAsDigitalClock(remainingTime); }); - timer = Future.delayed(Duration(seconds: 1), () { - if (this.remainingTime > 0) { + timer = Future.delayed(const Duration(seconds: 1), () { + if (remainingTime > 0) { startTimer(setState); } else { Navigator.pop(context); @@ -219,8 +211,9 @@ class OtpDialog { Navigator.pop(context); } - _onOtpCallBack(String otpCode, bool? isAutofill) { + void _onOtpCallBack(String otpCode, bool? isAutofill) { if (otpCode.length == 4) { + stopTimer = true; onSuccess(otpCode); } } diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 9829f4c..b43f3bd 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -18,50 +18,53 @@ class CodegenLoader extends AssetLoader{ "mohemm": "Mohemm", "english": "English", "arabic": "Arabic", - "login": "Login", - "pleaseEnterLoginDetails": "Please enter the detail below to login", - "username": "Username", - "password": "Password", - "welcomeBack": "Welcome back", - "wouldYouLikeToLoginWithCurrentUsername": "Would you like to login with current Username?", - "lastLoginDetails": "Last Login Details:", - "verificationType": "Verification Type:", - "pleaseVerify": "Please Verify", - "verifyThroughFace": "Verify Through Face", - "verifyThroughFingerprint": "Verify Through Fingerprint", - "verifyThroughSMS": "Verify Through SMS", - "verifyThroughWhatsapp": "Verify Through Whatsapp", - "useAnotherAccount": "Use Another Account", - "pleaseEnterTheVerificationCodeSentTo": "Please enter the verification code sent to ", - "theVerificationCodeWillExpireIn": "The verification code will expire in ", - "goodMorning": "Good Morning", - "markAttendance": "Mark Attendance", - "timeLeftToday": "Time Left Today", - "checkIn": "Check In", - "workList": "Work List", - "leaveBalance": "Leave Balance", - "missingSwipes": "Missing Swipes", - "ticketBalance": "Ticket Balance", - "other": "Other", - "services": "Services", - "viewAllServices": "View All Services", - "monthlyAttendance": "Monthly Attendance", - "workFromHome": "Work From Home", - "ticketRequest": "Ticket Request", - "viewAllOffers": "View All Offers", - "offers": "Offers & ", - "discounts": "Discounts", - "newString": "New", - "setTheNewPassword": "Set the new password", - "typeYourNewPasswordBelow": "Type your new password below", - "confirmPassword": "Confirm Password", - "update": "Update", - "title": "Title", - "home": "Home", - "mySalary": "My Salary", - "createRequest": "Create Request", - "forgotPassword": "Forgot Password", - "itemsForSale": "Items for Sale", + "login": "تسجيل الدخول", + "pleaseEnterLoginDetails": "الرجاء إدخال التفاصيل أدناه لتسجيل الدخول", + "username": "اسم المستخدم", + "password": "كلمة المرور", + "welcomeBack": "مرحبا بعودتك", + "wouldYouLikeToLoginWithCurrentUsername": "هل ترغب في تسجيل الدخول باسم المستخدم الحالي؟", + "lastLoginDetails": "تفاصيل تسجيل الدخول الأخير:", + "verificationType": "نوع التحقق:", + "pleaseVerify": "ارجوك تحقق", + "verifyThroughFace": "تحقق من خلال الوجه", + "verifyThroughFingerprint": "تحقق من خلال بصمة الإصبع", + "verifyThroughSMS": "تحقق من خلال الرسائل القصيرة", + "verifyThroughWhatsapp": "تحقق من خلال Whatsapp", + "useAnotherAccount": "استخدم حسابا آخر", + "pleaseEnterTheVerificationCodeSentTo": "الرجاء إدخال رمز التحقق المرسل إلى ", + "theVerificationCodeWillExpireIn": "ستنتهي صلاحية رمز التحقق في ", + "goodMorning": "صباح الخير", + "markAttendance": "علامة الحضور", + "timeLeftToday": "الوقت المتبقي اليوم", + "checkIn": "تحقق في", + "workList": "قائمة العمل", + "leaveBalance": "رصيد الاجازات", + "missingSwipes": "الضربات الشديدة في عداد المفقودين", + "ticketBalance": "رصيد التذكرة", + "other": "آخر", + "services": "خدمات", + "viewAllServices": "عرض جميع الخدمات", + "monthlyAttendance": "الحضور الشهري", + "workFromHome": "العمل من المنزل", + "ticketRequest": "طلب تذكرة", + "viewAllOffers": "مشاهدة جميع العروض", + "offers": "عروض & ", + "discounts": "الخصومات", + "newString": "جديد", + "setTheNewPassword": "قم بتعيين كلمة المرور الجديدة", + "typeYourNewPasswordBelow": "اكتب كلمة المرور الجديدة أدناه", + "confirmPassword": "تأكيد كلمة المرور", + "update": "تحديث", + "title": "عنوان", + "home": "مسكن", + "mySalary": "راتبي", + "createRequest": "إنشاء طلب", + "forgotPassword": "هل نسيت كلمة السر", + "employeeId": "هوية الموظف", + "loginCodeWillSentToMobileNumber": "الرجاء إدخال معرف الموظف الخاص بك ، وسيتم إرسال رمز تسجيل الدخول إلى رقم هاتفك المحمول", + "changePassword": "تغيير كلمة المرور", + "itemsForSale": "سلع للبيع", "msg": "Hello {} in the {} world ", "msg_named": "{} are written in the {lang} language", "clickMe": "Click me", @@ -147,6 +150,9 @@ static const Map en_US = { "mySalary": "My Salary", "createRequest": "Create Request", "forgotPassword": "Forgot Password", + "employeeId": "Employee ID", + "loginCodeWillSentToMobileNumber": "Please Enter your Employee ID, A login code will be sent to your mobile number", + "changePassword": "Change Password", "itemsForSale": "Items for Sale", "msg": "Hello {} in the {} world ", "msg_named": "{} are written in the {lang} language", diff --git a/lib/main.dart b/lib/main.dart index b118397..99cff95 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,11 @@ +import 'dart:io'; + import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/config/app_provider.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/theme/app_theme.dart'; import 'package:sizer/sizer.dart'; @@ -12,7 +16,7 @@ Future main() async { await EasyLocalization.ensureInitialized(); runApp( EasyLocalization( - supportedLocales: [ + supportedLocales: const [ Locale('en', 'US'), Locale('ar', 'SA'), ], @@ -39,6 +43,9 @@ class MyApp extends StatelessWidget { return AppProvider( child: Sizer( builder: (context, orientation, deviceType) { + AppState().setPostParamsModel( + PostParamsModel(languageID: EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2, channel: 31, versionID: 3.2, mobileType: Platform.isAndroid ? "android" : "ios"), + ); return MaterialApp( theme: AppTheme.getTheme(EasyLocalization.of(context)?.locale.languageCode == "ar"), debugShowCheckedModeBanner: false, diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index ac7af0f..5bfa4fc 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -556,98 +556,98 @@ class GenericResponseModel { disableSessionList = json['DisableSessionList']; employeeQR = json['EmployeeQR']; forgetPasswordTokenID = json['ForgetPasswordTokenID']; - getAbsenceAttachmentsList = json['GetAbsenceAttachmentsList'].cast(); - getAbsenceAttendanceTypesList = json['GetAbsenceAttendanceTypesList'].cast(); - getAbsenceCollectionNotificationBodyList = json['GetAbsenceCollectionNotificationBodyList'].cast(); - getAbsenceDffStructureList = json['GetAbsenceDffStructureList'].cast(); - getAbsenceTransactionList = json['GetAbsenceTransactionList'].cast(); - getAccrualBalancesList = json['GetAccrualBalancesList'].cast(); - getActionHistoryList = json['GetActionHistoryList'].cast(); - getAddressDffStructureList = json['GetAddressDffStructureList'].cast(); - getAddressNotificationBodyList = json['GetAddressNotificationBodyList'].cast(); - getApprovesList = json['GetApprovesList'].cast(); - getAttachementList = json['GetAttachementList'].cast(); - getAttendanceTrackingList = json['GetAttendanceTrackingList'].cast(); - getBasicDetColsStructureList = json['GetBasicDetColsStructureList'].cast(); - getBasicDetDffStructureList = json['GetBasicDetDffStructureList'].cast(); - getBasicDetNtfBodyList = json['GetBasicDetNtfBodyList'].cast(); - getCEICollectionNotificationBodyList = json['GetCEICollectionNotificationBodyList'].cast(); - getCEIDFFStructureList = json['GetCEIDFFStructureList'].cast(); - getCEITransactionList = json['GetCEITransactionList'].cast(); - getCcpDffStructureList = json['GetCcpDffStructureList'].cast(); - getCcpOutputList = json['GetCcpOutputList'].cast(); - getCcpTransactionsList = json['GetCcpTransactionsList'].cast(); - getCcpTransactionsListNew = json['GetCcpTransactionsList_New'].cast(); - getConcurrentProgramsList = json['GetConcurrentProgramsList'].cast(); - getContactColsStructureList = json['GetContactColsStructureList'].cast(); - getContactDetailsList = json['GetContactDetailsList'].cast(); - getContactDffStructureList = json['GetContactDffStructureList'].cast(); - getContactNotificationBodyList = json['GetContactNotificationBodyList'].cast(); - getCountriesList = json['GetCountriesList'].cast(); - getDayHoursTypeDetailsList = json['GetDayHoursTypeDetailsList'].cast(); - getDeductionsList = json['GetDeductionsList'].cast(); - getDefaultValueList = json['GetDefaultValueList'].cast(); - getEITCollectionNotificationBodyList = json['GetEITCollectionNotificationBodyList'].cast(); - getEITDFFStructureList = json['GetEITDFFStructureList'].cast(); - getEITTransactionList = json['GetEITTransactionList'].cast(); - getEarningsList = json['GetEarningsList'].cast(); - getEmployeeAddressList = json['GetEmployeeAddressList'].cast(); - getEmployeeBasicDetailsList = json['GetEmployeeBasicDetailsList'].cast(); - getEmployeeContactsList = json['GetEmployeeContactsList'].cast(); - getEmployeePhonesList = json['GetEmployeePhonesList'].cast(); - getEmployeeSubordinatesList = json['GetEmployeeSubordinatesList'].cast(); - getFliexfieldStructureList = json['GetFliexfieldStructureList'].cast(); - getHrCollectionNotificationBodyList = json['GetHrCollectionNotificationBodyList'].cast(); - getHrTransactionList = json['GetHrTransactionList'].cast(); - getItemCreationNtfBodyList = json['GetItemCreationNtfBodyList'].cast(); - getItemTypeNotificationsList = json['GetItemTypeNotificationsList'].cast(); - getItemTypesList = json['GetItemTypesList'].cast(); - getLookupValuesList = json['GetLookupValuesList'].cast(); - getMenuEntriesList = json['GetMenuEntriesList'].cast(); - getMoItemHistoryList = json['GetMoItemHistoryList'].cast(); - getMoNotificationBodyList = json['GetMoNotificationBodyList'].cast(); - getNotificationButtonsList = json['GetNotificationButtonsList'].cast(); - getNotificationReassignModeList = json['GetNotificationReassignModeList'].cast(); - getObjectValuesList = json['GetObjectValuesList'].cast(); - getOpenMissingSwipesList = json['GetOpenMissingSwipesList'].cast(); - getOpenNotificationsList = json['GetOpenNotificationsList'].cast(); - getOpenNotificationsNumList = json['GetOpenNotificationsNumList'].cast(); - getOpenPeriodDatesList = json['GetOpenPeriodDatesList'].cast(); - getOrganizationsSalariesList = json['GetOrganizationsSalariesList'].cast(); - getPaymentInformationList = json['GetPaymentInformationList'].cast(); - getPayslipList = json['GetPayslipList'].cast(); - getPendingReqDetailsList = json['GetPendingReqDetailsList'].cast(); - getPendingReqFunctionsList = json['GetPendingReqFunctionsList'].cast(); - getPerformanceAppraisalList = json['GetPerformanceAppraisalList'].cast(); - getPhonesNotificationBodyList = json['GetPhonesNotificationBodyList'].cast(); - getPoItemHistoryList = json['GetPoItemHistoryList'].cast(); - getPoNotificationBodyList = json['GetPoNotificationBodyList'].cast(); - getPrNotificationBodyList = json['GetPrNotificationBodyList'].cast(); - getQuotationAnalysisList = json['GetQuotationAnalysisList'].cast(); - getRFCEmployeeListList = json['GetRFCEmployeeListList'].cast(); - getRespondAttributeValueList = json['GetRespondAttributeValueList'].cast(); - getSITCollectionNotificationBodyList = json['GetSITCollectionNotificationBodyList'].cast(); - getSITDFFStructureList = json['GetSITDFFStructureList'].cast(); - getSITTransactionList = json['GetSITTransactionList'].cast(); - getScheduleShiftsDetailsList = json['GetScheduleShiftsDetailsList'].cast(); - getShiftTypesList = json['GetShiftTypesList'].cast(); - getStampMsNotificationBodyList = json['GetStampMsNotificationBodyList'].cast(); - getStampNsNotificationBodyList = json['GetStampNsNotificationBodyList'].cast(); - getSubordinatesAttdStatusList = json['GetSubordinatesAttdStatusList'].cast(); - getSubordinatesLeavesList = json['GetSubordinatesLeavesList'].cast(); - getSubordinatesLeavesTotalVacationsList = json['GetSubordinatesLeavesTotalVacationsList'].cast(); - getSummaryOfPaymentList = json['GetSummaryOfPaymentList'].cast(); - getSwipesList = json['GetSwipesList'].cast(); - getTermColsStructureList = json['GetTermColsStructureList'].cast(); - getTermDffStructureList = json['GetTermDffStructureList'].cast(); - getTermNotificationBodyList = json['GetTermNotificationBodyList'].cast(); - getTimeCardSummaryList = json['GetTimeCardSummaryList'].cast(); - getUserItemTypesList = json['GetUserItemTypesList'].cast(); - getVacationRulesList = json['GetVacationRulesList'].cast(); - getVaccinationOnHandList = json['GetVaccinationOnHandList'].cast(); - getVaccinationsList = json['GetVaccinationsList'].cast(); - getValueSetValuesList = json['GetValueSetValuesList'].cast(); - getWorkList = json['GetWorkList'].cast(); + getAbsenceAttachmentsList = json['GetAbsenceAttachmentsList']; + getAbsenceAttendanceTypesList = json['GetAbsenceAttendanceTypesList']; + getAbsenceCollectionNotificationBodyList = json['GetAbsenceCollectionNotificationBodyList']; + getAbsenceDffStructureList = json['GetAbsenceDffStructureList']; + getAbsenceTransactionList = json['GetAbsenceTransactionList']; + getAccrualBalancesList = json['GetAccrualBalancesList']; + getActionHistoryList = json['GetActionHistoryList']; + getAddressDffStructureList = json['GetAddressDffStructureList']; + getAddressNotificationBodyList = json['GetAddressNotificationBodyList']; + getApprovesList = json['GetApprovesList']; + getAttachementList = json['GetAttachementList']; + getAttendanceTrackingList = json['GetAttendanceTrackingList']; + getBasicDetColsStructureList = json['GetBasicDetColsStructureList']; + getBasicDetDffStructureList = json['GetBasicDetDffStructureList']; + getBasicDetNtfBodyList = json['GetBasicDetNtfBodyList']; + getCEICollectionNotificationBodyList = json['GetCEICollectionNotificationBodyList']; + getCEIDFFStructureList = json['GetCEIDFFStructureList']; + getCEITransactionList = json['GetCEITransactionList']; + getCcpDffStructureList = json['GetCcpDffStructureList']; + getCcpOutputList = json['GetCcpOutputList']; + getCcpTransactionsList = json['GetCcpTransactionsList']; + getCcpTransactionsListNew = json['GetCcpTransactionsList_New']; + getConcurrentProgramsList = json['GetConcurrentProgramsList']; + getContactColsStructureList = json['GetContactColsStructureList']; + getContactDetailsList = json['GetContactDetailsList']; + getContactDffStructureList = json['GetContactDffStructureList']; + getContactNotificationBodyList = json['GetContactNotificationBodyList']; + getCountriesList = json['GetCountriesList']; + getDayHoursTypeDetailsList = json['GetDayHoursTypeDetailsList']; + getDeductionsList = json['GetDeductionsList']; + getDefaultValueList = json['GetDefaultValueList']; + getEITCollectionNotificationBodyList = json['GetEITCollectionNotificationBodyList']; + getEITDFFStructureList = json['GetEITDFFStructureList']; + getEITTransactionList = json['GetEITTransactionList']; + getEarningsList = json['GetEarningsList']; + getEmployeeAddressList = json['GetEmployeeAddressList']; + getEmployeeBasicDetailsList = json['GetEmployeeBasicDetailsList']; + getEmployeeContactsList = json['GetEmployeeContactsList']; + getEmployeePhonesList = json['GetEmployeePhonesList']; + getEmployeeSubordinatesList = json['GetEmployeeSubordinatesList']; + getFliexfieldStructureList = json['GetFliexfieldStructureList']; + getHrCollectionNotificationBodyList = json['GetHrCollectionNotificationBodyList']; + getHrTransactionList = json['GetHrTransactionList']; + getItemCreationNtfBodyList = json['GetItemCreationNtfBodyList']; + getItemTypeNotificationsList = json['GetItemTypeNotificationsList']; + getItemTypesList = json['GetItemTypesList']; + getLookupValuesList = json['GetLookupValuesList']; + getMenuEntriesList = json['GetMenuEntriesList']; + getMoItemHistoryList = json['GetMoItemHistoryList']; + getMoNotificationBodyList = json['GetMoNotificationBodyList']; + getNotificationButtonsList = json['GetNotificationButtonsList']; + getNotificationReassignModeList = json['GetNotificationReassignModeList']; + getObjectValuesList = json['GetObjectValuesList']; + getOpenMissingSwipesList = json['GetOpenMissingSwipesList']; + getOpenNotificationsList = json['GetOpenNotificationsList']; + getOpenNotificationsNumList = json['GetOpenNotificationsNumList']; + getOpenPeriodDatesList = json['GetOpenPeriodDatesList']; + getOrganizationsSalariesList = json['GetOrganizationsSalariesList']; + getPaymentInformationList = json['GetPaymentInformationList']; + getPayslipList = json['GetPayslipList']; + getPendingReqDetailsList = json['GetPendingReqDetailsList']; + getPendingReqFunctionsList = json['GetPendingReqFunctionsList']; + getPerformanceAppraisalList = json['GetPerformanceAppraisalList']; + getPhonesNotificationBodyList = json['GetPhonesNotificationBodyList']; + getPoItemHistoryList = json['GetPoItemHistoryList']; + getPoNotificationBodyList = json['GetPoNotificationBodyList']; + getPrNotificationBodyList = json['GetPrNotificationBodyList']; + getQuotationAnalysisList = json['GetQuotationAnalysisList']; + getRFCEmployeeListList = json['GetRFCEmployeeListList']; + getRespondAttributeValueList = json['GetRespondAttributeValueList']; + getSITCollectionNotificationBodyList = json['GetSITCollectionNotificationBodyList']; + getSITDFFStructureList = json['GetSITDFFStructureList']; + getSITTransactionList = json['GetSITTransactionList']; + getScheduleShiftsDetailsList = json['GetScheduleShiftsDetailsList']; + getShiftTypesList = json['GetShiftTypesList']; + getStampMsNotificationBodyList = json['GetStampMsNotificationBodyList']; + getStampNsNotificationBodyList = json['GetStampNsNotificationBodyList']; + getSubordinatesAttdStatusList = json['GetSubordinatesAttdStatusList']; + getSubordinatesLeavesList = json['GetSubordinatesLeavesList']; + getSubordinatesLeavesTotalVacationsList = json['GetSubordinatesLeavesTotalVacationsList']; + getSummaryOfPaymentList = json['GetSummaryOfPaymentList']; + getSwipesList = json['GetSwipesList']; + getTermColsStructureList = json['GetTermColsStructureList']; + getTermDffStructureList = json['GetTermDffStructureList']; + getTermNotificationBodyList = json['GetTermNotificationBodyList']; + getTimeCardSummaryList = json['GetTimeCardSummaryList']; + getUserItemTypesList = json['GetUserItemTypesList']; + getVacationRulesList = json['GetVacationRulesList']; + getVaccinationOnHandList = json['GetVaccinationOnHandList']; + getVaccinationsList = json['GetVaccinationsList']; + getValueSetValuesList = json['GetValueSetValuesList']; + getWorkList = json['GetWorkList']; hRCertificateTemplate = json['HRCertificateTemplate']; imgURLsList = json['ImgURLsList']; insertApInv = json['InsertApInv']; diff --git a/lib/models/post_params_model.dart b/lib/models/post_params_model.dart new file mode 100644 index 0000000..cd6dd72 --- /dev/null +++ b/lib/models/post_params_model.dart @@ -0,0 +1,34 @@ +class PostParamsModel { + double? versionID; + int? channel; + int? languageID; + String? mobileType; + String? logInTokenID; + String? tokenID; + + PostParamsModel({this.versionID, this.channel, this.languageID, this.mobileType, this.logInTokenID, this.tokenID}); + + PostParamsModel.fromJson(Map json) { + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + mobileType = json['MobileType']; + logInTokenID = json['LogInTokenID']; + tokenID = json['TokenID']; + } + + Map toJson() { + final Map data = new Map(); + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['MobileType'] = this.mobileType; + data['LogInTokenID'] = this.logInTokenID; + data['TokenID'] = this.tokenID; + return data; + } + + set setLogInTokenID(String? token) => logInTokenID = token; + + set setTokenID(String? token) => tokenID = token; +} diff --git a/lib/ui/login/forgot_password_screen.dart b/lib/ui/login/forgot_password_screen.dart new file mode 100644 index 0000000..89bd66e --- /dev/null +++ b/lib/ui/login/forgot_password_screen.dart @@ -0,0 +1,114 @@ +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/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/widgets/button/default_button.dart'; +import 'package:mohem_flutter_app/widgets/input_widget.dart'; + +class ForgotPasswordScreen extends StatefulWidget { + ForgotPasswordScreen({Key? key}) : super(key: key); + + @override + _ForgotPasswordScreenState createState() { + return _ForgotPasswordScreenState(); + } +} + +class _ForgotPasswordScreenState extends State { + TextEditingController employeeId = TextEditingController(); + BasicMemberInformationModel? _basicMemberInformation; + GenericResponseModel? genericResponseModel; + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void performLogin() async { + // Utils.showLoading(context); + try { + _basicMemberInformation = await LoginApiClient().getBasicUserInformation("CS", employeeId.text); + genericResponseModel = await LoginApiClient().sendPublicActivationCode(_basicMemberInformation?.pMOBILENUMBER, employeeId.text); + OtpDialog( + context, + 1, + int.tryParse(_basicMemberInformation?.pMOBILENUMBER ?? ""), + (value) async { + GenericResponseModel? genericResponseModel = await LoginApiClient().checkPublicActivationCode(value, employeeId.text); + if (genericResponseModel?.errorMessage != null) { + Utils.showToast(genericResponseModel?.errorMessage ?? ""); + return; + } + + Navigator.pushNamed(context, AppRoutes.newPassword); + // this.checkActivationCode(value: value); + }, + () => { + Navigator.pop(context), + }, + ).displayDialog(context); + } catch (ex) { + print(ex); + Utils.handleException(ex, null); + // Utils.hideLoading(context); + } + } + + @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: [ + //const SizedBox(height: 23), + Expanded( + child: Padding( + padding: const EdgeInsets.all(21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + LocaleKeys.forgotPassword.tr().toText24(isBold: true), + LocaleKeys.loginCodeWillSentToMobileNumber.tr().toText16(), + 16.height, + InputWidget(LocaleKeys.employeeId.tr(), "123456", employeeId), + ], + ), + ) + ], + ), + ), + ), + DefaultButton(LocaleKeys.changePassword.tr(), () async { + //Navigator.pushNamed(context, AppRoutes.verifyLogin); + }) + .insideContainer + ], + ), + ); + } +} diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index f7f8e05..1db57f1 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -2,12 +2,18 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:mohem_flutter_app/api/login_api_client.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'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/check_mobile_app_version_model.dart'; +import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/input_widget.dart'; @@ -24,6 +30,9 @@ class _LoginScreenState extends State { TextEditingController username = TextEditingController(); TextEditingController password = TextEditingController(); + CheckMobileAppVersionModel? _checkMobileAppVersion; + MemberLoginListModel? _memberLoginList; + @override void initState() { super.initState(); @@ -34,6 +43,23 @@ class _LoginScreenState extends State { super.dispose(); } + void performLogin() async { + // Utils.showLoading(context); + try { + _checkMobileAppVersion = await LoginApiClient().checkMobileAppVersion(); + _memberLoginList = await LoginApiClient().memberLogin(username.text, password.text); + AppState().setMemberLoginListModel = _memberLoginList; + AppState().username = username.text; + print(_memberLoginList?.toJson()); + // Utils.hideLoading(context); + Navigator.pushNamed(context, AppRoutes.verifyLogin); + } catch (ex) { + print(ex); + Utils.handleException(ex, null); + // Utils.hideLoading(context); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -51,14 +77,18 @@ class _LoginScreenState extends State { Expanded(child: SizedBox()), Row( children: [ - LocaleKeys.english.tr().toText14(color: MyColors.textMixColor).onPress(() {}), + LocaleKeys.english.tr().toText14(color: MyColors.textMixColor).onPress(() { + context.setLocale(const Locale("en", "US")); + }), Container( width: 1, color: MyColors.darkWhiteColor, height: 16, margin: const EdgeInsets.only(left: 10, right: 10), ), - LocaleKeys.arabic.tr().toText14().onPress(() {}), + LocaleKeys.arabic.tr().toText14().onPress(() { + context.setLocale(const Locale("ar", "SA")); + }), ], ), ], @@ -79,7 +109,7 @@ class _LoginScreenState extends State { Align( alignment: Alignment.centerRight, child: LocaleKeys.forgotPassword.tr().toText12(isUnderLine: true, color: MyColors.textMixColor).onPress(() { - Navigator.pushNamed(context, AppRoutes.newPassword); + Navigator.pushNamed(context, AppRoutes.forgotPassword); }), ), ], @@ -92,7 +122,8 @@ class _LoginScreenState extends State { DefaultButton(LocaleKeys.login.tr(), () async { // context.setLocale(const Locale("en", "US")); // to change Loacle - Navigator.pushNamed(context, AppRoutes.verifyLogin); + SystemChannels.textInput.invokeMethod('TextInput.hide'); + performLogin(); }).insideContainer ], ), diff --git a/lib/ui/login/new_password_screen.dart b/lib/ui/login/new_password_screen.dart index 5774298..3fc37f1 100644 --- a/lib/ui/login/new_password_screen.dart +++ b/lib/ui/login/new_password_screen.dart @@ -88,9 +88,8 @@ class _NewPasswordScreenState extends State { ), ), DefaultButton(LocaleKeys.update.tr(), () async { - // context.setLocale(const Locale("en", "US")); // to change Loacle - Navigator.pushNamed(context, AppRoutes.verifyLogin); + // Navigator.pushNamed(context, AppRoutes.verifyLogin); }).insideContainer ], ), diff --git a/lib/ui/login/verify_login_screen.dart b/lib/ui/login/verify_login_screen.dart index 54be916..26b978f 100644 --- a/lib/ui/login/verify_login_screen.dart +++ b/lib/ui/login/verify_login_screen.dart @@ -3,13 +3,18 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; import 'package:local_auth/local_auth.dart'; +import 'package:mohem_flutter_app/api/login_api_client.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/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/extensions/widget_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/widgets/button/default_button.dart'; class VerifyLoginScreen extends StatefulWidget { @@ -613,19 +618,26 @@ class _VerifyLoginScreenState extends State { return InkWell( onTap: isDisable ? null - : () { + : () async { if (_flag == 0) { setState(() { // isMoreOption = true; }); } else { + BasicMemberInformationModel? memberInformationModel = await LoginApiClient() + .mohemmSendActivationCodeByOTPNotificationType(checkBiometricIsAvailable(BiometricType.fingerprint) ? 1 : 0, AppState().memberLoginList?.pMOBILENUMBER, _flag, AppState().username); OtpDialog( context, _flag, - //this.mobileNumber - 0554870506, - (value) { - Navigator.pushReplacementNamed(context, AppRoutes.dashboard); + int.tryParse(AppState().memberLoginList?.pMOBILENUMBER ?? ""), + (value) async { + GenericResponseModel? genericResponseModel = await LoginApiClient().checkActivationCode(false, AppState().memberLoginList?.pMOBILENUMBER, value, AppState().username); + if (genericResponseModel?.errorMessage != null) { + Utils.showToast(genericResponseModel?.errorMessage ?? ""); + // Navigator.pop(context); + } + + Navigator.pushNamedAndRemoveUntil(context, AppRoutes.dashboard, (Route route) => false); // this.checkActivationCode(value: value); }, () => {