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,7 +418,8 @@ class AuthenticationViewModel extends BaseViewModel {
deleteUser(){ deleteUser(){
user = null; user = null;
unverified = false; unverified = false;
notifyListeners(); isLogin = false;
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,30 +401,6 @@ class _LoginScreenState extends State<LoginScreen> {
])), ])),
]), ]),
), ),
Row(
mainAxisAlignment: MainAxisAlignment
.end,
children: <Widget>[
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<LoginScreen> {
])) ]))
]), ]),
), ),
bottomSheet: Container(
height: 90,
width: double.infinity,
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
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,)
],
),
),
),),
); );
} }

@ -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,92 +92,144 @@ 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,
child: Row( borderRadius: BorderRadius.all(
children: <Widget>[ Radius.circular(10),
Flexible( ),
flex: 3, border: Border.all(
child: ListTile( color: HexColor('#707070'),
title: Text( width: 0.1),
TranslationBase.of(context) ),
.lastLoginAt, child: Row(
overflow: mainAxisAlignment: MainAxisAlignment.spaceBetween,
TextOverflow.ellipsis, children: <Widget>[
style: TextStyle( Column(
fontFamily: 'Poppins', children: [
fontWeight:
FontWeight Text(
.w800, TranslationBase.of(context)
fontSize: 14), .lastLoginAt,
), overflow:
subtitle: AppText( TextOverflow.ellipsis,
authenticationViewModel.getType( style: TextStyle(
authenticationViewModel.user fontFamily: 'Poppins',
.logInTypeID, fontSize: 16,
context), color: Color(0xFF2E303A),
fontSize: 14, fontWeight: FontWeight.w700,),
))),
Flexible( ),
flex: 2, Row(
child: ListTile( children: [
title: AppText( AppText(
authenticationViewModel.user.editedOn != TranslationBase
null .of(context)
? DateUtils.getDayMonthYearDateFormatted( .verifyWith,
DateUtils.convertStringToDate( fontSize: 14,
authenticationViewModel.user color: Color(0xFF575757),
.editedOn)) fontWeight: FontWeight.w600,
: authenticationViewModel.user.createdOn != ),
null AppText(
? DateUtils.getDayMonthYearDateFormatted( authenticationViewModel.getType(
DateUtils.convertStringToDate(authenticationViewModel.user authenticationViewModel.user
.createdOn)) .logInTypeID,
: '--', context),
textAlign: fontSize: 14,
TextAlign.right, color: Color(0xFF2B353E),
fontSize: 14,
fontWeight: fontWeight: FontWeight.w700,
FontWeight.w800, ),
), ],
subtitle: AppText( )
authenticationViewModel.user.editedOn != ],
null crossAxisAlignment: CrossAxisAlignment.start,),
? DateUtils.getHour( Column(children: [
DateUtils.convertStringToDate( AppText(
authenticationViewModel.user authenticationViewModel.user.editedOn !=
.editedOn)) null
: authenticationViewModel.user.createdOn != ? DateUtils.getDayMonthYearDateFormatted(
null DateUtils.convertStringToDate(
? DateUtils.getHour( authenticationViewModel.user
DateUtils.convertStringToDate(authenticationViewModel.user .editedOn))
.createdOn)) : authenticationViewModel.user.createdOn !=
: '--', null
textAlign: ? DateUtils.getDayMonthYearDateFormatted(
TextAlign.right, DateUtils.convertStringToDate(authenticationViewModel.user
fontSize: 14, .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( : Column(
@ -175,13 +238,17 @@ 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)
.verifyFingerprint2, .verifyFingerprint2,
@ -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