login fixes

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

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

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

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

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

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

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

@ -3512,6 +3512,10 @@ class TranslationBase {
String get notice => localizedValues["notice"][locale.languageCode];
String get receiveOtpToast => localizedValues["receiveOtpToast"][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 showLess => localizedValues["showLess"][locale.languageCode];

@ -82,15 +82,26 @@ enum MaritalStatusType { single, married, divorced, widowed }
class Utils {
static int? onOtpBtnPressed(OTPType type, String? phoneNumber, BuildContext context) {
if (phoneNumber == null || phoneNumber.isEmpty || phoneNumber.length < 9) {
if (phoneNumber == null || phoneNumber.isEmpty) {
context.showBottomSheet(
child: ExceptionBottomSheet(
message: "Please enter your phone number.",
message: TranslationBase.of(context).pleaseEnterMobile,
onOkPressed: () {
Navigator.of(context).pop();
},
));
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;
}
@ -114,6 +125,17 @@ class Utils {
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}) {
sharedPref.setBool(IS_ROBOT_INIT, false);
sharedPref.remove(CLINICS_LIST);

Loading…
Cancel
Save