diff --git a/assets/images/svg/card_user.svg b/assets/images/svg/card_user.svg new file mode 100644 index 00000000..ee8bb0e2 --- /dev/null +++ b/assets/images/svg/card_user.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/images/svg/fingerprint.svg b/assets/images/svg/fingerprint.svg new file mode 100644 index 00000000..e189bc69 --- /dev/null +++ b/assets/images/svg/fingerprint.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/images/svg/globe_black.svg b/assets/images/svg/globe_black.svg new file mode 100644 index 00000000..a11766cb --- /dev/null +++ b/assets/images/svg/globe_black.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/images/svg/sms.svg b/assets/images/svg/sms.svg new file mode 100644 index 00000000..4237c0d1 --- /dev/null +++ b/assets/images/svg/sms.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart b/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart index a45b0f89..df68b778 100644 --- a/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart +++ b/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart @@ -18,7 +18,15 @@ class GenericBottomSheet extends StatefulWidget { final bool isFromSavedLogin; GenericBottomSheet( - {Key? key, this.countryCode = "", this.initialPhoneNumber = "", required this.buttons, this.textController, this.isForEmail = false, this.onCountryChange, this.isEnableCountryDropdown = false, this.isFromSavedLogin = false}) + {Key? key, + this.countryCode = "", + this.initialPhoneNumber = "", + required this.buttons, + this.textController, + this.isForEmail = false, + this.onCountryChange, + this.isEnableCountryDropdown = false, + this.isFromSavedLogin = false}) : super(key: key); @override @@ -26,12 +34,25 @@ class GenericBottomSheet extends StatefulWidget { } class _GenericBottomSheetState extends State { + FocusNode node = FocusNode(); + @override void initState() { super.initState(); if (!widget.isForEmail) { widget.textController = TextEditingController(text: widget.initialPhoneNumber); } + + WidgetsBinding.instance.addPostFrameCallback((_) { + print("GenericBottomSheet initState called"); + FocusScope.of(context).requestFocus(node); + // if (widget.textController != null) { + // + // widget.textController!.selection = TextSelection.fromPosition( + // TextPosition(offset: widget.textController!.text.length), + // ); + // } + }); } @override @@ -83,12 +104,13 @@ class _GenericBottomSheetState extends State { widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx", widget.textController!, padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), - keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number, onChange: (value) { widget.textController!.text = value!; }, isEnable: true, + focusNode: node, + autoFocus: true, isReadOnly: widget.isFromSavedLogin, prefix: widget.isForEmail ? null : widget.countryCode, hasSelection: false, @@ -96,7 +118,6 @@ class _GenericBottomSheetState extends State { isAllowLeadingIcon: true, countryList: Country.values, isCountryDropDown: widget.isEnableCountryDropdown, - // selectedCountry: widget, onCountryChange: (Country country) { widget.onCountryChange!(country); }, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart index 8157e5e7..4ddcafaf 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart @@ -590,7 +590,8 @@ Widget newInputWidget( String lang = 'en', bool isCountryDropDown = false, List countryList = const [], - // Country? selectedCountry, + FocusNode? focusNode, + bool autoFocus = false, Function(Country)? onCountryChange, }) { return Builder( @@ -768,6 +769,8 @@ Widget newInputWidget( textAlign: isRtl ? TextAlign.right : TextAlign.left, textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, onChanged: onChange, + focusNode: focusNode, + autofocus: autoFocus, style: context.dynamicTextStyle( fontSize: 14, height: 21 / 14, diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 979ceab2..a64bb5ec 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -398,7 +398,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { ); } else { GifLoaderDialogUtils.hideDialog(context); - Navigator.of(context).pushReplacement( + Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) => WelcomeLogin(), ), @@ -747,13 +747,16 @@ class _LandingPageState extends State with WidgetsBindingObserver { context: context, backgroundColor: Colors.transparent, isScrollControlled: true, - builder: (context) => Padding( - padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), - child: QuickLoginBottomSheet( - isDone:isDone, - onPressed: (){ - loginWithFingerPrintFace(3, 1, user, deviceToken); - },), + useSafeArea: true, + builder: (context) => SafeArea( + child: Padding( + padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + child: QuickLoginBottomSheet( + isDone:isDone, + onPressed: (){ + loginWithFingerPrintFace(3, 1, user, deviceToken); + },), + ), ), ); } diff --git a/lib/pages/login/register_new.dart b/lib/pages/login/register_new.dart index b00e521e..20c62ad6 100644 --- a/lib/pages/login/register_new.dart +++ b/lib/pages/login/register_new.dart @@ -242,11 +242,11 @@ class _RegisterNew extends State { ), child: isTermsAccepted ? const Icon(Icons.check, size: 16, color: Colors.white) : null, ), - const SizedBox(width: 12), + SizedBox(width: 12), Expanded( child: Text( TranslationBase.of(context).iAcceptTermsConditions, - style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFF2E3039)), + style: context.dynamicTextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Color(0xFF2E3039)), ), ), ], @@ -614,7 +614,7 @@ class _RegisterNew extends State { checkActivationCode({value, type}) async { // Navigator.pop(context); - GifLoaderDialogUtils.showMyDialog(context); + // GifLoaderDialogUtils.showMyDialog(context); var request = authService.getCommonRequest( registerd_data: null, deviceToken: DEVICE_TOKEN, @@ -679,17 +679,35 @@ class _RegisterNew extends State { }); } + // startSMSService(type) { + // SMSOTP( + // context, + // type, + // phoneController.text, + // (value) { + // this.checkActivationCode(value: value, type: type); + // }, + // () => { + // Navigator.pop(context), + // }, + // ).displayDialog(context); + // } + startSMSService(type) { - SMSOTP( + late SMSOTP smsOtp; // Declare the variable first + smsOtp = SMSOTP( context, type, phoneController.text, - (value) { - this.checkActivationCode(value: value, type: type); + (code) { + smsOtp.dispose(); // Now we can reference it + this.checkActivationCode(value: code, type: type); }, - () => { - Navigator.pop(context), + () { + smsOtp.dispose(); // Now we can reference it + Navigator.pop(context); }, - ).displayDialog(context); + ); + smsOtp.displayDialog(context); } } diff --git a/lib/pages/login/saved_login.dart b/lib/pages/login/saved_login.dart index 03a81c3c..d63ca405 100644 --- a/lib/pages/login/saved_login.dart +++ b/lib/pages/login/saved_login.dart @@ -76,10 +76,11 @@ class _SavedLogin extends State { dropDownList: [], resizeToAvoidBottomInset: true, showCenteredLogo: true, + showLastLoginScreenBar: true, dropDownIndexChange: (value) { Utils.changeAppLanguage(context: context); }, - // backgroundColor: const Color(0xFFF8F8FA), + // backgroundColor: const Color(0xFFF8F8FA), body: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0), @@ -141,7 +142,7 @@ class _SavedLogin extends State { // Last login info Text( TranslationBase.of(context).lastloginBy + ' ${getType(widget.savedLoginData.logInType!, context)}', - style: const TextStyle( + style: context.dynamicTextStyle( fontSize: 16, color: Color(0xFF8F9AA3), fontWeight: FontWeight.w600, @@ -149,7 +150,7 @@ class _SavedLogin extends State { ), Text( widget.savedLoginData.createdOn != null ? DateUtil.getFormattedDate(DateUtil.convertStringToDate(widget.savedLoginData.createdOn!), "d MMMM, y 'at' HH:mm") : '--', - style: const TextStyle( + style: context.dynamicTextStyle( fontSize: 16, color: Color(0xFF2E3039), fontWeight: FontWeight.w600, @@ -165,24 +166,27 @@ class _SavedLogin extends State { ), ), // Face ID login button - CustomButton( - text: "${TranslationBase.of(context).loginBy} ${getType(widget.savedLoginData.logInType!, context)}", - onPressed: () { - if (widget.savedLoginData.logInType! == 2 || widget.savedLoginData.logInType! == 3) { - loginWithFingerPrintFace(widget.savedLoginData.logInType!, widget.savedLoginData.iMEI!); - } else { - int? val = widget.savedLoginData.logInType!; - checkUserAuthentication(val); - } - }, - backgroundColor: Color(0xffFEE9EA), - borderColor: Color(0xffFEE9EA), - textColor: Color(0xffED1C2B), - fontSize: 12, - fontWeight: FontWeight.w500, - borderRadius: 12, - padding: EdgeInsets.fromLTRB(0, 10, 0, 10), - // icon: "assets/images/svg/apple-finder.svg", + Container( + height: 45, + child: CustomButton( + text: "${TranslationBase.of(context).loginBy} ${getType(widget.savedLoginData.logInType!, context)}", + onPressed: () { + if (widget.savedLoginData.logInType! == 2 || widget.savedLoginData.logInType! == 3) { + loginWithFingerPrintFace(widget.savedLoginData.logInType!, widget.savedLoginData.iMEI!); + } else { + int? val = widget.savedLoginData.logInType!; + checkUserAuthentication(val); + } + }, + backgroundColor: Color(0xffFEE9EA), + borderColor: Color(0xffFEE9EA), + textColor: Color(0xffED1C2B), + fontSize: 12, + fontWeight: FontWeight.w500, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(0, 10, 0, 10), + // icon: "assets/images/svg/apple-finder.svg", + ), ), ], ), @@ -227,7 +231,9 @@ class _SavedLogin extends State { text: TranslationBase.of(context).sendOTPSMS, onPressed: () { int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneController); - if (val != null) checkUserAuthentication(val); + if (val != null) { + checkUserAuthentication(val); + } }, backgroundColor: CustomColors.bgRedColor, borderColor: CustomColors.bgRedBorderColor, @@ -248,7 +254,6 @@ class _SavedLogin extends State { color: Color(0xFF2E3039), fontWeight: FontWeight.w500, ), - ), ), ], @@ -259,7 +264,10 @@ class _SavedLogin extends State { text: TranslationBase.of(context).sendOTPWHATSAPP, onPressed: () { int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneController); - if (val != null) checkUserAuthentication(val); + if (val != null) { + GifLoaderDialogUtils.showMyDialog(context); + checkUserAuthentication(val); + } }, backgroundColor: Colors.white, borderColor: Color(0xFF2E3039), @@ -567,8 +575,8 @@ class _SavedLogin extends State { }); } - checkUserAuthentication(type) { - GifLoaderDialogUtils.showMyDialog(context); + checkUserAuthentication(type) async { + await GifLoaderDialogUtils.showMyDialog(context); var req = this.authService.getCommonRequest( type: type, registerd_data: null, @@ -631,7 +639,7 @@ class _SavedLogin extends State { user: widget.savedLoginData, ); request.sMSSignature = await SMSOTP.getSignature(); - GifLoaderDialogUtils.showMyDialog(context); + // GifLoaderDialogUtils.showMyDialog(context); request.dob = ""; request.healthId = ""; request.isHijri = 0; @@ -648,19 +656,40 @@ class _SavedLogin extends State { var tempType; + // + // startSMSService(type, String loginToken) { + // tempType = type; + // SMSOTP( + // context, + // type, + // phoneController.text, + // (value) { + // this.checkActivationCode(value, type, loginToken); + // }, + // () => { + // Navigator.pop(context), + // }, + // ).displayDialog(context); + // } + startSMSService(type, String loginToken) { tempType = type; - SMSOTP( + late SMSOTP smsOtp; // Declare the variable first + + smsOtp = SMSOTP( context, type, phoneController.text, - (value) { - this.checkActivationCode(value, type, loginToken); + (code) { + smsOtp.dispose(); // Now we can reference it + this.checkActivationCode(code, type, loginToken); }, - () => { - Navigator.pop(context), + () { + smsOtp.dispose(); // Now we can reference it + Navigator.pop(context); }, - ).displayDialog(context); + ); + smsOtp.displayDialog(context); } void checkIfIsInPatient() { diff --git a/lib/pages/login/welcome.dart b/lib/pages/login/welcome.dart index ef448004..609f7426 100644 --- a/lib/pages/login/welcome.dart +++ b/lib/pages/login/welcome.dart @@ -79,7 +79,6 @@ class _WelcomeLogin extends State { bool onlySMSBox = false; var userData; - int fingrePrintBefore = 0; var dob; @@ -100,7 +99,7 @@ class _WelcomeLogin extends State { appBarTitle: TranslationBase.of(context).welcome, isShowDecPage: false, isShowAppBar: true, - isshowBackButton: false, + isshowBackButton: true, showNewAppBar: true, backgroundColor: Color(0xffF8F8F8), showNewAppBarTitle: false, @@ -173,13 +172,9 @@ class _WelcomeLogin extends State { SizedBox(height: 16), CustomButton( text: TranslationBase.of(context).login, - // fontFamily: FontUtils.getFontFamily(context), - // padding: EdgeInsets.all(10), - // padding: , icon: "assets/images/svg/login1.svg", onPressed: () { - // bool isValid = Utils.validateIqama(nationIdController.text); - if (true) { + if (nationIdController.text.isNotEmpty) { showModalBottomSheet( context: context, isScrollControlled: true, @@ -250,10 +245,9 @@ class _WelcomeLogin extends State { ); }), ); + } else { + Utils.showErrorToast("Please enter National id or File no", context); } - // } else { - // Utils.showErrorToast(TranslationBase.of(context).validIQama, context); - // } }, ), SizedBox(height: 14), @@ -261,7 +255,6 @@ class _WelcomeLogin extends State { child: RichText( textAlign: TextAlign.center, text: TextSpan( - style: context.dynamicTextStyle( color: Colors.black, fontSize: 16, @@ -310,7 +303,7 @@ class _WelcomeLogin extends State { authService .checkPatientAuthentication(request) .then((value) => { - GifLoaderDialogUtils.hideDialog(context), + // GifLoaderDialogUtils.hideDialog(context), if (value['isSMSSent']) { sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']), @@ -335,7 +328,7 @@ class _WelcomeLogin extends State { var request = this.getCommonRequest(type: type); request.sMSSignature = await SMSOTP.getSignature(); selectedOption = type; - GifLoaderDialogUtils.showMyDialog(context); + // GifLoaderDialogUtils.showMyDialog(context); if (healthId != null || isDubai) { if (!isDubai) { request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); @@ -343,7 +336,7 @@ class _WelcomeLogin extends State { request.healthId = healthId; request.isHijri = isHijri; await this.authService.sendActivationCodeRegister(request).then((result) { - GifLoaderDialogUtils.hideDialog(context); + // GifLoaderDialogUtils.hideDialog(context); if (result != null && result['isSMSSent'] == true) { this.startSMSService(type); } @@ -483,27 +476,32 @@ class _WelcomeLogin extends State { startSMSService(type) { tempType = type; - SMSOTP( + late SMSOTP smsOtp; // Declare the variable first + + smsOtp = SMSOTP( context, type, phoneController.text, - (value) { - this.checkActivationCode(value: value); + (code) { + smsOtp.dispose(); // Now we can reference it + this.checkActivationCode(value: code); }, - () => { - Navigator.pop(context), + () { + smsOtp.dispose(); // Now we can reference it + Navigator.pop(context); }, - ).displayDialog(context); + ); + smsOtp.displayDialog(context); } - showLoader(bool isTrue) { - setState(() { - isLoading = isTrue; - }); - } + // showLoader(bool isTrue) { + // setState(() { + // isLoading = isTrue; + // }); + // } setDefault() async { - showLoader(true); + // showLoader(true); if (await sharedPref.getObject(IMEI_USER_DATA) != null) user = SelectDeviceIMEIRES.fromJson(await sharedPref.getObject(IMEI_USER_DATA)); if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) { @@ -548,7 +546,11 @@ class _WelcomeLogin extends State { } getCommonRequest({type}) { - var fileNo = false; + bool fileNo = false; + if (nationIdController.text != null && nationIdController.text.isNotEmpty) { + fileNo = nationIdController.text.length < 10; + } + var request = SendActivationRequest(); request.patientMobileNumber = int.parse(phoneController.text); request.mobileNo = '0' + phoneController.text.toString(); @@ -567,14 +569,16 @@ class _WelcomeLogin extends State { request.dob = this.registerd_data.dob; request.isRegister = this.registerd_data.isRegister; } else { - request.searchType = request.searchType != null ? request.searchType : 1; + // request.searchType = request.searchType != null ? request.searchType : 1; if (fileNo) { - request.patientID = this.user!.patientID != null ? this.user!.patientID : 0; + request.patientID = this.user != null && this.user!.patientID != null ? this.user!.patientID : int.parse(nationIdController.text); + request.patientIdentificationID = request.nationalID = ""; + request.searchType = 2; } else { request.patientID = 0; + request.searchType = 1; + request.patientIdentificationID = request.nationalID = nationIdController != null ? nationIdController.text : '0'; } - request.nationalID = nationIdController != null ? nationIdController.text : '0'; - request.patientIdentificationID = nationIdController != null ? nationIdController.text : '0'; request.isRegister = false; } request.deviceTypeID = request.searchType; diff --git a/lib/pages/rateAppointment/rate_appointment_doctor.dart b/lib/pages/rateAppointment/rate_appointment_doctor.dart index c396fd4d..f9fcd6f0 100644 --- a/lib/pages/rateAppointment/rate_appointment_doctor.dart +++ b/lib/pages/rateAppointment/rate_appointment_doctor.dart @@ -38,212 +38,215 @@ class _RateAppointmentDoctorState extends State { Widget build(BuildContext context) { projectViewModel = Provider.of(context); return BaseView( - builder: (_, model, w) => AppScaffold( - isShowAppBar: true, - showNewAppBar: true, - showNewAppBarTitle: true, - baseViewModel: model, - appBarTitle: TranslationBase.of(context).rateDoctor, - body: SingleChildScrollView( - child: Container( - padding: EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).lastVisit, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.64, - height: 23 / 16), - ), - SizedBox( - height: 25, - ), - Container( - child: DoctorView( - doctor: getDoctorObject(model), - isLiveCareAppointment: false, - isShowFlag: false, + builder: (_, model, w) => SafeArea( + top: false, + child: AppScaffold( + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + baseViewModel: model, + appBarTitle: TranslationBase.of(context).rateDoctor, + body: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).lastVisit, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.64, + height: 23 / 16), ), - ), - SizedBox( - height: 12, - ), - Container( - width: double.infinity, - child: Container( - decoration: cardRadius(10), - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).tapTitle, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.64, - height: 23 / 16), - ), - SizedBox( - height: 12, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ...List.generate( - 5, - (index) => AnimatedSwitcher( - duration: Duration(milliseconds: 1000), - switchInCurve: Curves.elasticOut, - switchOutCurve: Curves.elasticIn, - transitionBuilder: (Widget child, - Animation animation) { - return ScaleTransition( - child: child, scale: animation); - }, - child: Container( - key: ValueKey(rating), - child: IconButton( - iconSize: 45.0, - onPressed: () { - setState(() { - rating = index + 1; - }); - }, - color: rating >= (index + 1) - ? Color.fromRGBO(255, 186, 0, 1.0) - : Colors.grey[400], - icon: Icon(rating >= (index + 1) - ? Icons.star - : Icons.star)), - ), - ), - ) - ], - ), - ], - ), + SizedBox( + height: 25, + ), + Container( + child: DoctorView( + doctor: getDoctorObject(model), + isLiveCareAppointment: false, + isShowFlag: false, ), ), - ), - SizedBox( - height: 12, - ), - Container( - decoration: cardRadius(10), - child: Padding( - padding: EdgeInsets.all(8.0), - child: TextField( - maxLines: 5, - decoration: InputDecoration.collapsed( - hintText: TranslationBase.of(context).notes, - hintStyle: TextStyle( + SizedBox( + height: 12, + ), + Container( + width: double.infinity, + child: Container( + decoration: cardRadius(10), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).tapTitle, + style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, - height: 23 / 16)), - onChanged: (value) { - setState(() { - note = value; - }); - }, - ))), - ], + height: 23 / 16), + ), + SizedBox( + height: 12, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ...List.generate( + 5, + (index) => AnimatedSwitcher( + duration: Duration(milliseconds: 1000), + switchInCurve: Curves.elasticOut, + switchOutCurve: Curves.elasticIn, + transitionBuilder: (Widget child, + Animation animation) { + return ScaleTransition( + child: child, scale: animation); + }, + child: Container( + key: ValueKey(rating), + child: IconButton( + iconSize: 45.0, + onPressed: () { + setState(() { + rating = index + 1; + }); + }, + color: rating >= (index + 1) + ? Color.fromRGBO(255, 186, 0, 1.0) + : Colors.grey[400], + icon: Icon(rating >= (index + 1) + ? Icons.star + : Icons.star)), + ), + ), + ) + ], + ), + ], + ), + ), + ), + ), + SizedBox( + height: 12, + ), + Container( + decoration: cardRadius(10), + child: Padding( + padding: EdgeInsets.all(8.0), + child: TextField( + maxLines: 5, + decoration: InputDecoration.collapsed( + hintText: TranslationBase.of(context).notes, + hintStyle: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.64, + height: 23 / 16)), + onChanged: (value) { + setState(() { + note = value; + }); + }, + ))), + ], + ), ), ), - ), - bottomSheet: Container( - color: Colors.white, - padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: DefaultButton( - TranslationBase.of(context).later, - () { - if(widget.isFromRegistration) { - ConfirmDialog dialog = new ConfirmDialog( - context: context, - confirmMessage: TranslationBase.of(context).validInsurance, - okText: TranslationBase.of(context).yes, - cancelText: TranslationBase.of(context).no, - okFunction: () { - ConfirmDialog.closeAlertDialog(context); - Navigator.pushAndRemoveUntil( + bottomSheet: Container( + color: Colors.white, + padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: DefaultButton( + TranslationBase.of(context).later, + () { + if(widget.isFromRegistration) { + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: TranslationBase.of(context).validInsurance, + okText: TranslationBase.of(context).yes, + cancelText: TranslationBase.of(context).no, + okFunction: () { + ConfirmDialog.closeAlertDialog(context); + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (context) => LandingPage()), + (Route route) => false, + ); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + }, + cancelFunction: () { + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (context) => LandingPage()), + (Route route) => false, + ); + }); + dialog.showAlertDialog(context); + } else { + Navigator.pushReplacement( + context, + FadePage( + page: LandingPage(), + ), + ); + // if(projectViewModel.isLoginChild) { + // Navigator.pushReplacement( + // context, + // FadePage( + // page: LandingPage(), + // ), + // ); + // } else { + // Navigator.pop( + // context, + // // FadePage( + // // page: LandingPage(), + // // ), + // ); + // } + } + }, + color: CustomColors.accentColor, + textColor: Colors.white, + ), + ), + SizedBox(width: 10), + Expanded( + child: DefaultButton( + TranslationBase.of(context).next, + rating <= 0 + ? null + : () { + Navigator.push( context, - MaterialPageRoute(builder: (context) => LandingPage()), - (Route route) => false, + FadePage( + page: RateAppointmentClinic( + appointmentDetails: model.appointmentDetails, + doctorNote: note, + doctorRate: rating, + ), + ), ); - Navigator.push(context, FadePage(page: InsuranceUpdate())); }, - cancelFunction: () { - Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute(builder: (context) => LandingPage()), - (Route route) => false, - ); - }); - dialog.showAlertDialog(context); - } else { - Navigator.pushReplacement( - context, - FadePage( - page: LandingPage(), - ), - ); - // if(projectViewModel.isLoginChild) { - // Navigator.pushReplacement( - // context, - // FadePage( - // page: LandingPage(), - // ), - // ); - // } else { - // Navigator.pop( - // context, - // // FadePage( - // // page: LandingPage(), - // // ), - // ); - // } - } - }, - color: CustomColors.accentColor, - textColor: Colors.white, - ), - ), - SizedBox(width: 10), - Expanded( - child: DefaultButton( - TranslationBase.of(context).next, - rating <= 0 - ? null - : () { - Navigator.push( - context, - FadePage( - page: RateAppointmentClinic( - appointmentDetails: model.appointmentDetails, - doctorNote: note, - doctorRate: rating, - ), - ), - ); - }, - // iconData: Icons.notifications_active, - color: Color(0xff359846), - disabledColor: Colors.grey, + // iconData: Icons.notifications_active, + color: Color(0xff359846), + disabledColor: Colors.grey, + ), ), - ), - ], + ], + ), ), ), ), diff --git a/lib/uitl/gif_loader_dialog_utils.dart b/lib/uitl/gif_loader_dialog_utils.dart index 59fed780..002f7608 100644 --- a/lib/uitl/gif_loader_dialog_utils.dart +++ b/lib/uitl/gif_loader_dialog_utils.dart @@ -8,8 +8,8 @@ class GifLoaderDialogUtils { static bool get isLoading => _isLoadingVisible; static showMyDialog(BuildContext context, {bool barrierDismissible = true}) { - // showDialog(context: context, builder: (cxt) => GifLoaderContainer()); - WidgetsBinding.instance.addPostFrameCallback((_) { + // Remove the PostFrameCallback to show dialog immediately + if (!_isLoadingVisible) { _isLoadingVisible = true; showDialog( barrierDismissible: barrierDismissible, @@ -22,7 +22,7 @@ class GifLoaderDialogUtils { ).then((value) { _isLoadingVisible = false; }); - }); + } } static hideDialog(BuildContext context) { diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 193c48c1..fbfbb205 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -21,6 +21,8 @@ import 'package:hmg_patient_app/pages/Blood/user_agreement_page.dart'; import 'package:hmg_patient_app/pages/DrawerPages/notifications/notifications_page.dart'; import 'package:hmg_patient_app/pages/landing/landing_page.dart'; import 'package:hmg_patient_app/pages/livecare/livecare_home.dart'; +import 'package:hmg_patient_app/pages/login/saved_login.dart'; +import 'package:hmg_patient_app/pages/login/welcome.dart'; import 'package:hmg_patient_app/pages/rateAppointment/rate_appointment_doctor.dart'; import 'package:hmg_patient_app/routes.dart'; import 'package:hmg_patient_app/services/authentication/auth_provider.dart'; @@ -108,78 +110,75 @@ class _AppDrawerState extends State { child: ListView( padding: EdgeInsets.zero, children: [ - Container( - height: SizeConfig.screenHeight! * .30, - child: InkWell( - child: Padding( - padding: const EdgeInsets.all(14.0), - child: Column( - children: [ - Container( - width: double.infinity, - padding: EdgeInsets.only(top: 12), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SvgPicture.asset( - "assets/images/new/logo.svg", - height: 60, - width: 60, - ), - IconButton( - icon: Icon(Icons.clear), - onPressed: () { - Navigator.pop(context); - }, - ) - ], - ), + InkWell( + child: Padding( + padding: const EdgeInsets.all(14.0), + child: Column( + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.only(top: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SvgPicture.asset( + "assets/images/new/logo.svg", + height: 60, + width: 60, + ), + IconButton( + icon: Icon(Icons.clear), + onPressed: () { + Navigator.pop(context); + }, + ) + ], ), - mHeight(12), - Container( - width: double.infinity, - margin: EdgeInsets.only(top: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - (user != null && projectProvider!.isLogin) ? user!.firstName! + ' ' + user!.lastName! : TranslationBase.of(context).cantSeeProfile, - style: TextStyle(color: Color(0xff2E303A), fontWeight: FontWeight.bold, fontSize: 20, letterSpacing: -1.2, height: 35 / 20), - ), - AutoSizeText( - (user != null && projectProvider!.isLogin) - ? TranslationBase.of(context).fileNumber + ": " + user!.patientID.toString() - : TranslationBase.of(context).loginRegisterNow, - maxLines: 1, - minFontSize: 10, - style: TextStyle( - fontSize: SizeConfig.textMultiplier! * 1.6, - fontWeight: FontWeight.w600, - letterSpacing: -0.39, - height: 0.8, - ), - ), - // Text( - // (user != null && projectProvider!.isLogin) - // ? TranslationBase.of(context).fileNumber + ": " + user!.patientID.toString() - // : TranslationBase.of(context).loginRegisterNow, - // style: TextStyle( - // color: Color(0xff2E303A), - // fontSize: 16, - // letterSpacing: -0.96, - // height: 1, - // ), - // ), - mHeight(20.0), + ), + mHeight(12), + Container( + width: double.infinity, + margin: EdgeInsets.only(top: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + (user != null && projectProvider!.isLogin) ? user!.firstName! + ' ' + user!.lastName! : TranslationBase.of(context).cantSeeProfile, + style: TextStyle(color: Color(0xff2E303A), fontWeight: FontWeight.bold, fontSize: 20, letterSpacing: -1.2, height: 35 / 20), + ), + AutoSizeText( (user != null && projectProvider!.isLogin) - ? Image.network("https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=${user!.patientID.toString()}", fit: BoxFit.fill, height: 70, width: 70) - : Container(), - ], - ), + ? TranslationBase.of(context).fileNumber + ": " + user!.patientID.toString() + : TranslationBase.of(context).loginRegisterNow, + maxLines: 1, + minFontSize: 10, + style: TextStyle( + fontSize: SizeConfig.textMultiplier! * 1.6, + fontWeight: FontWeight.w600, + letterSpacing: -0.39, + height: 0.8, + ), + ), + // Text( + // (user != null && projectProvider!.isLogin) + // ? TranslationBase.of(context).fileNumber + ": " + user!.patientID.toString() + // : TranslationBase.of(context).loginRegisterNow, + // style: TextStyle( + // color: Color(0xff2E303A), + // fontSize: 16, + // letterSpacing: -0.96, + // height: 1, + // ), + // ), + mHeight(20.0), + (user != null && projectProvider!.isLogin) + ? Image.network("https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=${user!.patientID.toString()}", fit: BoxFit.fill, height: 70, width: 70) + : Container(), + ], ), - ], - ), + ), + ], ), ), ), @@ -647,25 +646,42 @@ class _AppDrawerState extends State { login() async { var data = await sharedPref.getObject(IMEI_USER_DATA); sharedPref.remove(REGISTER_DATA_FOR_LOGIIN); - if (data != null) { - Navigator.of(context).pushNamed(CONFIRM_LOGIN); + SelectDeviceIMEIRES savedData = SelectDeviceIMEIRES.fromJson(data); + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => SavedLogin(savedData), + ), + ); + + } else { GifLoaderDialogUtils.showMyDialog(context); - authService.selectDeviceImei(DEVICE_TOKEN).then((SelectDeviceIMEIRES? value) { + authService.selectDeviceImei(DEVICE_TOKEN).then((value) async { GifLoaderDialogUtils.hideDialog(context); + var data = await sharedPref.getObject(IMEI_USER_DATA); if (value != null) { + SelectDeviceIMEIRES savedData = SelectDeviceIMEIRES.fromJson(data); setUserValues(value); - Navigator.of(context).pushNamed(CONFIRM_LOGIN); + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => SavedLogin(savedData), + ), + ); } else { - Navigator.of(context).pushNamed( - WELCOME_LOGIN, + GifLoaderDialogUtils.hideDialog(context); + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => WelcomeLogin(), + ), ); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); - Navigator.of(context).pushNamed( - WELCOME_LOGIN, + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => WelcomeLogin(), + ), ); }); } @@ -673,6 +689,35 @@ class _AppDrawerState extends State { locator().hamburgerMenu.logMenuItemClick('login'); } + // login() async { + // var data = await sharedPref.getObject(IMEI_USER_DATA); + // sharedPref.remove(REGISTER_DATA_FOR_LOGIIN); + // + // if (data != null) { + // Navigator.of(context).pushNamed(CONFIRM_LOGIN); + // } else { + // GifLoaderDialogUtils.showMyDialog(context); + // authService.selectDeviceImei(DEVICE_TOKEN).then((SelectDeviceIMEIRES? value) { + // GifLoaderDialogUtils.hideDialog(context); + // if (value != null) { + // setUserValues(value); + // Navigator.of(context).pushNamed(CONFIRM_LOGIN); + // } else { + // Navigator.of(context).pushNamed( + // WELCOME_LOGIN, + // ); + // } + // }).catchError((err) { + // GifLoaderDialogUtils.hideDialog(context); + // Navigator.of(context).pushNamed( + // WELCOME_LOGIN, + // ); + // }); + // } + // locator().loginRegistration.login_register_initiate(); + // locator().hamburgerMenu.logMenuItemClick('login'); + // } + Future getFamilyFiles() async { if (user != null) { if (await sharedPref.getObject(FAMILY_FILE) != null) { diff --git a/lib/widgets/drawer/langauge_picker.dart b/lib/widgets/drawer/langauge_picker.dart index 5de2d546..99be96b0 100644 --- a/lib/widgets/drawer/langauge_picker.dart +++ b/lib/widgets/drawer/langauge_picker.dart @@ -6,12 +6,14 @@ class LanguageSelector extends StatefulWidget { final String currentLanguage; final ValueChanged onLanguageChanged; final List> languages; + final bool showOnlyIcon; const LanguageSelector({ super.key, required this.currentLanguage, required this.onLanguageChanged, required this.languages, + required this.showOnlyIcon, }); @override @@ -26,44 +28,54 @@ class _LanguageSelectorState extends State { orElse: () => {'code': 'en', 'name': 'English'}, ); - return Stack(clipBehavior: Clip.none, children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Color(0xFFFEE9EA), - ), - child: InkWell( - onTap: () { - final newLanguage = widget.currentLanguage == 'ar' ? 'en' : 'ar'; - print(newLanguage); - widget.onLanguageChanged(newLanguage); - - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - SvgPicture.asset("assets/images/svg/language.svg", width: 24), - const SizedBox(width: 6), - Text( - currentLangData['name']?.toUpperCase() ?? 'EN', - style: context.dynamicTextStyle( + if (widget.showOnlyIcon) { + return InkWell( + onTap: () { + final newLanguage = widget.currentLanguage == 'ar' ? 'en' : 'ar'; + print(newLanguage); + widget.onLanguageChanged(newLanguage); + }, + child: SvgPicture.asset("assets/images/svg/globe_black.svg", width: 32), + ); + } else { + return Stack(clipBehavior: Clip.none, children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Color(0xFFFEE9EA), + ), + child: InkWell( + onTap: () { + final newLanguage = widget.currentLanguage == 'ar' ? 'en' : 'ar'; + print(newLanguage); + widget.onLanguageChanged(newLanguage); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset("assets/images/svg/language.svg", width: 24), + const SizedBox(width: 6), + Text( + currentLangData['name']?.toUpperCase() ?? 'EN', + style: context.dynamicTextStyle( fontWeight: FontWeight.w500, fontSize: 14, color: const Color(0xFFED1C2B), letterSpacing: 0.1, - isLanguageSwitcher: true, + isLanguageSwitcher: true, + ), ), - ), - ], + ], + ), ), ), ), - ), - ]); + ]); + } } } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index d3478112..f84c2d84 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -89,6 +89,7 @@ class AppScaffold extends StatefulWidget { final bool isShowLanguageChanger; final bool resizeToAvoidBottomInset; final bool showCenteredLogo; + final bool showLastLoginScreenBar; AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -141,6 +142,7 @@ class AppScaffold extends StatefulWidget { this.isShowLanguageChanger = false, this.resizeToAvoidBottomInset = false, this.showCenteredLogo = false, + this.showLastLoginScreenBar = false, }); @override @@ -237,7 +239,7 @@ class _AppScaffoldState extends State { // : widget.isShowAppBar // ? widget.customAppBar != null // ? widget.customAppBar - + extendBodyBehindAppBar: true, appBar: isUserNotLogin ? null : widget.isShowPharmacyAppbar @@ -256,6 +258,7 @@ class _AppScaffoldState extends State { appBarIcons: widget.appBarIcons, showCenterLogo: widget.showCenteredLogo, isShowLanguageChanger: widget.isShowLanguageChanger, + showSavedLoginBar: widget.showLastLoginScreenBar, onTap: () { widget.onTap; }, @@ -361,25 +364,27 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { final List? appBarIcons; final bool isShowLanguageChanger; final bool showCenterLogo; + final bool showSavedLoginBar; String currentLang = 'ar'; VoidCallback? onTap; - NewAppBarWidget( - {Key? key, - this.showTitle = false, - this.showDropDown = false, - this.title = "", - this.dropDownList, - this.appBarIcons, - this.dropdownIndexValue, - this.dropDownIndexChange, - this.onTap, - this.isShowBackButton = true, - this.isShowLanguageChanger = false, - this.showCenterLogo = false}) - : super(key: key); + NewAppBarWidget({ + Key? key, + this.showTitle = false, + this.showDropDown = false, + this.title = "", + this.dropDownList, + this.appBarIcons, + this.dropdownIndexValue, + this.dropDownIndexChange, + this.onTap, + this.isShowBackButton = true, + this.isShowLanguageChanger = false, + this.showCenterLogo = false, + this.showSavedLoginBar = false, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -397,77 +402,178 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { : null, // centerTitle: showCenterLogo, titleSpacing: -8, - // centerTitle: false, - title: Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (showCenterLogo) SvgPicture.asset('assets/images/svg/habiblogo.svg', height: 32, width: 32).withHorizontalPadding(25), - if (showTitle) - Expanded( - child: Text( - title, - maxLines: 1, - style: TextStyle( - fontSize: 24, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 35 / 24), - ), - ), - if (showDropDown! && !isShowLanguageChanger) - Container( - decoration: containerRadius(Color(0xFFF7F7F7), 30), - height: 30, - child: DropdownButtonHideUnderline( - child: ButtonTheme( - alignedDropdown: true, - child: DropdownButton( - iconEnabledColor: CustomColors.grey2, - style: TextStyle(color: CustomColors.lightGreyColor, fontSize: 12), - dropdownColor: CustomColors.lightGreyColor, - value: dropdownIndexValue, - items: [ - for (int i = 0; i < dropDownList!.length; i++) - DropdownMenuItem( - value: i, - child: AutoSizeText( - dropDownList![i], - style: TextStyle( - fontSize: 12, - fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), - fontWeight: FontWeight.w600, - color: Color(0xff2B2E31), - letterSpacing: -.48, - // height: 12 / 18 - ), + // centerTitle: showSavedLoginBar, + title: showSavedLoginBar + ? Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SvgPicture.asset( + 'assets/images/svg/card_user.svg', + height: 32, + width: 32, + ).withHorizontalPadding(24), + if (showCenterLogo) Expanded(child: SvgPicture.asset('assets/images/svg/habiblogo.svg', height: 32, width: 32)), + if (showDropDown! && isShowLanguageChanger) + Directionality( + textDirection: TextDirection.ltr, + child: LanguageSelector( + currentLanguage: projectViewModel.isArabic ? 'ar' : 'en', + showOnlyIcon: true, + onLanguageChanged: (String value) { + dropDownIndexChange!(value == 'ar' ? 1 : 0); + }, + languages: [ + {'code': 'ar', 'name': '${TranslationBase.of(context).lanEnglish}'}, + {'code': 'en', 'name': '${TranslationBase.of(context).lanArabic}'} + ], + ), + ).withHorizontalPadding(24), + ], + ) + : Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + if (showTitle) + Expanded( + child: Text( + title, + maxLines: 1, + style: TextStyle( + fontSize: 24, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 35 / 24), + ), + ), + if (showDropDown! && !isShowLanguageChanger) + Container( + decoration: containerRadius(Color(0xFFF7F7F7), 30), + height: 30, + child: DropdownButtonHideUnderline( + child: ButtonTheme( + alignedDropdown: true, + child: DropdownButton( + iconEnabledColor: CustomColors.grey2, + style: TextStyle(color: CustomColors.lightGreyColor, fontSize: 12), + dropdownColor: CustomColors.lightGreyColor, + value: dropdownIndexValue, + items: [ + for (int i = 0; i < dropDownList!.length; i++) + DropdownMenuItem( + value: i, + child: AutoSizeText( + dropDownList![i], + style: TextStyle( + fontSize: 12, + fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), + fontWeight: FontWeight.w600, + color: Color(0xff2B2E31), + letterSpacing: -.48, + // height: 12 / 18 + ), + ), + ) + ], + onChanged: dropDownIndexChange, + underline: Container( + height: 0, ), - ) - ], - onChanged: dropDownIndexChange, - underline: Container( - height: 0, + ), + ), ), ), - ), - ), - ), - if (showDropDown! && isShowLanguageChanger) - Padding( - padding: EdgeInsets.symmetric(horizontal: 25), - child: Directionality( - textDirection: TextDirection.ltr, - child: LanguageSelector( - currentLanguage: projectViewModel.isArabic ? 'ar' : 'en', - onLanguageChanged: (String value) { - dropDownIndexChange!(value == 'ar' ? 1 : 0); - }, - languages: [ - {'code': 'ar', 'name': '${TranslationBase.of(context).lanEnglish}'}, - {'code': 'en', 'name': '${TranslationBase.of(context).lanArabic}'} - ], - ), - ), + if (showDropDown! && isShowLanguageChanger) + Padding( + padding: EdgeInsets.symmetric(horizontal: 20), + child: Directionality( + textDirection: TextDirection.ltr, + child: LanguageSelector( + currentLanguage: projectViewModel.isArabic ? 'ar' : 'en', + showOnlyIcon: false, + onLanguageChanged: (String value) { + dropDownIndexChange!(value == 'ar' ? 1 : 0); + }, + languages: [ + {'code': 'ar', 'name': '${TranslationBase.of(context).lanEnglish}'}, + {'code': 'en', 'name': '${TranslationBase.of(context).lanArabic}'} + ], + ), + ), + ), + ], ), - ], - ), + + // Row( + // crossAxisAlignment: CrossAxisAlignment.center, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // if (showTitle) + // Expanded( + // child: Text( + // title, + // maxLines: 1, + // style: TextStyle( + // fontSize: 24, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 35 / 24), + // ), + // ), + // if (showDropDown! && !isShowLanguageChanger) + // Container( + // decoration: containerRadius(Color(0xFFF7F7F7), 30), + // height: 30, + // child: DropdownButtonHideUnderline( + // child: ButtonTheme( + // alignedDropdown: true, + // child: DropdownButton( + // iconEnabledColor: CustomColors.grey2, + // style: TextStyle(color: CustomColors.lightGreyColor, fontSize: 12), + // dropdownColor: CustomColors.lightGreyColor, + // value: dropdownIndexValue, + // items: [ + // for (int i = 0; i < dropDownList!.length; i++) + // DropdownMenuItem( + // value: i, + // child: AutoSizeText( + // dropDownList![i], + // style: TextStyle( + // fontSize: 12, + // fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), + // fontWeight: FontWeight.w600, + // color: Color(0xff2B2E31), + // letterSpacing: -.48, + // // height: 12 / 18 + // ), + // ), + // ) + // ], + // onChanged: dropDownIndexChange, + // underline: Container( + // height: 0, + // ), + // ), + // ), + // ), + // ), + // if (showDropDown! && isShowLanguageChanger) + // Expanded( + // child: Padding( + // padding: EdgeInsets.symmetric(horizontal: 25), + // child: Directionality( + // textDirection: TextDirection.ltr, + // child: LanguageSelector( + // currentLanguage: projectViewModel.isArabic ? 'ar' : 'en', + // onLanguageChanged: (String value) { + // dropDownIndexChange!(value == 'ar' ? 1 : 0); + // }, + // languages: [ + // {'code': 'ar', 'name': '${TranslationBase.of(context).lanEnglish}'}, + // {'code': 'en', 'name': '${TranslationBase.of(context).lanArabic}'} + // ], + // ), + // ), + // ), + // ), + // ], + // ), + actions: [ if (appBarIcons != null) ...appBarIcons! diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 9dff5c51..a4ecbaab 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -18,21 +18,16 @@ import '../otp_widget.dart'; class SMSOTP { final type; - final mobileNo; - final Function onSuccess; - final Function onFailure; - final context; int remainingTime = 120; - - Future? timer; + Timer? _timer; // Changed from Future? to Timer? + bool _isDisposed = false; // Add disposal flag static BuildContext? _context; - static bool? _loading; SMSOTP( @@ -361,19 +356,32 @@ class SMSOTP { } startTimer(setState) { + // Cancel any existing timer + _timer?.cancel(); + this.remainingTime--; - setState(() { - displayTime = this.getSecondsAsDigitalClock(this.remainingTime); - }); + // Check if widget is still mounted before calling setState + if (!_isDisposed) { + setState(() { + displayTime = this.getSecondsAsDigitalClock(this.remainingTime); + }); + + _timer = Timer(Duration(seconds: 1), () { + if (!_isDisposed && this.remainingTime > 0) { + startTimer(setState); + } else if (!_isDisposed && this.remainingTime <= 0) { + Navigator.pop(context); + } + }); + } + } - timer = Future.delayed(Duration(seconds: 1), () { - if (this.remainingTime > 0) { - startTimer(setState); - } else { - Navigator.pop(context); - } - }); + // Add method to dispose the timer properly + void dispose() { + _isDisposed = true; + _timer?.cancel(); + _timer = null; } static void hideSMSBox(context) {