From bd4400e32fdd848137c61395a034b9cd7bf3d3bd Mon Sep 17 00:00:00 2001 From: Aamir Muhammad Date: Sun, 10 Aug 2025 14:27:34 +0300 Subject: [PATCH] changes --- .../otp/otp_validation_bootmsheet_widget.dart | 4 ++ lib/pages/login/register_new.dart | 3 +- lib/pages/login/welcome.dart | 64 +++++++++---------- lib/widgets/otp/sms-popup.dart | 11 +++- lib/widgets/otp_widget.dart | 39 +++++------ lib/widgets/quick_login.dart | 1 - 6 files changed, 67 insertions(+), 55 deletions(-) diff --git a/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart b/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart index b3ab81fc..89d1d930 100644 --- a/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart +++ b/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -53,6 +55,8 @@ class _GenericBottomSheetState extends State { @override Widget build(BuildContext context) { return SafeArea( + top: false, + bottom: Platform.isIOS ? false : true, child: GestureDetector( onTap: () { FocusScope.of(context).unfocus(); // Dismiss the keyboard when tapping outside diff --git a/lib/pages/login/register_new.dart b/lib/pages/login/register_new.dart index 5d40eaab..3940df0f 100644 --- a/lib/pages/login/register_new.dart +++ b/lib/pages/login/register_new.dart @@ -924,7 +924,7 @@ class _RegisterNew extends State { type: type, skipRegistration: skipRegistration, onWrongActivationCode: (String? message, bool? isReroute) { - if (isReroute== true) { + if (isReroute == true) { context.showBottomSheet( child: ExceptionBottomSheet( message: message.toString(), @@ -935,6 +935,7 @@ class _RegisterNew extends State { ), ); } else { + smsOtp.clearOTPInput(); context.showBottomSheet( child: ExceptionBottomSheet( message: message.toString(), diff --git a/lib/pages/login/welcome.dart b/lib/pages/login/welcome.dart index 84a0669b..03090d0c 100644 --- a/lib/pages/login/welcome.dart +++ b/lib/pages/login/welcome.dart @@ -342,17 +342,15 @@ class _WelcomeLogin extends State { .catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); - ConfirmDialog dialog = new ConfirmDialog( - context: context, - confirmMessage: err, - okText: TranslationBase.of(context).confirm, - cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => { - ConfirmDialog.closeAlertDialog(context), - Navigator.of(context).push(FadePage(page: RegisterNew())), - }, - cancelFunction: () => {}); - dialog.showAlertDialog(context); + context.showBottomSheet( + child: ExceptionBottomSheet( + message: err.toString(), + showCancel: true, + onOkPressed: () { + Navigator.of(context).pop(); + Navigator.of(context).push(FadePage(page: RegisterNew())); + }, + )); projectViewModel.analytics.loginRegistration.login_fail(error: err.toString()); }); } @@ -509,7 +507,7 @@ class _WelcomeLogin extends State { checkActivationCode( value: code, onWrongActivationCode: (String? message) { - // smsOtp.pauseTimer(); + smsOtp.clearOTPInput(); // Clear the SMS code when wrong context.showBottomSheet( child: ExceptionBottomSheet( message: message.toString(), @@ -641,13 +639,13 @@ class _WelcomeLogin extends State { } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); - context.showBottomSheet( - child: ExceptionBottomSheet( - message: err.toString(), - onOkPressed: () { - Navigator.of(context).pop(); - }, - )); + // context.showBottomSheet( + // child: ExceptionBottomSheet( + // message: err.toString(), + // onOkPressed: () { + // Navigator.of(context).pop(); + // }, + // )); // print(err); }); } else { @@ -683,13 +681,13 @@ class _WelcomeLogin extends State { } insertIMEI(); }).catchError((error) { - context.showBottomSheet( - child: ExceptionBottomSheet( - message: error.toString(), - onOkPressed: () { - Navigator.of(context).pop(); - }, - )); + // context.showBottomSheet( + // child: ExceptionBottomSheet( + // message: error.toString(), + // onOkPressed: () { + // Navigator.of(context).pop(); + // }, + // )); }); } @@ -709,13 +707,13 @@ class _WelcomeLogin extends State { insertIMEI() { authService.insertDeviceImei(selectedOption).then((value) => {}).catchError((err) { - context.showBottomSheet( - child: ExceptionBottomSheet( - message: err.toString(), - onOkPressed: () { - Navigator.of(context).pop(); - }, - )); + // context.showBottomSheet( + // child: ExceptionBottomSheet( + // message: err.toString(), + // onOkPressed: () { + // Navigator.of(context).pop(); + // }, + // )); // print(err); }); } diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 92bd1ed3..1bee1380 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -136,7 +136,7 @@ class SMSOTP { child: OTPWidget( autoFocus: true, controller: _pinPutController, - defaultBorderColor: Color(0xffffffff), + defaultBorderColor: Color(0xffE0E0E0), // Changed from white to light gray maxLength: 4, onTextChanged: (text) {}, pinBoxColor: Colors.white, @@ -315,6 +315,15 @@ class SMSOTP { return remainingTime; } + // Method to clear the OTP input + void clearOTPInput() { + _pinPutController.clear(); + digit1.clear(); + digit2.clear(); + digit3.clear(); + digit4.clear(); + } + checkSignature() async { SmsVerification.startListeningSms().then((message) { // setState(() { diff --git a/lib/widgets/otp_widget.dart b/lib/widgets/otp_widget.dart index 91c5bb08..b69a7041 100644 --- a/lib/widgets/otp_widget.dart +++ b/lib/widgets/otp_widget.dart @@ -208,19 +208,19 @@ class OTPWidgetState extends State with SingleTickerProviderStateMixi return widget.hideDefaultKeyboard ? _pinBoxRow(context) : GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - if (hasFocus) { - FocusScope.of(context).requestFocus(FocusNode()); - Future.delayed(Duration(milliseconds: 100), () { - FocusScope.of(context).requestFocus(focusNode); - }); - } else { - FocusScope.of(context).requestFocus(focusNode); - } - }, - child: _pinBoxRow(context), - ); + behavior: HitTestBehavior.opaque, + onTap: () { + if (hasFocus) { + FocusScope.of(context).requestFocus(FocusNode()); + Future.delayed(Duration(milliseconds: 100), () { + FocusScope.of(context).requestFocus(focusNode); + }); + } else { + FocusScope.of(context).requestFocus(focusNode); + } + }, + child: _pinBoxRow(context), + ); } Widget _otpTextInput() { @@ -318,13 +318,13 @@ class OTPWidgetState extends State with SingleTickerProviderStateMixi // } Widget _buildPinCode(int i, BuildContext context) { - final bool isFilled = i < text.length; + final bool isFilled = i < text.length && strList[i].isNotEmpty; // Check both conditions final bool isCurrent = i == currentIndex; final bool isFocused = hasFocus && isCurrent; // Colors based on state Color bgColor = Colors.white; - Color borderColor = widget.defaultBorderColor; + Color borderColor = Colors.white; Color textColor = Colors.black; if (widget.hasError) { @@ -333,12 +333,13 @@ class OTPWidgetState extends State with SingleTickerProviderStateMixi } else if (isFocused) { borderColor = Colors.transparent; bgColor = Colors.white; - textColor = Colors.white; + textColor = Colors.black; // Changed from white to black for better visibility } else if (isFilled) { borderColor = Colors.green; bgColor = Colors.green; textColor = Colors.white; } + // When cleared/empty, colors remain as default initialized above return Container( key: ValueKey("container$i"), @@ -448,7 +449,7 @@ class OTPWidgetState extends State with SingleTickerProviderStateMixi softWrap: true, key: ValueKey("$text$i"), style: widget.pinTextStyle?.copyWith(color: textColor, fontSize: fontSize, fontWeight: fontWeight, fontFamily: context.fontFamily) ?? - TextStyle(color: textColor, fontSize: fontSize, fontWeight: fontWeight, fontFamily: context.fontFamily, ), + TextStyle(color: textColor, fontSize: fontSize, fontWeight: fontWeight, fontFamily: context.fontFamily,), ), ); } else { @@ -461,6 +462,7 @@ class OTPWidgetState extends State with SingleTickerProviderStateMixi ); } } +} // // Widget _animatedTextBox(String text, int i, Color textColor) { @@ -483,5 +485,4 @@ class OTPWidgetState extends State with SingleTickerProviderStateMixi // TextStyle(color: textColor, fontSize: 24, fontWeight: FontWeight.bold), // ); // } -// } -} +// }} diff --git a/lib/widgets/quick_login.dart b/lib/widgets/quick_login.dart index 51fb859d..f7c2990a 100644 --- a/lib/widgets/quick_login.dart +++ b/lib/widgets/quick_login.dart @@ -91,7 +91,6 @@ class _QuickLoginBottomSheet extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Expanded(child: - CustomButton( text:TranslationBase.of(context).enableQuickLogin, onPressed:widget.onPressed,