From 515955663af98f14ca49dca8763406f459cb9d86 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 17 May 2021 16:26:37 +0300 Subject: [PATCH] add verification --- lib/config/localized_values.dart | 9 +- .../viewModel/authentication_view_model.dart | 10 +- lib/core/viewModel/project_view_model.dart | 1 - lib/screens/auth/login_screen.dart | 56 +++-- .../auth/verification_methods_screen.dart | 237 +++++++++++------- lib/util/translations_delegate_base.dart | 2 + lib/widgets/auth/method_type_card.dart | 12 +- .../auth/verification_methods_list.dart | 16 +- lib/widgets/shared/app_drawer_widget.dart | 1 - 9 files changed, 211 insertions(+), 133 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index d09d33f4..16be8d8e 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -576,10 +576,11 @@ const Map> localizedValues = { "ar": "الرجاء اختيار احدى الخيارات التالية للتحقق من البيانات" }, "register-user": {"en": "Register", "ar": "تسجيل"}, - "verify-with-fingerprint": {"en": "Verify through Fingerprint", "ar": "بصمة"}, - "verify-with-faceid": {"en": "Verify through Face ID", "ar": "معرف الوجه"}, - "verify-with-sms": {"en": "Verify through SMS", "ar": "الرسائل القصيرة"}, - "verify-with-whatsapp": {"en": "Verify through WhatsApp", "ar": " الواتس اب"}, + "verify-with-fingerprint": {"en": "Fingerprint", "ar": "بصمة"}, + "verify-with-faceid": {"en": "Face ID", "ar": "معرف الوجه"}, + "verify-with-sms": {"en": " SMS", "ar": "الرسائل القصيرة"}, + "verify-with-whatsapp": {"en": "WhatsApp", "ar": " الواتس اب"}, + "verify-with": {"en": "Verify through ", "ar": " الواتس اب"}, "last-login": { "en": "Last login details:", "ar": "تفاصيل تسجيل الدخول الأخير:" diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index 8e9c3541..223b303b 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -188,7 +188,7 @@ class AuthenticationViewModel extends BaseViewModel { } - /// check activation + /// check activation code for sms and whats app Future checkActivationCodeForDoctorApp({String activationCode}) async { setState(ViewState.BusyLocal); CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = @@ -253,7 +253,7 @@ class AuthenticationViewModel extends BaseViewModel { } } - /// add some logic in case of send activation code is success + /// add  token to shared preferences in case of send activation code is success setDataAfterSendActivationSuccess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) { print("VerificationCode : " + sendActivationCodeForDoctorAppResponseModel.verificationCode); @@ -362,7 +362,7 @@ class AuthenticationViewModel extends BaseViewModel { } setState(ViewState.Busy); var token = await _firebaseMessaging.getToken(); - if (DEVICE_TOKEN == "" && !ProjectViewModel().isLogin) { + if (DEVICE_TOKEN == "") { DEVICE_TOKEN = token; await _authService.selectDeviceImei(DEVICE_TOKEN); @@ -404,7 +404,6 @@ class AuthenticationViewModel extends BaseViewModel { String lang = await sharedPref.getString(APP_Language); await Helpers.clearSharedPref(); sharedPref.setString(APP_Language, lang); - ProjectViewModel().isLogin = false; deleteUser(); if(isSessionTimeout) await getDeviceInfoFromFirebase(); @@ -419,7 +418,8 @@ class AuthenticationViewModel extends BaseViewModel { deleteUser(){ user = null; unverified = false; - notifyListeners(); + isLogin = false; + notifyListeners(); } } diff --git a/lib/core/viewModel/project_view_model.dart b/lib/core/viewModel/project_view_model.dart index 494e3b10..f464df0e 100644 --- a/lib/core/viewModel/project_view_model.dart +++ b/lib/core/viewModel/project_view_model.dart @@ -24,7 +24,6 @@ class ProjectViewModel with ChangeNotifier { List doctorClinicsList = []; bool isLoading = false; bool isError = false; - bool isLogin = false; String error = ''; BaseAppClient baseAppClient = BaseAppClient(); diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index 7fbf47af..b8d5cca3 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -401,30 +401,6 @@ class _LoginScreenState extends State { ])), ]), ), - Row( - mainAxisAlignment: MainAxisAlignment - .end, - children: [ - Expanded( - child: AppButton( - title: TranslationBase - .of(context) - .login, - color: HexColor( - '#D02127'), - disabled: authenticationViewModel.userInfo - .userID == null || - authenticationViewModel.userInfo - .password == - null, - fontWeight: FontWeight - .bold, - onPressed: () { - login(context); - }, - )), - ], - ) ], ), ) @@ -433,6 +409,38 @@ class _LoginScreenState extends State { ])) ]), ), + bottomSheet: Container( + + height: 90, + width: double.infinity, + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + AppButton( + title: TranslationBase + .of(context) + .login, + color: Color(0xFFD02127), + disabled: authenticationViewModel.userInfo + .userID == null || + authenticationViewModel.userInfo + .password == + null, + fontWeight: FontWeight + .bold, + onPressed: () { + login(context); + }, + ), + + SizedBox(height: 25,) + ], + ), + ), + ),), ); } diff --git a/lib/screens/auth/verification_methods_screen.dart b/lib/screens/auth/verification_methods_screen.dart index 5aa626be..35d8366d 100644 --- a/lib/screens/auth/verification_methods_screen.dart +++ b/lib/screens/auth/verification_methods_screen.dart @@ -67,13 +67,24 @@ class _VerificationMethodsScreenState extends State { width: SizeConfig.realScreenWidth, child: Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + SizedBox( + height: 80, + ), + InkWell( + onTap: (){ + Navigator.of(context).pop(); + }, + child: Icon(Icons.arrow_back_ios,color: Color(0xFF2B353E),) + + ), Container( + child: Column( children: [ SizedBox( - height: 100, + height: 20, ), authenticationViewModel.user != null && isMoreOption == false ? Column( @@ -81,92 +92,144 @@ class _VerificationMethodsScreenState extends State { MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ + AppText( - TranslationBase.of(context).welcomeBack), + TranslationBase.of(context).welcomeBack, + fontSize:12, + fontWeight: FontWeight.w700, + color: Color(0xFF2B353E), + ), AppText( Helpers.capitalize(authenticationViewModel.user.doctorName), - fontSize: SizeConfig.textMultiplier * 3.5, + fontSize: 24, + color: Color(0xFF2B353E), fontWeight: FontWeight.bold, ), SizedBox( height: 20, ), AppText( - TranslationBase.of(context).accountInfo, - fontSize: SizeConfig.textMultiplier * 2.5, + TranslationBase.of(context).accountInfo , + fontSize: 16, + color: Color(0xFF2E303A), fontWeight: FontWeight.w600, ), SizedBox( height: 20, ), - Card( + Container( + padding: EdgeInsets.all(15), + decoration: BoxDecoration( color: Colors.white, - child: Row( - children: [ - Flexible( - flex: 3, - child: ListTile( - title: Text( - TranslationBase.of(context) - .lastLoginAt, - overflow: - TextOverflow.ellipsis, - style: TextStyle( - fontFamily: 'Poppins', - fontWeight: - FontWeight - .w800, - fontSize: 14), - ), - subtitle: AppText( - authenticationViewModel.getType( - authenticationViewModel.user - .logInTypeID, - context), - fontSize: 14, - ))), - Flexible( - flex: 2, - child: ListTile( - title: AppText( - authenticationViewModel.user.editedOn != - null - ? DateUtils.getDayMonthYearDateFormatted( - DateUtils.convertStringToDate( - authenticationViewModel.user - .editedOn)) - : authenticationViewModel.user.createdOn != - null - ? DateUtils.getDayMonthYearDateFormatted( - DateUtils.convertStringToDate(authenticationViewModel.user - .createdOn)) - : '--', - textAlign: - TextAlign.right, - fontSize: 14, - fontWeight: - FontWeight.w800, - ), - subtitle: AppText( - authenticationViewModel.user.editedOn != - null - ? DateUtils.getHour( - DateUtils.convertStringToDate( - authenticationViewModel.user - .editedOn)) - : authenticationViewModel.user.createdOn != - null - ? DateUtils.getHour( - DateUtils.convertStringToDate(authenticationViewModel.user - .createdOn)) - : '--', - textAlign: - TextAlign.right, - fontSize: 14, - ), - )) + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + border: Border.all( + color: HexColor('#707070'), + width: 0.1), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + + Text( + TranslationBase.of(context) + .lastLoginAt, + overflow: + TextOverflow.ellipsis, + style: TextStyle( + fontFamily: 'Poppins', + fontSize: 16, + color: Color(0xFF2E303A), + fontWeight: FontWeight.w700,), + + ), + Row( + children: [ + AppText( + TranslationBase + .of(context) + .verifyWith, + fontSize: 14, + color: Color(0xFF575757), + fontWeight: FontWeight.w600, + ), + AppText( + authenticationViewModel.getType( + authenticationViewModel.user + .logInTypeID, + context), + fontSize: 14, + color: Color(0xFF2B353E), + + fontWeight: FontWeight.w700, + ), + ], + ) + ], + crossAxisAlignment: CrossAxisAlignment.start,), + Column(children: [ + AppText( + authenticationViewModel.user.editedOn != + null + ? DateUtils.getDayMonthYearDateFormatted( + DateUtils.convertStringToDate( + authenticationViewModel.user + .editedOn)) + : authenticationViewModel.user.createdOn != + null + ? DateUtils.getDayMonthYearDateFormatted( + DateUtils.convertStringToDate(authenticationViewModel.user + .createdOn)) + : '--', + textAlign: + TextAlign.right, + fontSize: 13, + color: Color(0xFF2E303A), + fontWeight: FontWeight.w700, + ), + AppText( + authenticationViewModel.user.editedOn != + null + ? DateUtils.getHour( + DateUtils.convertStringToDate( + authenticationViewModel.user + .editedOn)) + : authenticationViewModel.user.createdOn != + null + ? DateUtils.getHour( + DateUtils.convertStringToDate(authenticationViewModel.user + .createdOn)) + : '--', + textAlign: + TextAlign.right, + fontSize: 14, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), + ) ], - )), + crossAxisAlignment: CrossAxisAlignment.start, + + ) + ], + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + AppText( + "Please Verify", + fontSize: 16, + color: Color(0xFF2B353E), + + fontWeight: FontWeight.w700, + ), + ], + ) ], ) : Column( @@ -175,13 +238,17 @@ class _VerificationMethodsScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ this.onlySMSBox == false - ? AppText( + ? Container( + margin: EdgeInsets.only(bottom: 20, top: 30), + child: AppText( TranslationBase.of(context) - .verifyLoginWith, - fontSize: - SizeConfig.textMultiplier * 3.5, + .verifyLoginWith, + fontSize: 18, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, textAlign: TextAlign.left, - ) + ), + ) : AppText( TranslationBase.of(context) .verifyFingerprint2, @@ -317,15 +384,6 @@ class _VerificationMethodsScreenState extends State { ), ), bottomSheet: authenticationViewModel.user == null ? SizedBox(height: 0,) : Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(0.0), - ), - border: Border.all( - color: HexColor('#707070'), - width: 0), - ), height: 90, width: double.infinity, child: Center( @@ -338,11 +396,8 @@ class _VerificationMethodsScreenState extends State { title: TranslationBase .of(context) .useAnotherAccount, - color: Colors.red[700], + color: Color(0xFFD02127), onPressed: () { - projectsProvider.isLogin = true; - authenticationViewModel.unverified = false; - authenticationViewModel.isLogin = false; authenticationViewModel.deleteUser(); Navigator.pushAndRemoveUntil( @@ -499,8 +554,6 @@ class _VerificationMethodsScreenState extends State { if (authenticationViewModel.state == ViewState.ErrorLocal) { Helpers.showErrorToast(authenticationViewModel.error); } else { - projectsProvider.isLogin = true; - Navigator.pushAndRemoveUntil( context, FadePage( diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index ba69e104..77230e2a 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -940,6 +940,8 @@ class TranslationBase { String get verifySMS => localizedValues['verify-with-sms'][locale.languageCode]; + String get verifyWith => + localizedValues['verify-with'][locale.languageCode]; String get verifyWhatsApp => localizedValues['verify-with-whatsapp'][locale.languageCode]; diff --git a/lib/widgets/auth/method_type_card.dart b/lib/widgets/auth/method_type_card.dart index d991020c..6d091756 100644 --- a/lib/widgets/auth/method_type_card.dart +++ b/lib/widgets/auth/method_type_card.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; class MethodTypeCard extends StatelessWidget { const MethodTypeCard({ @@ -20,9 +21,15 @@ class MethodTypeCard extends StatelessWidget { child: Container( margin: EdgeInsets.all(10), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + border: Border.all( + color: HexColor('#707070'), + width: 0.1), ), + height: 170, child: Padding( padding: EdgeInsets.fromLTRB(20, 15, 20, 15), child: Column( @@ -44,7 +51,8 @@ class MethodTypeCard extends StatelessWidget { AppText( label, fontSize: 14, - fontWeight: FontWeight.w600, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, ) ], ), diff --git a/lib/widgets/auth/verification_methods_list.dart b/lib/widgets/auth/verification_methods_list.dart index b6efe748..27dbe8bf 100644 --- a/lib/widgets/auth/verification_methods_list.dart +++ b/lib/widgets/auth/verification_methods_list.dart @@ -40,14 +40,18 @@ class _VerificationMethodsListState extends State { assetPath: 'assets/images/verify-whtsapp.png', onTap: () => {widget.authenticateUser(AuthMethodTypes.WhatsApp, true)}, - label: TranslationBase.of(context).verifyWhatsApp, + label: TranslationBase + .of(context) + .verifyWith+ TranslationBase.of(context).verifyWhatsApp, ); break; case AuthMethodTypes.SMS: return MethodTypeCard( assetPath: "assets/images/verify-sms.png", onTap: () => {widget.authenticateUser(AuthMethodTypes.SMS, true)}, - label: TranslationBase.of(context).verifySMS, + label:TranslationBase + .of(context) + .verifyWith+ TranslationBase.of(context).verifySMS, ); break; case AuthMethodTypes.Fingerprint: @@ -60,7 +64,9 @@ class _VerificationMethodsListState extends State { widget.authenticateUser(AuthMethodTypes.Fingerprint, true); } }, - label: TranslationBase.of(context).verifyFingerprint, + label: TranslationBase + .of(context) + .verifyWith+TranslationBase.of(context).verifyFingerprint, ); break; case AuthMethodTypes.FaceID: @@ -72,7 +78,9 @@ class _VerificationMethodsListState extends State { widget.authenticateUser(AuthMethodTypes.FaceID, true); } }, - label: TranslationBase.of(context).verifyFaceID, + label: TranslationBase + .of(context) + .verifyWith+TranslationBase.of(context).verifyFaceID, ); break; diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index ee7f0276..e350e39d 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -173,7 +173,6 @@ class _AppDrawerState extends State { onTap: () async { Navigator.pop(context); await authenticationViewModel.logout(); - projectsProvider.isLogin = false; }, ), ],