master
Sultan khan 3 days ago
parent 2619998362
commit e76018ba2f

@ -120,7 +120,7 @@ class _MyApp extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
PlatformBridge.init(context); PlatformBridge.init(context);
AppGlobal.context = context; // Don't set AppGlobal.context here - it's set after MultiProvider is created
// SystemChrome.setPreferredOrientations([ // SystemChrome.setPreferredOrientations([
// DeviceOrientation.portraitUp, // DeviceOrientation.portraitUp,
@ -174,6 +174,7 @@ class _MyApp extends State<MyApp> {
child: Consumer<ProjectViewModel>( child: Consumer<ProjectViewModel>(
builder: (context, projectProvider, child) => MaterialApp( builder: (context, projectProvider, child) => MaterialApp(
builder: (context, mchild) { builder: (context, mchild) {
AppGlobal.context = context; // Set context here after MultiProvider
AppGlobal.projectViewModelContext = context; AppGlobal.projectViewModelContext = context;
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith( data: MediaQuery.of(context).copyWith(

@ -180,7 +180,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
// user!.editedOn != null // user!.editedOn != null
// ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user!.editedOn!)) // ? 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), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48),
), ),
], ],

@ -217,7 +217,7 @@ class _AppDrawerState extends State<AppDrawer> {
children: <Widget>[ children: <Widget>[
(user!.isFamily == null || user!.isFamily == false) (user!.isFamily == null || user!.isFamily == false)
? InkWell( ? 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, isImageIcon: true,
bottomLine: false, bottomLine: false,
textColor: CustomColors.black, textColor: CustomColors.black,
@ -259,7 +259,7 @@ class _AppDrawerState extends State<AppDrawer> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: SvgPicture.asset("assets/images/new/family_files.svg"), child: SvgPicture.asset("assets/images/new/family_files.svg", width: 20, height: 20),
), ),
Expanded( Expanded(
flex: 7, flex: 7,
@ -389,7 +389,7 @@ class _AppDrawerState extends State<AppDrawer> {
children: [ children: [
DrawerItem( DrawerItem(
TranslationBase.of(context).notification, TranslationBase.of(context).notification,
SvgPicture.asset("assets/images/new/notifications.svg"), SvgPicture.asset("assets/images/new/notifications.svg", width: 20, height: 20),
isImageIcon: true, isImageIcon: true,
bottomLine: false, bottomLine: false,
letterSpacing: -0.84, letterSpacing: -0.84,
@ -430,7 +430,7 @@ class _AppDrawerState extends State<AppDrawer> {
), ),
if (projectProvider!.havePrivilege(3)) if (projectProvider!.havePrivilege(3))
InkWell( 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), isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider),
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
@ -452,7 +452,7 @@ class _AppDrawerState extends State<AppDrawer> {
}, },
), ),
InkWell( 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), isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider),
onTap: () { onTap: () {
logout(); logout();
@ -461,7 +461,7 @@ class _AppDrawerState extends State<AppDrawer> {
], ],
) )
: InkWell( : 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), isImageIcon: true, letterSpacing: -0.84, fontSize: 14, bottomLine: false, projectProvider: projectProvider),
onTap: () { onTap: () {
login(); login();

@ -32,6 +32,8 @@ class SMSOTP {
static bool? _loading; static bool? _loading;
bool _isDialogActive = false;
SMSOTP( SMSOTP(
this.context, this.context,
this.type, 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, context: context,
barrierColor: Colors.black.withOpacity(0.63), barrierColor: Colors.black.withOpacity(0.63),
builder: (context) { builder: (context) {
@ -129,7 +136,10 @@ class SMSOTP {
icon: Icon(Icons.close), icon: Icon(Icons.close),
constraints: BoxConstraints(), constraints: BoxConstraints(),
onPressed: () { onPressed: () {
_isDialogActive = false;
if (Navigator.canPop(context)) {
Navigator.pop(context); Navigator.pop(context);
}
this.onFailure(); this.onFailure();
}, },
@ -186,6 +196,11 @@ class SMSOTP {
}), }),
); );
}); });
// Clean up when dialog is dismissed
_isDialogActive = false;
return result;
} }
TextStyle buildTextStyle() { TextStyle buildTextStyle() {
@ -263,27 +278,38 @@ class SMSOTP {
} }
startTimer(setState) { startTimer(setState) {
if (!_isDialogActive) return; // Don't proceed if dialog is no longer active
this.remainingTime--; this.remainingTime--;
// Check again before calling setState to ensure dialog is still active
if (_isDialogActive) {
setState(() { setState(() {
displayTime = this.getSecondsAsDigitalClock(this.remainingTime); displayTime = this.getSecondsAsDigitalClock(this.remainingTime);
}); });
}
timer = Future.delayed(Duration(seconds: 1), () { timer = Future.delayed(Duration(seconds: 1), () {
if (this.remainingTime > 0) { if (_isDialogActive && this.remainingTime > 0) {
startTimer(setState); startTimer(setState);
} else { } else if (_isDialogActive && this.remainingTime <= 0) {
_isDialogActive = false;
if (Navigator.canPop(context)) {
Navigator.pop(context); Navigator.pop(context);
} }
}
}); });
} }
static void hideSMSBox(context) { static void hideSMSBox(context) {
if (Navigator.canPop(context)) {
Navigator.pop(context); Navigator.pop(context);
} }
}
_onOtpCallBack(String otpCode, bool isAutofill) { _onOtpCallBack(String otpCode, bool isAutofill) {
if (otpCode.length == 4) { if (otpCode.length == 4) {
_isDialogActive = false; // Stop the timer when OTP is entered
onSuccess(otpCode); onSuccess(otpCode);
} }
} }

Loading…
Cancel
Save