add verification

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

@ -576,10 +576,11 @@ const Map<String, Map<String, String>> 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": "تفاصيل تسجيل الدخول الأخير:"

@ -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();
}
}

@ -24,7 +24,6 @@ class ProjectViewModel with ChangeNotifier {
List<ClinicModel> doctorClinicsList = [];
bool isLoading = false;
bool isError = false;
bool isLogin = false;
String error = '';
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,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
height: 80,
),
InkWell(
onTap: (){
Navigator.of(context).pop();
},
child: Icon(Icons.arrow_back_ios,color: Color(0xFF2B353E),)
),
Container(
child: Column(
children: <Widget>[
SizedBox(
height: 100,
height: 20,
),
authenticationViewModel.user != null && isMoreOption == false
? Column(
@ -81,92 +92,144 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
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: <Widget>[
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: <Widget>[
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<VerificationMethodsScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
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<VerificationMethodsScreen> {
),
),
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<VerificationMethodsScreen> {
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<VerificationMethodsScreen> {
if (authenticationViewModel.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(authenticationViewModel.error);
} else {
projectsProvider.isLogin = true;
Navigator.pushAndRemoveUntil(
context,
FadePage(

@ -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];

@ -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,
)
],
),

@ -40,14 +40,18 @@ class _VerificationMethodsListState extends State<VerificationMethodsList> {
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<VerificationMethodsList> {
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<VerificationMethodsList> {
widget.authenticateUser(AuthMethodTypes.FaceID, true);
}
},
label: TranslationBase.of(context).verifyFaceID,
label: TranslationBase
.of(context)
.verifyWith+TranslationBase.of(context).verifyFaceID,
);
break;

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

Loading…
Cancel
Save