login fixes

merge-update-with-lab-changes
Sultan khan 7 months ago committed by haroon amjad
parent 29675e3058
commit e689826730

@ -2365,7 +2365,9 @@ const Map localizedValues = {
"notice": {"en": "Notice", "ar":"إشعار"}, "notice": {"en": "Notice", "ar":"إشعار"},
"receiveOtpToast": {"en": "Where would you like to receive OTP?", "ar":"أين تود تلقي رمز التحقق OTP؟"}, "receiveOtpToast": {"en": "Where would you like to receive OTP?", "ar":"أين تود تلقي رمز التحقق OTP؟"},
"pleaseChooseOption": {"en": "Please select from the below options to receive OTP.", "ar":"الرجاء اختيار من الخيارات أدناه لتلقي رمز التحقق OTP."}, "pleaseChooseOption": {"en": "Please select from the below options to receive OTP.", "ar":"الرجاء اختيار من الخيارات أدناه لتلقي رمز التحقق OTP."},
"pleaseEnterMobile": {"en": "Please enter phone number", "ar":"الرجاء إدخال رقم الهاتف"},
"pleaseEnterValidMobile": {"en": "Please enter valid phone number", "ar":"الرجاء إدخال رقم هاتف صالح"},
"pleaseEnterNationalIdOrFileNo": {"en": "Please enter National id or File no", "ar":"الرجاء إدخال رقم الهوية الوطنية أو رقم الملف"},

@ -20,7 +20,7 @@ class GenericBottomSheet extends StatefulWidget {
final bool isEnableCountryDropdown; final bool isEnableCountryDropdown;
final bool isFromSavedLogin; final bool isFromSavedLogin;
Function(String?)? onChange; Function(String?)? onChange;
FocusNode myFocusNode;
GenericBottomSheet( GenericBottomSheet(
{this.countryCode = "", {this.countryCode = "",
this.initialPhoneNumber = "", this.initialPhoneNumber = "",
@ -30,7 +30,9 @@ class GenericBottomSheet extends StatefulWidget {
this.onCountryChange, this.onCountryChange,
this.isEnableCountryDropdown = false, this.isEnableCountryDropdown = false,
this.isFromSavedLogin = false, this.isFromSavedLogin = false,
this.onChange}); this.onChange,
required this.myFocusNode
});
@override @override
_GenericBottomSheetState createState() => _GenericBottomSheetState(); _GenericBottomSheetState createState() => _GenericBottomSheetState();
@ -138,7 +140,7 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
} }
}, },
isEnable: true, isEnable: true,
autoFocus: true, focusNode: widget.myFocusNode,
isReadOnly: widget.isFromSavedLogin, isReadOnly: widget.isFromSavedLogin,
prefix: widget.isForEmail ? null : widget.countryCode, prefix: widget.isForEmail ? null : widget.countryCode,
hasSelection: false, hasSelection: false,
@ -182,7 +184,7 @@ class CustomButton extends StatelessWidget {
final String? fontFamily; final String? fontFamily;
final FontWeight fontWeight; final FontWeight fontWeight;
final bool isDisabled; final bool isDisabled;
final Color iconColor;
CustomButton({ CustomButton({
Key? key, Key? key,
required this.text, required this.text,
@ -198,6 +200,7 @@ class CustomButton extends StatelessWidget {
this.fontWeight = FontWeight.w500, this.fontWeight = FontWeight.w500,
this.isDisabled = false, this.isDisabled = false,
this.icon, this.icon,
this.iconColor = Colors.white,
}) : super(key: key); }) : super(key: key);
@override @override
@ -222,6 +225,10 @@ class CustomButton extends StatelessWidget {
padding: const EdgeInsets.only(right: 8.0), padding: const EdgeInsets.only(right: 8.0),
child: SvgPicture.asset( child: SvgPicture.asset(
icon!, icon!,
colorFilter: ColorFilter.mode(
isDisabled ? iconColor.withOpacity(0.5) : iconColor,
BlendMode.srcIn,
),
width: 24, width: 24,
height: 24, height: 24,
), ),

@ -808,6 +808,10 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
await sharedPref.setInt(LAST_LOGIN, lastLogin); await sharedPref.setInt(LAST_LOGIN, lastLogin);
showQuickLoginBottomSheet(context, user, deviceToken, true); showQuickLoginBottomSheet(context, user, deviceToken, true);
Future.delayed(Duration(seconds: 3), () {
Navigator.of(context).pop();
});
insertIMEI(lastLogin, deviceToken); insertIMEI(lastLogin, deviceToken);
} }
} }

@ -66,7 +66,7 @@ class _RegisterNew extends State<RegisterNew> {
final nationalIDorFile = TextEditingController(); final nationalIDorFile = TextEditingController();
final phoneController = TextEditingController(); final phoneController = TextEditingController();
AppointmentRateViewModel appointmentRateViewModel = locator<AppointmentRateViewModel>(); AppointmentRateViewModel appointmentRateViewModel = locator<AppointmentRateViewModel>();
final FocusNode myFocusNode = FocusNode();
Country selectedCountry = Country.saudiArabia; Country selectedCountry = Country.saudiArabia;
OTPType? otpType; OTPType? otpType;
bool isTermsAccepted = false; bool isTermsAccepted = false;
@ -324,7 +324,8 @@ class _RegisterNew extends State<RegisterNew> {
// Utils.showErrorToast(TranslationBase.of(context).pleaseEnterNationalId); // Utils.showErrorToast(TranslationBase.of(context).pleaseEnterNationalId);
return; return;
} }
if (nationalIDorFile != null && !Utils.validateIqama(nationalIDorFile.text)) { if ((!Utils.validateIqama(nationalIDorFile.text) && selectedCountry.countryCode == '966') ||
(!Utils.validateUaeNationalId(nationalIDorFile.text) && selectedCountry.countryCode == '971')) {
context.showBottomSheet( context.showBottomSheet(
child: ExceptionBottomSheet( child: ExceptionBottomSheet(
message: "Please enter correct national id", message: "Please enter correct national id",
@ -401,7 +402,18 @@ class _RegisterNew extends State<RegisterNew> {
if (mobileNo.isEmpty) { if (mobileNo.isEmpty) {
context.showBottomSheet( context.showBottomSheet(
child: ExceptionBottomSheet( child: ExceptionBottomSheet(
message: "Please enter mobile number", message: TranslationBase.of(context).pleaseEnterMobile,
showCancel: false,
onOkPressed: () {
Navigator.of(context).pop();
},
),
);
}
else if (!Utils.validateMobileNumber(mobileNo)) {
context.showBottomSheet(
child: ExceptionBottomSheet(
message: TranslationBase.of(context).pleaseEnterValidMobile,
showCancel: false, showCancel: false,
onOkPressed: () { onOkPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
@ -409,19 +421,6 @@ class _RegisterNew extends State<RegisterNew> {
), ),
); );
} }
//
// else if (mobileNo.length < 8) {
// context.showBottomSheet(
// child: ExceptionBottomSheet(
// message: "Please enter correct mobile number",
// showCancel: false,
// onOkPressed: () {
// Navigator.of(context).pop();
// },
// ),
// );
// }
else { else {
registerUser(1); registerUser(1);
} }
@ -456,17 +455,17 @@ class _RegisterNew extends State<RegisterNew> {
if (mobileNo.isEmpty) { if (mobileNo.isEmpty) {
context.showBottomSheet( context.showBottomSheet(
child: ExceptionBottomSheet( child: ExceptionBottomSheet(
message: "Please enter mobile number", message: TranslationBase.of(context).pleaseEnterMobile,
showCancel: false, showCancel: false,
onOkPressed: () { onOkPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
); );
} else if (mobileNo.length < 9) { } else if (!Utils.validateMobileNumber(mobileNo)) {
context.showBottomSheet( context.showBottomSheet(
child: ExceptionBottomSheet( child: ExceptionBottomSheet(
message: "Please enter correct mobile number", message: TranslationBase.of(context).pleaseEnterValidMobile,
showCancel: false, showCancel: false,
onOkPressed: () { onOkPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
@ -485,11 +484,14 @@ class _RegisterNew extends State<RegisterNew> {
icon: "assets/images/svg/whatsapp.svg", icon: "assets/images/svg/whatsapp.svg",
), ),
), ),
], ], myFocusNode:myFocusNode,
), ),
), ),
), ),
); );
Future.delayed(Duration(milliseconds: 500), () {
myFocusNode.requestFocus();
});
}, },
fontFamily: context.fontFamily, fontFamily: context.fontFamily,
), ),

@ -57,7 +57,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
late ProjectViewModel projectViewModel; late ProjectViewModel projectViewModel;
bool isFromDubai = false; bool isFromDubai = false;
List<NationalityCountries> countriesList = []; List<NationalityCountries> countriesList = [];
final FocusNode myFocusNode = FocusNode();
// TextEditingController nationality = TextEditingController(); // TextEditingController nationality = TextEditingController();
String? name, nationalId; String? name, nationalId;
@ -336,6 +336,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
backgroundColor: Color(0xFFFEE9EA), backgroundColor: Color(0xFFFEE9EA),
borderColor: Color(0xFFFEE9EA), borderColor: Color(0xFFFEE9EA),
textColor: Color(0xFFED1C2B), textColor: Color(0xFFED1C2B),
iconColor: Color(0xFFED1C2B),
), ),
), ),
SizedBox( SizedBox(
@ -343,10 +344,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
), ),
Expanded( Expanded(
child: CustomButton( child: CustomButton(
backgroundColor: Color(0xFF18C273), backgroundColor: Color(0xFFccedde),
borderColor: Color(0xFF18C273), borderColor: Color(0xFFccedde),
textColor: Color(0xFF18C273),
text: TranslationBase.of(context).confirm, text: TranslationBase.of(context).confirm,
icon: "assets/images/svg/confirm.svg", icon: "assets/images/svg/confirm.svg",
iconColor: Color(0xFF18C273),
onPressed: () { onPressed: () {
if (isFromDubai) { if (isFromDubai) {
if (name == null) { if (name == null) {
@ -396,11 +399,14 @@ class _RegisterNew extends State<RegisterNewStep2> {
borderColor: Color(0xFF18C273), borderColor: Color(0xFF18C273),
textColor: Colors.white), textColor: Colors.white),
), ),
], ], myFocusNode: myFocusNode,
), ),
), ),
), ),
); );
Future.delayed(Duration(milliseconds: 500), () {
myFocusNode.requestFocus();
});
}, },
fontFamily: context.fontFamily, fontFamily: context.fontFamily,
), ),

@ -54,7 +54,7 @@ class _SavedLogin extends State<SavedLogin> {
TextEditingController? phoneController; TextEditingController? phoneController;
final authService = AuthProvider(); final authService = AuthProvider();
late ProjectViewModel projectViewModel; late ProjectViewModel projectViewModel;
final FocusNode myFocusNode = FocusNode();
late ToDoCountProviderModel toDoProvider; late ToDoCountProviderModel toDoProvider;
Country selectedCountry = Country.saudiArabia; Country selectedCountry = Country.saudiArabia;
@ -295,12 +295,15 @@ class _SavedLogin extends State<SavedLogin> {
icon: "assets/images/svg/whatsapp.svg", icon: "assets/images/svg/whatsapp.svg",
), ),
), ),
], ], myFocusNode: myFocusNode,
), ),
), ),
); );
}), }),
); );
Future.delayed(Duration(milliseconds: 500), () {
myFocusNode.requestFocus();
});
}, },
backgroundColor: Colors.white, backgroundColor: Colors.white,
borderColor: Color(0xFF2E3039), borderColor: Color(0xFF2E3039),

@ -77,6 +77,7 @@ class _WelcomeLogin extends State<WelcomeLogin> {
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>(); AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
AppointmentRateViewModel appointmentRateViewModel = locator<AppointmentRateViewModel>(); AppointmentRateViewModel appointmentRateViewModel = locator<AppointmentRateViewModel>();
late ProjectViewModel projectViewModel; late ProjectViewModel projectViewModel;
final FocusNode myFocusNode = FocusNode();
late ToDoCountProviderModel toDoProvider; late ToDoCountProviderModel toDoProvider;
@ -189,6 +190,7 @@ class _WelcomeLogin extends State<WelcomeLogin> {
text: TranslationBase.of(context).login, text: TranslationBase.of(context).login,
icon: "assets/images/svg/login1.svg", icon: "assets/images/svg/login1.svg",
onPressed: () { onPressed: () {
if (nationIdController.text.isNotEmpty) { if (nationIdController.text.isNotEmpty) {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
@ -199,6 +201,7 @@ class _WelcomeLogin extends State<WelcomeLogin> {
enableDrag: false, enableDrag: false,
// Prevent dragging to avoid focus conflicts // Prevent dragging to avoid focus conflicts
builder: (bottomSheetContext) => StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) { builder: (bottomSheetContext) => StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) {
return Padding( return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom),
child: SingleChildScrollView( child: SingleChildScrollView(
@ -258,16 +261,19 @@ class _WelcomeLogin extends State<WelcomeLogin> {
icon: "assets/images/svg/whatsapp.svg", icon: "assets/images/svg/whatsapp.svg",
), ),
), ),
], ], myFocusNode: myFocusNode,
), ),
), ),
); );
}), }),
); );
Future.delayed(Duration(milliseconds: 500), () {
myFocusNode.requestFocus();
});
} else { } else {
context.showBottomSheet( context.showBottomSheet(
child: ExceptionBottomSheet( child: ExceptionBottomSheet(
message: "Please enter National id or File no", message: TranslationBase.of(context).pleaseEnterNationalIdOrFileNo,
showCancel: false, showCancel: false,
onOkPressed: () { onOkPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();

@ -3512,6 +3512,10 @@ class TranslationBase {
String get notice => localizedValues["notice"][locale.languageCode]; String get notice => localizedValues["notice"][locale.languageCode];
String get receiveOtpToast => localizedValues["receiveOtpToast"][locale.languageCode]; String get receiveOtpToast => localizedValues["receiveOtpToast"][locale.languageCode];
String get pleaseChooseOption => localizedValues["pleaseChooseOption"][locale.languageCode]; String get pleaseChooseOption => localizedValues["pleaseChooseOption"][locale.languageCode];
String get pleaseEnterMobile => localizedValues["pleaseEnterMobile"][locale.languageCode];
String get pleaseEnterValidMobile => localizedValues["pleaseEnterValidMobile"][locale.languageCode];
String get pleaseEnterNationalIdOrFileNo => localizedValues["pleaseEnterNationalIdOrFileNo"][locale.languageCode];
String get readMore => localizedValues["readMore"][locale.languageCode]; String get readMore => localizedValues["readMore"][locale.languageCode];
String get showLess => localizedValues["showLess"][locale.languageCode]; String get showLess => localizedValues["showLess"][locale.languageCode];

@ -82,15 +82,26 @@ enum MaritalStatusType { single, married, divorced, widowed }
class Utils { class Utils {
static int? onOtpBtnPressed(OTPType type, String? phoneNumber, BuildContext context) { static int? onOtpBtnPressed(OTPType type, String? phoneNumber, BuildContext context) {
if (phoneNumber == null || phoneNumber.isEmpty || phoneNumber.length < 9) { if (phoneNumber == null || phoneNumber.isEmpty) {
context.showBottomSheet( context.showBottomSheet(
child: ExceptionBottomSheet( child: ExceptionBottomSheet(
message: "Please enter your phone number.", message: TranslationBase.of(context).pleaseEnterMobile,
onOkPressed: () { onOkPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
)); ));
return null; return null;
} else if (!Utils.validateMobileNumber(phoneNumber)) {
context.showBottomSheet(
child: ExceptionBottomSheet(
message: TranslationBase.of(context).pleaseEnterValidMobile,
showCancel: false,
onOkPressed: () {
Navigator.of(context).pop();
},
),
);
return null;
} }
return type == OTPType.sms ? 1 : 4; return type == OTPType.sms ? 1 : 4;
} }
@ -114,6 +125,17 @@ class Utils {
return sum % 10 == 0; return sum % 10 == 0;
} }
static bool validateUaeNationalId(String id) {
// Must be exactly 15 digits
final regex = RegExp(r'^784\d{4}\d{7}\d{1}$');
return regex.hasMatch(id);
}
static bool validateMobileNumber(String number) {
final regex = RegExp(r'^(05\d{8}|5\d{8})$');
return regex.hasMatch(number);
}
static void changeAppLanguage({required BuildContext context}) { static void changeAppLanguage({required BuildContext context}) {
sharedPref.setBool(IS_ROBOT_INIT, false); sharedPref.setBool(IS_ROBOT_INIT, false);
sharedPref.remove(CLINICS_LIST); sharedPref.remove(CLINICS_LIST);

Loading…
Cancel
Save