add verification

auth_refactor
Elham Rababah 5 years ago
parent 1187c3b605
commit 515955663a

@ -576,10 +576,11 @@ const Map<String, Map<String, String>> localizedValues = {
"ar": "الرجاء اختيار احدى الخيارات التالية للتحقق من البيانات" "ar": "الرجاء اختيار احدى الخيارات التالية للتحقق من البيانات"
}, },
"register-user": {"en": "Register", "ar": "تسجيل"}, "register-user": {"en": "Register", "ar": "تسجيل"},
"verify-with-fingerprint": {"en": "Verify through Fingerprint", "ar": "بصمة"}, "verify-with-fingerprint": {"en": "Fingerprint", "ar": "بصمة"},
"verify-with-faceid": {"en": "Verify through Face ID", "ar": "معرف الوجه"}, "verify-with-faceid": {"en": "Face ID", "ar": "معرف الوجه"},
"verify-with-sms": {"en": "Verify through SMS", "ar": "الرسائل القصيرة"}, "verify-with-sms": {"en": " SMS", "ar": "الرسائل القصيرة"},
"verify-with-whatsapp": {"en": "Verify through WhatsApp", "ar": " الواتس اب"}, "verify-with-whatsapp": {"en": "WhatsApp", "ar": " الواتس اب"},
"verify-with": {"en": "Verify through ", "ar": " الواتس اب"},
"last-login": { "last-login": {
"en": "Last login details:", "en": "Last login details:",
"ar": "تفاصيل تسجيل الدخول الأخير:" "ar": "تفاصيل تسجيل الدخول الأخير:"

@ -188,7 +188,7 @@ class AuthenticationViewModel extends BaseViewModel {
} }
/// check activation /// check activation code for sms and whats app
Future checkActivationCodeForDoctorApp({String activationCode}) async { Future checkActivationCodeForDoctorApp({String activationCode}) async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = 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) { setDataAfterSendActivationSuccess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) {
print("VerificationCode : " + print("VerificationCode : " +
sendActivationCodeForDoctorAppResponseModel.verificationCode); sendActivationCodeForDoctorAppResponseModel.verificationCode);
@ -362,7 +362,7 @@ class AuthenticationViewModel extends BaseViewModel {
} }
setState(ViewState.Busy); setState(ViewState.Busy);
var token = await _firebaseMessaging.getToken(); var token = await _firebaseMessaging.getToken();
if (DEVICE_TOKEN == "" && !ProjectViewModel().isLogin) { if (DEVICE_TOKEN == "") {
DEVICE_TOKEN = token; DEVICE_TOKEN = token;
await _authService.selectDeviceImei(DEVICE_TOKEN); await _authService.selectDeviceImei(DEVICE_TOKEN);
@ -404,7 +404,6 @@ class AuthenticationViewModel extends BaseViewModel {
String lang = await sharedPref.getString(APP_Language); String lang = await sharedPref.getString(APP_Language);
await Helpers.clearSharedPref(); await Helpers.clearSharedPref();
sharedPref.setString(APP_Language, lang); sharedPref.setString(APP_Language, lang);
ProjectViewModel().isLogin = false;
deleteUser(); deleteUser();
if(isSessionTimeout) if(isSessionTimeout)
await getDeviceInfoFromFirebase(); await getDeviceInfoFromFirebase();
@ -419,6 +418,7 @@ class AuthenticationViewModel extends BaseViewModel {
deleteUser(){ deleteUser(){
user = null; user = null;
unverified = false; unverified = false;
isLogin = false;
notifyListeners(); notifyListeners();
} }

@ -24,7 +24,6 @@ class ProjectViewModel with ChangeNotifier {
List<ClinicModel> doctorClinicsList = []; List<ClinicModel> doctorClinicsList = [];
bool isLoading = false; bool isLoading = false;
bool isError = false; bool isError = false;
bool isLogin = false;
String error = ''; String error = '';
BaseAppClient baseAppClient = BaseAppClient(); BaseAppClient baseAppClient = BaseAppClient();

@ -401,17 +401,29 @@ class _LoginScreenState extends State<LoginScreen> {
])), ])),
]), ]),
), ),
Row( ],
mainAxisAlignment: MainAxisAlignment ),
.end, )
],
)
]))
]),
),
bottomSheet: Container(
height: 90,
width: double.infinity,
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
Expanded( AppButton(
child: AppButton(
title: TranslationBase title: TranslationBase
.of(context) .of(context)
.login, .login,
color: HexColor( color: Color(0xFFD02127),
'#D02127'),
disabled: authenticationViewModel.userInfo disabled: authenticationViewModel.userInfo
.userID == null || .userID == null ||
authenticationViewModel.userInfo authenticationViewModel.userInfo
@ -422,17 +434,13 @@ class _LoginScreenState extends State<LoginScreen> {
onPressed: () { onPressed: () {
login(context); login(context);
}, },
)),
],
)
],
), ),
)
SizedBox(height: 25,)
], ],
)
]))
]),
), ),
),
),),
); );
} }

@ -67,13 +67,24 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
width: SizeConfig.realScreenWidth, width: SizeConfig.realScreenWidth,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
SizedBox(
height: 80,
),
InkWell(
onTap: (){
Navigator.of(context).pop();
},
child: Icon(Icons.arrow_back_ios,color: Color(0xFF2B353E),)
),
Container( Container(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
height: 100, height: 20,
), ),
authenticationViewModel.user != null && isMoreOption == false authenticationViewModel.user != null && isMoreOption == false
? Column( ? Column(
@ -81,54 +92,86 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
MainAxisAlignment.spaceEvenly, MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
AppText( AppText(
TranslationBase.of(context).welcomeBack), TranslationBase.of(context).welcomeBack,
fontSize:12,
fontWeight: FontWeight.w700,
color: Color(0xFF2B353E),
),
AppText( AppText(
Helpers.capitalize(authenticationViewModel.user.doctorName), Helpers.capitalize(authenticationViewModel.user.doctorName),
fontSize: SizeConfig.textMultiplier * 3.5, fontSize: 24,
color: Color(0xFF2B353E),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
AppText( AppText(
TranslationBase.of(context).accountInfo, TranslationBase.of(context).accountInfo ,
fontSize: SizeConfig.textMultiplier * 2.5, fontSize: 16,
color: Color(0xFF2E303A),
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
Card( Container(
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10),
),
border: Border.all(
color: HexColor('#707070'),
width: 0.1),
),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Flexible( Column(
flex: 3, children: [
child: ListTile(
title: Text( Text(
TranslationBase.of(context) TranslationBase.of(context)
.lastLoginAt, .lastLoginAt,
overflow: overflow:
TextOverflow.ellipsis, TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontFamily: 'Poppins', fontFamily: 'Poppins',
fontWeight: fontSize: 16,
FontWeight color: Color(0xFF2E303A),
.w800, fontWeight: FontWeight.w700,),
fontSize: 14),
),
Row(
children: [
AppText(
TranslationBase
.of(context)
.verifyWith,
fontSize: 14,
color: Color(0xFF575757),
fontWeight: FontWeight.w600,
), ),
subtitle: AppText( AppText(
authenticationViewModel.getType( authenticationViewModel.getType(
authenticationViewModel.user authenticationViewModel.user
.logInTypeID, .logInTypeID,
context), context),
fontSize: 14, fontSize: 14,
))), color: Color(0xFF2B353E),
Flexible(
flex: 2, fontWeight: FontWeight.w700,
child: ListTile( ),
title: AppText( ],
)
],
crossAxisAlignment: CrossAxisAlignment.start,),
Column(children: [
AppText(
authenticationViewModel.user.editedOn != authenticationViewModel.user.editedOn !=
null null
? DateUtils.getDayMonthYearDateFormatted( ? DateUtils.getDayMonthYearDateFormatted(
@ -143,11 +186,11 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
: '--', : '--',
textAlign: textAlign:
TextAlign.right, TextAlign.right,
fontSize: 14, fontSize: 13,
fontWeight: color: Color(0xFF2E303A),
FontWeight.w800, fontWeight: FontWeight.w700,
), ),
subtitle: AppText( AppText(
authenticationViewModel.user.editedOn != authenticationViewModel.user.editedOn !=
null null
? DateUtils.getHour( ? DateUtils.getHour(
@ -163,10 +206,30 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
textAlign: textAlign:
TextAlign.right, TextAlign.right,
fontSize: 14, 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( : Column(
@ -175,12 +238,16 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
this.onlySMSBox == false this.onlySMSBox == false
? AppText( ? Container(
margin: EdgeInsets.only(bottom: 20, top: 30),
child: AppText(
TranslationBase.of(context) TranslationBase.of(context)
.verifyLoginWith, .verifyLoginWith,
fontSize: fontSize: 18,
SizeConfig.textMultiplier * 3.5, color: Color(0xFF2E303A),
fontWeight: FontWeight.bold,
textAlign: TextAlign.left, textAlign: TextAlign.left,
),
) )
: AppText( : AppText(
TranslationBase.of(context) TranslationBase.of(context)
@ -317,15 +384,6 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
), ),
), ),
bottomSheet: authenticationViewModel.user == null ? SizedBox(height: 0,) : Container( 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, height: 90,
width: double.infinity, width: double.infinity,
child: Center( child: Center(
@ -338,11 +396,8 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
title: TranslationBase title: TranslationBase
.of(context) .of(context)
.useAnotherAccount, .useAnotherAccount,
color: Colors.red[700], color: Color(0xFFD02127),
onPressed: () { onPressed: () {
projectsProvider.isLogin = true;
authenticationViewModel.unverified = false;
authenticationViewModel.isLogin = false;
authenticationViewModel.deleteUser(); authenticationViewModel.deleteUser();
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
@ -499,8 +554,6 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
if (authenticationViewModel.state == ViewState.ErrorLocal) { if (authenticationViewModel.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(authenticationViewModel.error); Helpers.showErrorToast(authenticationViewModel.error);
} else { } else {
projectsProvider.isLogin = true;
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
FadePage( FadePage(

@ -940,6 +940,8 @@ class TranslationBase {
String get verifySMS => String get verifySMS =>
localizedValues['verify-with-sms'][locale.languageCode]; localizedValues['verify-with-sms'][locale.languageCode];
String get verifyWith =>
localizedValues['verify-with'][locale.languageCode];
String get verifyWhatsApp => String get verifyWhatsApp =>
localizedValues['verify-with-whatsapp'][locale.languageCode]; localizedValues['verify-with-whatsapp'][locale.languageCode];

@ -1,5 +1,6 @@
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
class MethodTypeCard extends StatelessWidget { class MethodTypeCard extends StatelessWidget {
const MethodTypeCard({ const MethodTypeCard({
@ -20,9 +21,15 @@ class MethodTypeCard extends StatelessWidget {
child: Container( child: Container(
margin: EdgeInsets.all(10), margin: EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10),
), ),
border: Border.all(
color: HexColor('#707070'),
width: 0.1),
),
height: 170,
child: Padding( child: Padding(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15), padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
child: Column( child: Column(
@ -44,7 +51,8 @@ class MethodTypeCard extends StatelessWidget {
AppText( AppText(
label, label,
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, color: Color(0xFF2E303A),
fontWeight: FontWeight.bold,
) )
], ],
), ),

@ -40,14 +40,18 @@ class _VerificationMethodsListState extends State<VerificationMethodsList> {
assetPath: 'assets/images/verify-whtsapp.png', assetPath: 'assets/images/verify-whtsapp.png',
onTap: () => onTap: () =>
{widget.authenticateUser(AuthMethodTypes.WhatsApp, true)}, {widget.authenticateUser(AuthMethodTypes.WhatsApp, true)},
label: TranslationBase.of(context).verifyWhatsApp, label: TranslationBase
.of(context)
.verifyWith+ TranslationBase.of(context).verifyWhatsApp,
); );
break; break;
case AuthMethodTypes.SMS: case AuthMethodTypes.SMS:
return MethodTypeCard( return MethodTypeCard(
assetPath: "assets/images/verify-sms.png", assetPath: "assets/images/verify-sms.png",
onTap: () => {widget.authenticateUser(AuthMethodTypes.SMS, true)}, onTap: () => {widget.authenticateUser(AuthMethodTypes.SMS, true)},
label: TranslationBase.of(context).verifySMS, label:TranslationBase
.of(context)
.verifyWith+ TranslationBase.of(context).verifySMS,
); );
break; break;
case AuthMethodTypes.Fingerprint: case AuthMethodTypes.Fingerprint:
@ -60,7 +64,9 @@ class _VerificationMethodsListState extends State<VerificationMethodsList> {
widget.authenticateUser(AuthMethodTypes.Fingerprint, true); widget.authenticateUser(AuthMethodTypes.Fingerprint, true);
} }
}, },
label: TranslationBase.of(context).verifyFingerprint, label: TranslationBase
.of(context)
.verifyWith+TranslationBase.of(context).verifyFingerprint,
); );
break; break;
case AuthMethodTypes.FaceID: case AuthMethodTypes.FaceID:
@ -72,7 +78,9 @@ class _VerificationMethodsListState extends State<VerificationMethodsList> {
widget.authenticateUser(AuthMethodTypes.FaceID, true); widget.authenticateUser(AuthMethodTypes.FaceID, true);
} }
}, },
label: TranslationBase.of(context).verifyFaceID, label: TranslationBase
.of(context)
.verifyWith+TranslationBase.of(context).verifyFaceID,
); );
break; break;

@ -173,7 +173,6 @@ class _AppDrawerState extends State<AppDrawer> {
onTap: () async { onTap: () async {
Navigator.pop(context); Navigator.pop(context);
await authenticationViewModel.logout(); await authenticationViewModel.logout();
projectsProvider.isLogin = false;
}, },
), ),
], ],

Loading…
Cancel
Save