From e76018ba2f048fed19d8263c8f53f5bf5eb1b800 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Sun, 19 Jul 2026 11:25:06 +0300 Subject: [PATCH] update --- lib/main.dart | 3 +- lib/pages/login/confirm-login.dart | 2 +- lib/widgets/drawer/app_drawer_widget.dart | 12 +++---- lib/widgets/otp/sms-popup.dart | 44 ++++++++++++++++++----- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 03ac65fc..1e9e01f1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -120,7 +120,7 @@ class _MyApp extends State { @override Widget build(BuildContext context) { PlatformBridge.init(context); - AppGlobal.context = context; + // Don't set AppGlobal.context here - it's set after MultiProvider is created // SystemChrome.setPreferredOrientations([ // DeviceOrientation.portraitUp, @@ -174,6 +174,7 @@ class _MyApp extends State { child: Consumer( builder: (context, projectProvider, child) => MaterialApp( builder: (context, mchild) { + AppGlobal.context = context; // Set context here after MultiProvider AppGlobal.projectViewModelContext = context; return MediaQuery( data: MediaQuery.of(context).copyWith( diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 537aaafd..b6b9e449 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -180,7 +180,7 @@ class _ConfirmLogin extends State { // user!.editedOn != null // ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user!.editedOn!)) // : - user!.createdOn != null ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user!.createdOn!)) : '--', + user!.createdOn != null && user!.createdOn !='null'? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user!.createdOn!)) : '--', style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), ), ], diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 45fd0275..3a6839d7 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -217,7 +217,7 @@ class _AppDrawerState extends State { children: [ (user!.isFamily == null || user!.isFamily == false) ? InkWell( - child: DrawerItem(TranslationBase.of(context).family, SvgPicture.asset("assets/images/new/family_files.svg"), + child: DrawerItem(TranslationBase.of(context).family, SvgPicture.asset("assets/images/new/family_files.svg", width: 20, height: 20), isImageIcon: true, bottomLine: false, textColor: CustomColors.black, @@ -259,7 +259,7 @@ class _AppDrawerState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: SvgPicture.asset("assets/images/new/family_files.svg"), + child: SvgPicture.asset("assets/images/new/family_files.svg", width: 20, height: 20), ), Expanded( flex: 7, @@ -389,7 +389,7 @@ class _AppDrawerState extends State { children: [ DrawerItem( TranslationBase.of(context).notification, - SvgPicture.asset("assets/images/new/notifications.svg"), + SvgPicture.asset("assets/images/new/notifications.svg", width: 20, height: 20), isImageIcon: true, bottomLine: false, letterSpacing: -0.84, @@ -430,7 +430,7 @@ class _AppDrawerState extends State { ), if (projectProvider!.havePrivilege(3)) InkWell( - child: DrawerItem(TranslationBase.of(context).appsetting, SvgPicture.asset("assets/images/new/app_setting.svg"), + child: DrawerItem(TranslationBase.of(context).appsetting, SvgPicture.asset("assets/images/new/app_setting.svg", width: 20, height: 20), isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { Navigator.of(context).pushNamed( @@ -452,7 +452,7 @@ class _AppDrawerState extends State { }, ), InkWell( - child: DrawerItem(TranslationBase.of(context).logout, SvgPicture.asset("assets/images/new/logout.svg"), + child: DrawerItem(TranslationBase.of(context).logout, SvgPicture.asset("assets/images/new/logout.svg", width: 20, height: 20), isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { logout(); @@ -461,7 +461,7 @@ class _AppDrawerState extends State { ], ) : InkWell( - child: DrawerItem(TranslationBase.of(context).loginregister, SvgPicture.asset("assets/images/new/logout.svg"), + child: DrawerItem(TranslationBase.of(context).loginregister, SvgPicture.asset("assets/images/new/logout.svg", width: 20, height: 20), isImageIcon: true, letterSpacing: -0.84, fontSize: 14, bottomLine: false, projectProvider: projectProvider), onTap: () { login(); diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 71738aba..01e6f0b0 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -32,6 +32,8 @@ class SMSOTP { static bool? _loading; + bool _isDialogActive = false; + SMSOTP( this.context, this.type, @@ -90,7 +92,12 @@ class SMSOTP { // } - return showDialog( + // Reset state for fresh dialog + _isDialogActive = true; + remainingTime = 120; + displayTime = ''; + + var result = await showDialog( context: context, barrierColor: Colors.black.withOpacity(0.63), builder: (context) { @@ -129,7 +136,10 @@ class SMSOTP { icon: Icon(Icons.close), constraints: BoxConstraints(), onPressed: () { - Navigator.pop(context); + _isDialogActive = false; + if (Navigator.canPop(context)) { + Navigator.pop(context); + } this.onFailure(); }, @@ -186,6 +196,11 @@ class SMSOTP { }), ); }); + + // Clean up when dialog is dismissed + _isDialogActive = false; + + return result; } TextStyle buildTextStyle() { @@ -263,27 +278,38 @@ class SMSOTP { } startTimer(setState) { + if (!_isDialogActive) return; // Don't proceed if dialog is no longer active + this.remainingTime--; - setState(() { - displayTime = this.getSecondsAsDigitalClock(this.remainingTime); - }); + // Check again before calling setState to ensure dialog is still active + if (_isDialogActive) { + setState(() { + displayTime = this.getSecondsAsDigitalClock(this.remainingTime); + }); + } timer = Future.delayed(Duration(seconds: 1), () { - if (this.remainingTime > 0) { + if (_isDialogActive && this.remainingTime > 0) { startTimer(setState); - } else { - Navigator.pop(context); + } else if (_isDialogActive && this.remainingTime <= 0) { + _isDialogActive = false; + if (Navigator.canPop(context)) { + Navigator.pop(context); + } } }); } static void hideSMSBox(context) { - Navigator.pop(context); + if (Navigator.canPop(context)) { + Navigator.pop(context); + } } _onOtpCallBack(String otpCode, bool isAutofill) { if (otpCode.length == 4) { + _isDialogActive = false; // Stop the timer when OTP is entered onSuccess(otpCode); } }