diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index 6022dceb..d6afa270 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -23,6 +23,7 @@ import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; import 'package:doctor_app_flutter/models/doctor/user_model.dart'; +import 'package:doctor_app_flutter/root_page.dart'; import 'package:doctor_app_flutter/screens/auth/login_screen.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -77,6 +78,7 @@ class AuthenticationViewModel extends BaseViewModel { getDoctorProfile(); } + /// select Device IMEI Future selectDeviceImei(imei) async { setState(ViewState.Busy); await _authService.selectDeviceImei(imei); @@ -87,6 +89,7 @@ class AuthenticationViewModel extends BaseViewModel { setState(ViewState.Idle); } + /// Insert Device IMEI Future insertDeviceImei() async { var loggedIn = await sharedPref.getObj(LOGGED_IN_USER); var user = await sharedPref.getObj(LAST_LOGIN_USER); @@ -125,6 +128,8 @@ class AuthenticationViewModel extends BaseViewModel { setState(ViewState.Idle); } + + /// first step login Future login(UserModel userInfo) async { setState(ViewState.BusyLocal); await _authService.login(userInfo); @@ -141,6 +146,7 @@ class AuthenticationViewModel extends BaseViewModel { } } + /// send activation code for for msg methods Future sendActivationCodeVerificationScreen( AuthMethodTypes authMethodType) async { setState(ViewState.BusyLocal); ActivationCodeForVerificationScreenModel activationCodeModel = @@ -162,6 +168,7 @@ class AuthenticationViewModel extends BaseViewModel { setState(ViewState.Idle); } + /// send activation code for silent login Future sendActivationCodeForDoctorApp({AuthMethodTypes authMethodType, String password }) async { setState(ViewState.BusyLocal); int projectID = await sharedPref.getInt(PROJECT_ID); @@ -180,6 +187,8 @@ class AuthenticationViewModel extends BaseViewModel { setState(ViewState.Idle); } + + /// check activation Future checkActivationCodeForDoctorApp({String activationCode}) async { setState(ViewState.BusyLocal); CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = @@ -204,7 +213,7 @@ class AuthenticationViewModel extends BaseViewModel { } } - + /// get list of Hospitals Future getHospitalsList(memberID) async { GetHospitalsRequestModel getHospitalsRequestModel =GetHospitalsRequestModel(); getHospitalsRequestModel.memberID = memberID; @@ -216,6 +225,8 @@ class AuthenticationViewModel extends BaseViewModel { setState(ViewState.Idle); } + + /// get type name based on id. getType(type, context) { switch (type) { case 1: @@ -242,7 +253,8 @@ class AuthenticationViewModel extends BaseViewModel { } } - setDataAfterSendActivationSuccsess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) { + /// add some logic in case of send activation code is success + setDataAfterSendActivationSuccess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) { print("VerificationCode : " + sendActivationCodeForDoctorAppResponseModel.verificationCode); sharedPref.setString(VIDA_AUTH_TOKEN_ID, @@ -257,6 +269,7 @@ class AuthenticationViewModel extends BaseViewModel { sharedPref.setObj(key, value); } + /// ask user to add his biometric showIOSAuthMessages() async { const iosStrings = const IOSAuthMessages( cancelButton: 'cancel', @@ -275,10 +288,12 @@ class AuthenticationViewModel extends BaseViewModel { } } + /// add profile to base view model super class localSetDoctorProfile(DoctorProfileModel profile) { super.setDoctorProfile(profile); } + /// get doctor profile based on clinic model Future getDoctorProfileBasedOnClinic(ClinicModel clinicInfo) async { ProfileReqModel docInfo = new ProfileReqModel( doctorID: clinicInfo.doctorID, @@ -297,6 +312,7 @@ class AuthenticationViewModel extends BaseViewModel { } } + /// add some logic in case of check activation code is success onCheckActivationCodeSuccess() async { sharedPref.setString( TOKEN, @@ -317,6 +333,7 @@ class AuthenticationViewModel extends BaseViewModel { } } + /// check specific biometric if it available or not Future checkIfBiometricAvailable(BiometricType biometricType) async { bool isAvailable = false; await _getAvailableBiometrics(); @@ -328,6 +345,7 @@ class AuthenticationViewModel extends BaseViewModel { return isAvailable; } + /// get all available biometric on the device for local Auth service Future _getAvailableBiometrics() async { try { _availableBiometrics = await auth.getAvailableBiometrics(); @@ -336,7 +354,7 @@ class AuthenticationViewModel extends BaseViewModel { } } - + /// call firebase service to check if the user already login in before or not getDeviceInfoFromFirebase() async { _firebaseMessaging.setAutoInitEnabled(true); if (Platform.isIOS) { @@ -367,7 +385,7 @@ class AuthenticationViewModel extends BaseViewModel { }); } - + /// determine the status of the app APP_STATUS get status { if (state == ViewState.Busy) { return APP_STATUS.LOADING; @@ -382,7 +400,7 @@ class AuthenticationViewModel extends BaseViewModel { } } - + /// logout function logout() async { DEVICE_TOKEN = ""; String lang = await sharedPref.getString(APP_Language); @@ -392,7 +410,7 @@ class AuthenticationViewModel extends BaseViewModel { Navigator.pushAndRemoveUntil( AppGlobal.CONTEX, FadePage( - page: LoginScreen(), + page: RootPage(), ), (r) => false); } diff --git a/lib/screens/auth/verification_methods_screen.dart b/lib/screens/auth/verification_methods_screen.dart index afd5604c..1e61d553 100644 --- a/lib/screens/auth/verification_methods_screen.dart +++ b/lib/screens/auth/verification_methods_screen.dart @@ -1,5 +1,6 @@ import 'dart:io' show Platform; +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/enum/auth_method_types.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; @@ -20,10 +21,12 @@ import 'package:provider/provider.dart'; import '../../config/size_config.dart'; import '../../landing_page.dart'; +import '../../root_page.dart'; import '../../routes.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../util/helpers.dart'; import '../../widgets/auth/verification_methods_list.dart'; +import 'login_screen.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = Helpers(); @@ -53,6 +56,7 @@ class _VerificationMethodsScreenState extends State { return AppScaffold( isShowAppBar: false, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, // baseViewModel: model, body: SingleChildScrollView( child: Center( @@ -336,7 +340,13 @@ class _VerificationMethodsScreenState extends State { .useAnotherAccount, color: Colors.red[700], onPressed: () { - Navigator.of(context).pushNamed(LOGIN); + projectsProvider.isLogin = true; + Navigator.pushAndRemoveUntil( + AppGlobal.CONTEX, + FadePage( + page: RootPage(), + ), + (r) => false); }, ), @@ -360,7 +370,7 @@ class _VerificationMethodsScreenState extends State { Helpers.showErrorToast(authenticationViewModel.error); GifLoaderDialogUtils.hideDialog(context); } else { - authenticationViewModel.setDataAfterSendActivationSuccsess(authenticationViewModel.activationCodeForDoctorAppRes); + authenticationViewModel.setDataAfterSendActivationSuccess(authenticationViewModel.activationCodeForDoctorAppRes); sharedPref.setString(PASSWORD, widget.password); GifLoaderDialogUtils.hideDialog(context); this.startSMSService(authMethodType); @@ -382,7 +392,7 @@ class _VerificationMethodsScreenState extends State { GifLoaderDialogUtils.hideDialog(context); Helpers.showErrorToast(authenticationViewModel.error); } else { - authenticationViewModel.setDataAfterSendActivationSuccsess(authenticationViewModel.activationCodeVerificationScreenRes); + authenticationViewModel.setDataAfterSendActivationSuccess(authenticationViewModel.activationCodeVerificationScreenRes); if (authMethodType == AuthMethodTypes.SMS || authMethodType == AuthMethodTypes.WhatsApp) { GifLoaderDialogUtils.hideDialog(context); diff --git a/lib/widgets/auth/method_type_card.dart b/lib/widgets/auth/method_type_card.dart index 45190d2c..d991020c 100644 --- a/lib/widgets/auth/method_type_card.dart +++ b/lib/widgets/auth/method_type_card.dart @@ -6,11 +6,12 @@ class MethodTypeCard extends StatelessWidget { Key key, this.assetPath, this.onTap, - this.label, + this.label, this.height = 20, }) : super(key: key); final String assetPath; final Function onTap; final String label; + final double height; @override Widget build(BuildContext context) { @@ -38,7 +39,7 @@ class MethodTypeCard extends StatelessWidget { ], ), SizedBox( - height: 20, + height:height , ), AppText( label, diff --git a/lib/widgets/auth/sms-popup.dart b/lib/widgets/auth/sms-popup.dart index cf16a0f1..ed926545 100644 --- a/lib/widgets/auth/sms-popup.dart +++ b/lib/widgets/auth/sms-popup.dart @@ -309,12 +309,14 @@ class SMSOTP { } } - checkValue() { + checkValue() async { if (verifyAccountForm.currentState.validate()) { onSuccess(digit1.text.toString() + digit2.text.toString() + digit3.text.toString() + digit4.text.toString()); + this.isClosed = true; + } } @@ -341,7 +343,9 @@ class SMSOTP { Future.delayed(Duration(seconds: 1), () { if (this.remainingTime > 0) { - if (isClosed == false) startTimer(setState); + if (isClosed == false) { + startTimer(setState); + } } else { Navigator.pop(context); } diff --git a/lib/widgets/auth/verification_methods_list.dart b/lib/widgets/auth/verification_methods_list.dart index de867cde..b6efe748 100644 --- a/lib/widgets/auth/verification_methods_list.dart +++ b/lib/widgets/auth/verification_methods_list.dart @@ -81,6 +81,7 @@ class _VerificationMethodsListState extends State { assetPath: 'assets/images/login/more_icon.png', onTap: widget.onShowMore, label: TranslationBase.of(context).moreVerification, + height: 0, ); } }