otp screen & register Uae & resend Activation Code.

pull/45/head
aamir-csol 1 month ago
parent 9d852aa281
commit 15c07cb4e2

@ -817,5 +817,6 @@
"news": "أخبار", "news": "أخبار",
"ready": "جاهز", "ready": "جاهز",
"enterValidNationalId": "الرجاء إدخال رقم الهوية الوطنية أو رقم الملف الصحيح", "enterValidNationalId": "الرجاء إدخال رقم الهوية الوطنية أو رقم الملف الصحيح",
"enterValidPhoneNumber": "الرجاء إدخال رقم هاتف صالح" "enterValidPhoneNumber": "الرجاء إدخال رقم هاتف صالح",
"iAcceptThe" : "أوافق على"
} }

@ -813,5 +813,6 @@
"enterValidNationalId": "Please enter a valid national ID or file number", "enterValidNationalId": "Please enter a valid national ID or file number",
"enterValidPhoneNumber": "Please enter a valid phone number", "enterValidPhoneNumber": "Please enter a valid phone number",
"ready": "Ready", "ready": "Ready",
"news": "News" "news": "News",
"iAcceptThe" : "I Accept the"
} }

@ -726,7 +726,7 @@ const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_In
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; static const maxSmallScreen = 660;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat;
// static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -62,7 +62,7 @@ class AppState {
SelectDeviceByImeiRespModelElement? _selectDeviceByImeiRespModelElement; SelectDeviceByImeiRespModelElement? _selectDeviceByImeiRespModelElement;
void setSelectDeviceByImeiRespModelElement(SelectDeviceByImeiRespModelElement value) { void setSelectDeviceByImeiRespModelElement(SelectDeviceByImeiRespModelElement? value) {
_selectDeviceByImeiRespModelElement = value; _selectDeviceByImeiRespModelElement = value;
} }

@ -48,6 +48,7 @@ class AuthenticationViewModel extends ChangeNotifier {
final DialogService _dialogService; final DialogService _dialogService;
final NavigationService _navigationService; final NavigationService _navigationService;
final LocalAuthService _localAuthService; final LocalAuthService _localAuthService;
AuthenticationViewModel({ AuthenticationViewModel({
required AppState appState, required AppState appState,
required AuthenticationRepo authenticationRepo, required AuthenticationRepo authenticationRepo,
@ -79,6 +80,8 @@ class AuthenticationViewModel extends ChangeNotifier {
CalenderEnum calenderType = CalenderEnum.gregorian; CalenderEnum calenderType = CalenderEnum.gregorian;
LoginTypeEnum loginTypeEnum = LoginTypeEnum.sms; LoginTypeEnum loginTypeEnum = LoginTypeEnum.sms;
final ValueNotifier<bool> otpScreenNotifier = ValueNotifier<bool>(false);
//================== //==================
String errorMsg = ''; String errorMsg = '';
@ -106,7 +109,6 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
Future<void> clearDefaultInputValues() async { Future<void> clearDefaultInputValues() async {
nationalIdController.clear(); nationalIdController.clear();
phoneNumberController.clear(); phoneNumberController.clear();
emailController.clear(); emailController.clear();
@ -394,12 +396,8 @@ class AuthenticationViewModel extends ChangeNotifier {
return isUserComingForRegister; return isUserComingForRegister;
} }
Future<void> checkActivationCode({ Future<void> checkActivationCode(
required String? activationCode, {required String? activationCode, required OTPTypeEnum otpTypeEnum, required Function(String? message) onWrongActivationCode, Function()? onResendActivation}) async {
required OTPTypeEnum otpTypeEnum,
required Function(String? message) onWrongActivationCode,
Function()? onResendActivation,
}) async {
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1); bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1);
final request = RequestUtils.getCommonRequestWelcome( final request = RequestUtils.getCommonRequestWelcome(
@ -422,6 +420,7 @@ class AuthenticationViewModel extends ChangeNotifier {
countryCode: _appState.getSelectDeviceByImeiRespModelElement != null && _appState.getSelectDeviceByImeiRespModelElement!.outSa == true countryCode: _appState.getSelectDeviceByImeiRespModelElement != null && _appState.getSelectDeviceByImeiRespModelElement!.outSa == true
? CountryEnum.unitedArabEmirates.countryCode ? CountryEnum.unitedArabEmirates.countryCode
: selectedCountrySignup.countryCode, : selectedCountrySignup.countryCode,
//TODO: Error Here IN Zip Code.
loginType: loginTypeEnum.toInt) loginType: loginTypeEnum.toInt)
.toJson(); .toJson();
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
@ -469,6 +468,7 @@ class AuthenticationViewModel extends ChangeNotifier {
failure: failure, failure: failure,
onUnHandledFailure: (failure) async { onUnHandledFailure: (failure) async {
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
otpScreenNotifier.value = true;
await _dialogService.showCommonBottomSheetWithoutH(message: failure.message, label: LocaleKeys.notice.tr(), onOkPressed: () {}); await _dialogService.showCommonBottomSheetWithoutH(message: failure.message, label: LocaleKeys.notice.tr(), onOkPressed: () {});
}, },
onMessageStatusFailure: (failure) async { onMessageStatusFailure: (failure) async {
@ -595,6 +595,7 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
Future<void> onWrongActivationCode({String? message}) async { Future<void> onWrongActivationCode({String? message}) async {
otpScreenNotifier.value = true;
await _dialogService.showErrorBottomSheet(message: message ?? "Something went wrong. ", onOkPressed: () {}); await _dialogService.showErrorBottomSheet(message: message ?? "Something went wrong. ", onOkPressed: () {});
} }
@ -622,19 +623,20 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
checkLastLoginStatus(Function() onSuccess) async { checkLastLoginStatus(Function() onSuccess) async {
Future.delayed(Duration(seconds: 1), () async { Future.delayed(Duration(seconds: 1), () async {
if(cacheService.getBool(key: CacheConst.quickLoginEnabled) == null){ if (cacheService.getBool(key: CacheConst.quickLoginEnabled) == null) {
if (_appState.getSelectDeviceByImeiRespModelElement != null && if (_appState.getSelectDeviceByImeiRespModelElement != null &&
(_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) { (_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) {
phoneNumberController.text = phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
(_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
: _appState.getAuthenticatedUser()!.mobileNumber)!;
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!; nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
onSuccess(); onSuccess();
} else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) && } else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) &&
_appState.getAuthenticatedUser() != null) { _appState.getAuthenticatedUser() != null) {
phoneNumberController.text = phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
(_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
: _appState.getAuthenticatedUser()!.mobileNumber)!;
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!; nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
onSuccess(); onSuccess();
} }
@ -921,4 +923,6 @@ class AuthenticationViewModel extends ChangeNotifier {
}, },
); );
} }
// === OTP Widget Logics ===//
} }

@ -7,8 +7,10 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart'; import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart';
import 'package:provider/provider.dart';
typedef OnDone = void Function(String text); typedef OnDone = void Function(String text);
@ -90,6 +92,7 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
int currentIndex = 0; int currentIndex = 0;
List<String> strList = []; List<String> strList = [];
bool hasFocus = false; bool hasFocus = false;
AuthenticationViewModel? authVm;
@override @override
void didUpdateWidget(OTPWidget oldWidget) { void didUpdateWidget(OTPWidget oldWidget) {
@ -124,6 +127,7 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
@override @override
void initState() { void initState() {
super.initState(); super.initState();
authVm = context.read<AuthenticationViewModel>();
focusNode = widget.focusNode ?? FocusNode(); focusNode = widget.focusNode ?? FocusNode();
_highlightAnimationController = AnimationController(vsync: this); _highlightAnimationController = AnimationController(vsync: this);
_initTextController(); _initTextController();
@ -132,12 +136,15 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
widget.controller!.addListener(_controllerListener); widget.controller!.addListener(_controllerListener);
} }
focusNode.addListener(_focusListener); focusNode.addListener(_focusListener);
authVm?.otpScreenNotifier.addListener(_onOtpScreenNotifierChanged);
} }
void _controllerListener() { void _controllerListener() {
if (mounted == true) { if (mounted == true) {
setState(() { setState(() {
_initTextController(); _initTextController();
text = widget.controller?.text ?? "";
currentIndex = text.length;
}); });
var onTextChanged = widget.onTextChanged; var onTextChanged = widget.onTextChanged;
if (onTextChanged != null) { if (onTextChanged != null) {
@ -154,6 +161,41 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
} }
} }
void onWrongOtpClear() {
if (mounted) {
setState(() {
text = "";
currentIndex = 0;
strList.clear();
_calculateStrList();
});
// Clear the controller if it exists
if (widget.controller != null) {
widget.controller!.clear();
}
// Remove focus from the input
if (focusNode.hasFocus) {
focusNode.unfocus();
}
// Optionally refocus after a short delay to allow user to re-enter OTP
Future.delayed(const Duration(milliseconds: 100), () {
if (mounted && widget.autoFocus) {
FocusScope.of(context).requestFocus(focusNode);
}
});
}
}
void _onOtpScreenNotifierChanged() {
if (authVm?.otpScreenNotifier.value == true) {
onWrongOtpClear();
authVm?.otpScreenNotifier.value = false;
}
}
void _initTextController() { void _initTextController() {
if (widget.controller == null) { if (widget.controller == null) {
return; return;
@ -304,19 +346,17 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
); );
} }
Widget _buildPinCode(int i, BuildContext context) { Widget _buildPinCode(int i, BuildContext context) {
Color pinBoxColor; Color pinBoxColor;
if (widget.hasError) { if (widget.hasError) {
pinBoxColor = widget.errorBorderColor; pinBoxColor = widget.errorBorderColor;
} else if (text.length == widget.maxLength) { } else if (text.length == widget.maxLength) {
// Check for completion first, before individual box logic
pinBoxColor = AppColors.successColor; pinBoxColor = AppColors.successColor;
} else if (i < text.length) { } else if (i < text.length) {
pinBoxColor = AppColors.blackBgColor; // Custom color for filled boxes pinBoxColor = AppColors.blackBgColor;
} else { } else {
pinBoxColor = widget.pinBoxColor; // Default white color pinBoxColor = widget.pinBoxColor;
} }
EdgeInsets insets; EdgeInsets insets;
@ -355,7 +395,6 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
); );
} }
// Widget _buildPinCode(int i, BuildContext context) { // Widget _buildPinCode(int i, BuildContext context) {
// Color pinBoxColor = widget.pinBoxColor; // Color pinBoxColor = widget.pinBoxColor;
// //
@ -455,7 +494,7 @@ class _OTPVerificationScreenState extends State<OTPVerificationScreen> {
Timer? _resendTimer; Timer? _resendTimer;
int _resendTime = 120; int _resendTime = 120;
bool _isOtpComplete = false; bool _isOtpComplete = false;
bool _isVerifying = false; // Flag to prevent multiple verification calls bool _isVerifying = false;
@override @override
void initState() { void initState() {
@ -504,11 +543,18 @@ class _OTPVerificationScreenState extends State<OTPVerificationScreen> {
}); });
_otpController.clear(); _otpController.clear();
_startResendTimer(); _startResendTimer();
// autoFillOtp("1234");
widget.onResendOTPPressed(widget.phoneNumber); widget.onResendOTPPressed(widget.phoneNumber);
} }
} }
void _clearOtpAndResetState() {
setState(() {
_isVerifying = false;
_isOtpComplete = false;
});
_otpController.clear();
}
String _getMaskedPhoneNumber() { String _getMaskedPhoneNumber() {
final phone = widget.phoneNumber; final phone = widget.phoneNumber;
return phone.length > 4 ? '05xxxxxx${phone.substring(phone.length - 2)}' : phone; return phone.length > 4 ? '05xxxxxx${phone.substring(phone.length - 2)}' : phone;

@ -812,9 +812,10 @@ abstract class LocaleKeys {
static const notNow = 'notNow'; static const notNow = 'notNow';
static const pendingActivation = 'pendingActivation'; static const pendingActivation = 'pendingActivation';
static const awaitingApproval = 'awaitingApproval'; static const awaitingApproval = 'awaitingApproval';
static const news = 'news';
static const ready = 'ready'; static const ready = 'ready';
static const enterValidNationalId = 'enterValidNationalId'; static const enterValidNationalId = 'enterValidNationalId';
static const enterValidPhoneNumber = 'enterValidPhoneNumber'; static const enterValidPhoneNumber = 'enterValidPhoneNumber';
static const iAcceptThe = 'iAcceptThe';
static const news = 'news';
} }

@ -4,6 +4,8 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
@ -153,6 +155,7 @@ class LoginScreenState extends State<LoginScreen> {
required TextEditingController? phoneNumberController, required TextEditingController? phoneNumberController,
required AuthenticationViewModel authViewModel, required AuthenticationViewModel authViewModel,
}) { }) {
AppState appState = getIt<AppState>();
context.showBottomSheet( context.showBottomSheet(
isScrollControlled: true, isScrollControlled: true,
isDismissible: false, isDismissible: false,
@ -180,6 +183,8 @@ class LoginScreenState extends State<LoginScreen> {
onOkPress: () { onOkPress: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
})) { })) {
Navigator.of(context).pop();
appState.setSelectDeviceByImeiRespModelElement(null);
await authViewModel.checkUserAuthentication(otpTypeEnum: OTPTypeEnum.sms); await authViewModel.checkUserAuthentication(otpTypeEnum: OTPTypeEnum.sms);
} }
}, },
@ -209,6 +214,8 @@ class LoginScreenState extends State<LoginScreen> {
onOkPress: () { onOkPress: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
})) { })) {
Navigator.of(context).pop();
appState.setSelectDeviceByImeiRespModelElement(null);
await authViewModel.checkUserAuthentication(otpTypeEnum: OTPTypeEnum.whatsapp); await authViewModel.checkUserAuthentication(otpTypeEnum: OTPTypeEnum.whatsapp);
} }
}, },

@ -2,6 +2,8 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
@ -152,12 +154,36 @@ class _RegisterNew extends State<RegisterNew> {
}, },
), ),
SizedBox(width: 12.h), SizedBox(width: 12.h),
Expanded( Row(
child: Text( children: [
LocaleKeys.iAcceptTermsConditions.tr(), Text(
style: context.dynamicTextStyle(fontSize: 14.fSize, fontWeight: FontWeight.w500, color: Color(0xFF2E3039)), LocaleKeys.iAcceptThe.tr(),
), style: context.dynamicTextStyle(fontSize: 14.fSize, fontWeight: FontWeight.w500, color: Color(0xFF2E3039)),
),
GestureDetector(
onTap: () {
// Navigate to terms and conditions page
Navigator.of(context).pushNamed('/terms');
},
child: Text(
LocaleKeys.termsConditoins.tr(),
style: context.dynamicTextStyle(
fontSize: 14.fSize,
fontWeight: FontWeight.w500,
color: AppColors.primaryRedColor,
decoration: TextDecoration.underline,
decorationColor: AppColors.primaryRedBorderColor,
),
),
),
],
), ),
// Expanded(
// child: Text(
// LocaleKeys.iAcceptTermsConditions.tr().split("the").first,
// style: context.dynamicTextStyle(fontSize: 14.fSize, fontWeight: FontWeight.w500, color: Color(0xFF2E3039)),
// ),
// ),
], ],
), ),
), ),
@ -224,6 +250,7 @@ class _RegisterNew extends State<RegisterNew> {
} }
void showRegisterModel({required BuildContext context, required AuthenticationViewModel authVM}) { void showRegisterModel({required BuildContext context, required AuthenticationViewModel authVM}) {
AppState appState = getIt.get<AppState>();
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
@ -235,7 +262,7 @@ class _RegisterNew extends State<RegisterNew> {
child: SingleChildScrollView( child: SingleChildScrollView(
child: GenericBottomSheet( child: GenericBottomSheet(
countryCode: authVM.selectedCountrySignup.countryCode, countryCode: authVM.selectedCountrySignup.countryCode,
initialPhoneNumber: "", initialPhoneNumber: authVM.phoneNumberController.text,
textController: authVM.phoneNumberController, textController: authVM.phoneNumberController,
isEnableCountryDropdown: false, isEnableCountryDropdown: false,
onCountryChange: authVM.onCountryChange, onCountryChange: authVM.onCountryChange,
@ -256,6 +283,7 @@ class _RegisterNew extends State<RegisterNew> {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
)) { )) {
appState.setSelectDeviceByImeiRespModelElement(null);
await authVM.onRegistrationStart(otpTypeEnum: OTPTypeEnum.sms); await authVM.onRegistrationStart(otpTypeEnum: OTPTypeEnum.sms);
} }
}, },
@ -280,15 +308,14 @@ class _RegisterNew extends State<RegisterNew> {
child: CustomButton( child: CustomButton(
text: LocaleKeys.sendOTPWHATSAPP.tr(), text: LocaleKeys.sendOTPWHATSAPP.tr(),
onPressed: () async { onPressed: () async {
// Dismiss keyboard before validation
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
if (ValidationUtils.isValidatePhone( if (ValidationUtils.isValidatePhone(
phoneNumber: authVM.phoneNumberController.text, phoneNumber: authVM.phoneNumberController.text,
onOkPress: () { onOkPress: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
)) { )) {
appState.setSelectDeviceByImeiRespModelElement(null);
await authVM.onRegistrationStart(otpTypeEnum: OTPTypeEnum.whatsapp); await authVM.onRegistrationStart(otpTypeEnum: OTPTypeEnum.whatsapp);
} }
}, },
@ -296,6 +323,7 @@ class _RegisterNew extends State<RegisterNew> {
borderColor: AppColors.borderOnlyColor, borderColor: AppColors.borderOnlyColor,
textColor: AppColors.textColor, textColor: AppColors.textColor,
icon: AppAssets.whatsapp, icon: AppAssets.whatsapp,
iconColor: null,
), ),
), ),
], ],

@ -12,6 +12,8 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/authentication/login.dart'; import 'package:hmg_patient_app_new/presentation/authentication/login.dart';
import 'package:hmg_patient_app_new/presentation/home/landing_page.dart';
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart'; import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart';
import 'package:hmg_patient_app_new/widgets/bottomsheet/generic_bottom_sheet.dart'; import 'package:hmg_patient_app_new/widgets/bottomsheet/generic_bottom_sheet.dart';
@ -164,17 +166,16 @@ class _SavedLogin extends State<SavedLogin> {
Padding( Padding(
padding: EdgeInsets.only(bottom: 10.h), padding: EdgeInsets.only(bottom: 10.h),
child: CustomButton( child: CustomButton(
text: LocaleKeys.sendOTPSMS.tr(), text: LocaleKeys.sendOTPSMS.tr(),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
loginType = LoginTypeEnum.sms; loginType = LoginTypeEnum.sms;
authVm.checkUserAuthentication(otpTypeEnum: OTPTypeEnum.sms); authVm.checkUserAuthentication(otpTypeEnum: OTPTypeEnum.sms);
}, },
backgroundColor: AppColors.primaryRedColor, backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedBorderColor, borderColor: AppColors.primaryRedColor,
textColor: AppColors.whiteColor, textColor: AppColors.whiteColor,
icon: AppAssets.sms, icon: AppAssets.sms),
),
), ),
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -247,13 +248,13 @@ class _SavedLogin extends State<SavedLogin> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
child: Container( child: SizedBox(
height: 56, height: 56,
child: CustomButton( child: CustomButton(
text: LocaleKeys.guest.tr(), text: LocaleKeys.guest.tr(),
onPressed: () { onPressed: () {
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (BuildContext context) => LoginScreen()), MaterialPageRoute(builder: (BuildContext context) => LandingNavigation()),
); );
}, },
backgroundColor: Color(0xffFEE9EA), backgroundColor: Color(0xffFEE9EA),
@ -277,7 +278,7 @@ class _SavedLogin extends State<SavedLogin> {
text: LocaleKeys.switchAccount.tr(), text: LocaleKeys.switchAccount.tr(),
onPressed: () async { onPressed: () async {
await authVm.clearDefaultInputValues(); await authVm.clearDefaultInputValues();
Navigator.of(context).pushReplacement( Navigator.of(context).push(
MaterialPageRoute(builder: (BuildContext context) => LoginScreen()), MaterialPageRoute(builder: (BuildContext context) => LoginScreen()),
); );
}, },

@ -22,19 +22,9 @@ class NavigationService {
navigatorKey.currentState?.pushReplacementNamed(routeName); navigatorKey.currentState?.pushReplacementNamed(routeName);
} }
Future<T?> pushToOtpScreen<T>({ Future<T?> pushToOtpScreen<T>({required String phoneNumber, required Function(int code) checkActivationCode, required Function(String phoneNumber) onResendOTPPressed}) {
required String phoneNumber,
required Function(int code) checkActivationCode,
required Function(String phoneNumber) onResendOTPPressed,
}) {
return navigatorKey.currentState!.push( return navigatorKey.currentState!.push(
MaterialPageRoute( MaterialPageRoute(builder: (_) => OTPVerificationScreen(phoneNumber: phoneNumber, checkActivationCode: checkActivationCode, onResendOTPPressed: onResendOTPPressed)),
builder: (_) => OTPVerificationScreen(
phoneNumber: phoneNumber,
checkActivationCode: checkActivationCode,
onResendOTPPressed: onResendOTPPressed,
),
),
); );
} }

Loading…
Cancel
Save