add UNVERIFIED status

auth_refactor
Elham Rababah 5 years ago
parent fd9f93a936
commit 2e71706cab

@ -35,6 +35,9 @@ class AuthenticationService extends BaseService {
List<DoctorProfileModel> _doctorProfilesList = [];
List<DoctorProfileModel> get doctorProfilesList => _doctorProfilesList;
Future selectDeviceImei(imei) async {
try {
await baseAppClient.post(SELECT_DEVICE_IMEI,

@ -1,3 +1,5 @@
import 'dart:io';
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';
@ -20,8 +22,10 @@ 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/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/services.dart';
import 'package:local_auth/auth_strings.dart';
import 'package:local_auth/local_auth.dart';
@ -29,6 +33,8 @@ import 'package:provider/provider.dart';
import 'doctor_profile_view_model.dart';
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED, UNVERIFIED }
class AuthenticationViewModel extends BaseViewModel {
AuthenticationService _authService = locator<AuthenticationService>();
HospitalsService _hospitalsService = locator<HospitalsService>();
@ -38,18 +44,20 @@ class AuthenticationViewModel extends BaseViewModel {
List<GetHospitalsResponseModel> get hospitals => _hospitalsService.hospitals;
NewLoginInformationModel get loginInfo => _authService.loginInfo;
List<DoctorProfileModel> get doctorProfilesList => _authService.doctorProfilesList;
SendActivationCodeForDoctorAppResponseModel
get activationCodeVerificationScreenRes =>
_authService.activationCodeVerificationScreenRes;
get activationCodeVerificationScreenRes =>
_authService.activationCodeVerificationScreenRes;
SendActivationCodeForDoctorAppResponseModel
get activationCodeForDoctorAppRes =>
_authService.activationCodeForDoctorAppRes;
get activationCodeForDoctorAppRes =>
_authService.activationCodeForDoctorAppRes;
CheckActivationCodeForDoctorAppResponseModel
get checkActivationCodeForDoctorAppRes =>
_authService.checkActivationCodeForDoctorAppRes;
get checkActivationCodeForDoctorAppRes =>
_authService.checkActivationCodeForDoctorAppRes;
NewLoginInformationModel loggedUser;
GetIMEIDetailsModel user;
@ -57,7 +65,14 @@ class AuthenticationViewModel extends BaseViewModel {
UserModel userInfo = UserModel();
final LocalAuthentication auth = LocalAuthentication();
List<BiometricType> _availableBiometrics;
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
bool isLogin = false;
bool unverified = false;
AuthenticationViewModel({bool checkDeviceInfo = false}) {
getDeviceInfoFromFirebase();
}
Future selectDeviceImei(imei) async {
setState(ViewState.Busy);
@ -70,7 +85,6 @@ class AuthenticationViewModel extends BaseViewModel {
}
Future insertDeviceImei() async {
var loggedIn = await sharedPref.getObj(LOGGED_IN_USER);
var user = await sharedPref.getObj(LAST_LOGIN_USER);
if (user != null) {
@ -116,6 +130,7 @@ class AuthenticationViewModel extends BaseViewModel {
setState(ViewState.ErrorLocal);
} else {
sharedPref.setInt(PROJECT_ID, userInfo.projectID);
loggedUser = loginInfo;
saveObjToString(LOGGED_IN_USER, loginInfo);
sharedPref.remove(LAST_LOGIN_USER);
sharedPref.setString(TOKEN, loginInfo.logInTokenID);
@ -183,7 +198,6 @@ class AuthenticationViewModel extends BaseViewModel {
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
}
@ -238,8 +252,7 @@ class AuthenticationViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
setDataAfterSendActivationSuccsess(
SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) {
setDataAfterSendActivationSuccsess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) {
print("VerificationCode : " +
sendActivationCodeForDoctorAppResponseModel.verificationCode);
sharedPref.setString(VIDA_AUTH_TOKEN_ID,
@ -300,28 +313,26 @@ class AuthenticationViewModel extends BaseViewModel {
onCheckActivationCodeSuccess() async {
sharedPref.setString(
TOKEN,
checkActivationCodeForDoctorAppRes.authenticationTokenID);
checkActivationCodeForDoctorAppRes.authenticationTokenID);
if (checkActivationCodeForDoctorAppRes.listDoctorProfile != null &&
checkActivationCodeForDoctorAppRes.listDoctorProfile
.isNotEmpty) {
localSetDoctorProfile(
checkActivationCodeForDoctorAppRes.listDoctorProfile[0]);
checkActivationCodeForDoctorAppRes.listDoctorProfile[0]);
} else {
sharedPref.setObj(
CLINIC_NAME,
checkActivationCodeForDoctorAppRes.listDoctorsClinic);
ClinicModel clinic = ClinicModel.fromJson(
checkActivationCodeForDoctorAppRes.listDoctorsClinic[0]
checkActivationCodeForDoctorAppRes.listDoctorsClinic[0]
.toJson());
await getDoctorProfileBasedOnClinic(clinic);
await getDoctorProfileBasedOnClinic(clinic);
}
}
Future <bool> checkIfBiometricAvailable(BiometricType biometricType) async {
bool isAvailable = false;
await _getAvailableBiometrics();
await _getAvailableBiometrics();
if (_availableBiometrics != null) {
for (var i = 0; i < _availableBiometrics.length; i++) {
if (biometricType == _availableBiometrics[i]) isAvailable = true;
@ -338,4 +349,54 @@ class AuthenticationViewModel extends BaseViewModel {
}
}
getDeviceInfoFromFirebase() async {
_firebaseMessaging.setAutoInitEnabled(true);
if (Platform.isIOS) {
_firebaseMessaging.requestNotificationPermissions();
}
setState(ViewState.Busy);
_firebaseMessaging.getToken().then((String token) async {
if (DEVICE_TOKEN == "") {
DEVICE_TOKEN = token;
await _authService.selectDeviceImei(DEVICE_TOKEN);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else {
if (_authService.dashboardItemsList.length > 0) {
user =_authService.dashboardItemsList[0];
sharedPref.setObj(
LAST_LOGIN_USER, _authService.dashboardItemsList[0]);
this.unverified = true;
// Navigator.of(AppGlobal.CONTEX).pushReplacement(MaterialPageRoute(
// builder: (BuildContext context) => VerificationMethodsScreen(
// password: null,
// )));
}
setState(ViewState.Idle);
}
} else {
setState(ViewState.Idle);
}
});
}
APP_STATUS get stutas {
if (state == ViewState.Busy) {
return APP_STATUS.LOADING;
} else {
if (this.unverified) {
return APP_STATUS.UNVERIFIED;
} else if (this.isLogin) {
return APP_STATUS.AUTHENTICATED;
} else {
return APP_STATUS.UNAUTHENTICATED;
}
}
}
}

@ -8,7 +8,6 @@ import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import '../../locator.dart';
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
class DoctorProfileViewModel extends BaseViewModel {
List<ClinicModel> doctorsClinicList = [];
@ -41,18 +40,6 @@ class DoctorProfileViewModel extends BaseViewModel {
}
notifyListeners();
}
//TODO Elham move it auth view model
APP_STATUS get stutas {
if (isLoading) {
return APP_STATUS.LOADING;
} else {
if (this.isLogin) {
return APP_STATUS.AUTHENTICATED;
} else {
return APP_STATUS.UNAUTHENTICATED;
}
}
}
Future<dynamic> getDocProfiles(docInfo,
{bool allowChangeProfile = true}) async {

@ -90,7 +90,6 @@ void setupLocator() {
/// View Model
locator.registerFactory(() => DoctorReplayViewModel());
locator.registerFactory(() => AuthenticationViewModel());
locator.registerFactory(() => ScheduleViewModel());
locator.registerFactory(() => ReferralPatientViewModel());
locator.registerFactory(() => ReferredPatientViewModel());

@ -11,6 +11,7 @@ import 'package:provider/provider.dart';
import './config/size_config.dart';
import './routes.dart';
import 'config/config.dart';
import 'core/viewModel/authentication_view_model.dart';
import 'core/viewModel/doctor_profile_view_model.dart';
import 'core/viewModel/hospitals_view_model.dart';
import 'locator.dart';
@ -23,7 +24,6 @@ void main() async {
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
AppGlobal.CONTEX = context;
@ -33,10 +33,10 @@ class MyApp extends StatelessWidget {
SizeConfig().init(constraints, orientation);
return MultiProvider(
providers: [
ChangeNotifierProvider<AuthenticationViewModel>(
create: (context) => AuthenticationViewModel()),
ChangeNotifierProvider<DoctorProfileViewModel>(
create: (context) => DoctorProfileViewModel()),
// ChangeNotifierProvider<HospitalViewModel>(
// create: (context) => HospitalViewModel()),
ChangeNotifierProvider<ProjectViewModel>(
create: (context) => ProjectViewModel(),
),

@ -1,25 +1,30 @@
import 'package:doctor_app_flutter/core/viewModel/doctor_profile_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
import 'package:doctor_app_flutter/screens/auth/login_screen.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'core/viewModel/authentication_view_model.dart';
import 'landing_page.dart';
class RootPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
DoctorProfileViewModel authProvider = Provider.of(context);
AuthenticationViewModel authenticationViewModel = Provider.of(context);
// ignore: missing_return
Widget buildRoot() {
switch (authProvider.stutas) {
switch (authenticationViewModel.stutas) {
case APP_STATUS.LOADING:
return Scaffold(
body: Center(
child: DrAppCircularProgressIndeicator(),
),
body: AppLoaderWidget(),
);
break;
case APP_STATUS.UNVERIFIED:
return VerificationMethodsScreen(password: null,);
break;
case APP_STATUS.UNAUTHENTICATED:
return LoginScreen();
break;

@ -1,32 +1,20 @@
import 'dart:io';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_response_model.dart';
import 'package:doctor_app_flutter/core/service/authentication_service.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../widgets/shared/app_scaffold_widget.dart';
//TODO Elham remove it
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
class LoginScreen extends StatefulWidget {
@override
@ -35,10 +23,6 @@ class LoginScreen extends StatefulWidget {
class _LoginScreenState extends State<LoginScreen> {
String platformImei;
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
bool _isLoading = true;
ProjectViewModel projectViewModel;
AuthenticationService authService = AuthenticationService();
//TODO change AppTextFormField to AppTextFormFieldCustom
final loginFormKey = GlobalKey<FormState>();
@ -46,463 +30,410 @@ class _LoginScreenState extends State<LoginScreen> {
List<GetHospitalsResponseModel> projectsList = [];
FocusNode focusPass = FocusNode();
FocusNode focusProject = FocusNode();
@override
void initState() {
super.initState();
//TODO Elham move it root page and the logic in the view model
_firebaseMessaging.setAutoInitEnabled(true);
if (Platform.isIOS) {
_firebaseMessaging.requestNotificationPermissions();
}
_firebaseMessaging.getToken().then((String token) async {
if (DEVICE_TOKEN == "" && projectViewModel.isLogin == false) {
DEVICE_TOKEN = token;
changeLoadingState(true);
authService.selectDeviceImei(DEVICE_TOKEN).then((value) {
print(authService.dashboardItemsList);
if (authService.dashboardItemsList.length > 0) {
sharedPref.setObj(
LAST_LOGIN_USER, authService.dashboardItemsList[0]);
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (BuildContext context) => VerificationMethodsScreen(
password: null,
)));
} else {
changeLoadingState(false);
}
});
} else {
changeLoadingState(false);
}
}).catchError((err) {
print(err);
});
}
//TODO Elham change it to GIF
void changeLoadingState(isLoading) {
setState(() {
_isLoading = isLoading;
});
}
AuthenticationViewModel authenticationViewModel;
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of<ProjectViewModel>(context);
return BaseView<AuthenticationViewModel>(
builder: (_, model, w) =>
AppScaffold(
baseViewModel: model,
isShowAppBar: false,
backgroundColor: HexColor('#F8F8F8'),
body: SafeArea(
child: (_isLoading == false)
? ListView(children: <Widget>[
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
return AppScaffold(
isShowAppBar: false,
backgroundColor: HexColor('#F8F8F8'),
body: SafeArea(
child: ListView(children: <Widget>[
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 30),
alignment: Alignment.topLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//TODO Use App Text rather than text
Container(
margin:
EdgeInsetsDirectional.fromSTEB(30, 0, 30, 30),
alignment: Alignment.topLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
//TODO Use App Text rather than text
Container(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
SizedBox(
height: 30,
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
SizedBox(
height: 10,
),
Text(
TranslationBase
.of(context)
.welcomeTo,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight
.w600,
fontFamily: 'Poppins'),
),
Text(
TranslationBase
.of(context)
.drSulaimanAlHabib,
style: TextStyle(
fontWeight: FontWeight
.w800,
fontSize: SizeConfig
.isMobile
? 24
: SizeConfig
.realScreenWidth *
0.029,
fontFamily: 'Poppins'),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
SizedBox(
height: 30,
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
SizedBox(
height: 10,
),
Text(
Text(
"Doctor App",
style: TextStyle(
fontSize:
SizeConfig.isMobile
? 16
: SizeConfig
.realScreenWidth *
0.030,
fontWeight: FontWeight
.w800,
color: HexColor(
'#B8382C')),
),
]),
],
)),
SizedBox(
height: 40,
),
Form(
key: loginFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment
.spaceBetween,
children: <Widget>[
Container(
width: SizeConfig
.realScreenWidth * 0.90,
height: SizeConfig
.realScreenHeight * 0.65,
child:
Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
buildSizedBox(),
Padding(
child: AppText(
TranslationBase
.of(context)
.enterCredentials,
fontSize: 18,
fontWeight: FontWeight
.bold,
),
padding: EdgeInsets.only(
top: 10, bottom: 10)),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.welcomeTo,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight
.w600,
fontFamily: 'Poppins'),
),
Text(
.enterId,
fontWeight: FontWeight
.w800,
fontSize: 14,
)),
AppTextFormField(
labelText: '',
borderColor: Colors
.white,
textInputAction: TextInputAction
.next,
validator: (value) {
if (value !=
null && value
.isEmpty) {
return TranslationBase
.of(context)
.pleaseEnterYourID;
}
return null;
},
onSaved: (value) {
if (value !=
null) setState(() {
authenticationViewModel.userInfo
.userID =
value
.trim();
});
},
onChanged: (value) {
if (value != null)
setState(() {
authenticationViewModel.userInfo
.userID =
value
.trim();
});
},
onFieldSubmitted: (_) {
focusPass
.nextFocus();
},
)
])),
buildSizedBox(),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.drSulaimanAlHabib,
style: TextStyle(
fontWeight: FontWeight
.w800,
fontSize: SizeConfig
.isMobile
? 24
: SizeConfig
.realScreenWidth *
0.029,
fontFamily: 'Poppins'),
),
Text(
"Doctor App",
style: TextStyle(
fontSize:
SizeConfig.isMobile
? 16
: SizeConfig
.realScreenWidth *
0.030,
fontWeight: FontWeight
.w800,
color: HexColor(
'#B8382C')),
),
]),
],
)),
SizedBox(
height: 40,
),
Form(
key: loginFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment
.spaceBetween,
children: <Widget>[
Container(
width: SizeConfig
.realScreenWidth * 0.90,
height: SizeConfig
.realScreenHeight * 0.65,
child:
Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
buildSizedBox(),
Padding(
child: AppText(
TranslationBase
.of(context)
.enterCredentials,
fontSize: 18,
fontWeight: FontWeight
.bold,
),
padding: EdgeInsets.only(
top: 10, bottom: 10)),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.enterId,
fontWeight: FontWeight
.w800,
fontSize: 14,
)),
AppTextFormField(
labelText: '',
borderColor: Colors
.white,
textInputAction: TextInputAction
.next,
validator: (value) {
if (value !=
null && value
.isEmpty) {
return TranslationBase
.of(context)
.pleaseEnterYourID;
}
return null;
},
onSaved: (value) {
if (value !=
null) setState(() {
model.userInfo
.userID =
value
.trim();
});
},
onChanged: (value) {
if (value != null)
setState(() {
model.userInfo
.userID =
value
.trim();
});
},
onFieldSubmitted: (
_) {
focusPass
.nextFocus();
},
)
])),
buildSizedBox(),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.enterPassword,
fontWeight: FontWeight
.w800,
fontSize: 14,
)),
AppTextFormField(
focusNode: focusPass,
obscureText: true,
borderColor: Colors
.white,
textInputAction: TextInputAction
.next,
validator: (value) {
if (value !=
null && value
.isEmpty) {
return TranslationBase
.of(context)
.pleaseEnterPassword;
}
return null;
},
onSaved: (value) {
if (value !=
null)
setState(() {
model.userInfo
.password =
value;
});
},
onChanged: (value){
if (value !=
null)
setState(() {
model.userInfo
.password =
value;
});
},
onFieldSubmitted: (
_) {
focusPass
.nextFocus();
Helpers
.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject,
model);
},
onTap: () {
this.getProjects(
model.userInfo
.userID, model);
},
)
])),
buildSizedBox(),
projectsList.length > 0
? Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.selectYourProject,
fontWeight: FontWeight
.w600,
)),
AppTextFormField(
focusNode: focusProject,
controller: projectIdController,
borderColor: Colors
.white,
suffixIcon: Icons
.arrow_drop_down,
onTap: () {
Helpers
.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject,
model);
},
validator: (
value) {
if (value !=
null &&
value
.isEmpty) {
return TranslationBase
.of(
context)
.pleaseEnterYourProject;
}
return null;
})
]))
: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.selectYourProject,
fontWeight: FontWeight
.w800,
fontSize: 14,
)),
AppTextFormField(
readOnly: true,
borderColor: Colors
.white,
prefix: IconButton(
icon: Icon(Icons
.arrow_drop_down),
iconSize: 30,
padding: EdgeInsets
.only(
bottom: 30),
),
)
])),
]),
),
Row(
mainAxisAlignment: MainAxisAlignment
.end,
children: <Widget>[
Expanded(
child: AppButton(
title: TranslationBase
.of(context)
.login,
color: HexColor(
'#D02127'),
disabled: model.userInfo
.userID == null ||
model.userInfo
.password ==
null,
fontWeight: FontWeight
.bold,
onPressed: () {
login(context, model);
},
)),
],
.enterPassword,
fontWeight: FontWeight
.w800,
fontSize: 14,
)),
AppTextFormField(
focusNode: focusPass,
obscureText: true,
borderColor: Colors
.white,
textInputAction: TextInputAction
.next,
validator: (value) {
if (value !=
null && value
.isEmpty) {
return TranslationBase
.of(context)
.pleaseEnterPassword;
}
return null;
},
onSaved: (value) {
if (value !=
null)
setState(() {
authenticationViewModel.userInfo
.password =
value;
});
},
onChanged: (value){
if (value !=
null)
setState(() {
authenticationViewModel.userInfo
.password =
value;
});
},
onFieldSubmitted: (_) {
focusPass
.nextFocus();
Helpers
.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject,
authenticationViewModel);
},
onTap: () {
this.getProjects(
authenticationViewModel.userInfo
.userID);
},
)
],
),
)
],
)
]))
])
: Center(child: AppLoaderWidget()),
),
), );
])),
buildSizedBox(),
projectsList.length > 0
? Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.selectYourProject,
fontWeight: FontWeight
.w600,
)),
AppTextFormField(
focusNode: focusProject,
controller: projectIdController,
borderColor: Colors
.white,
suffixIcon: Icons
.arrow_drop_down,
onTap: () {
Helpers
.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject,
authenticationViewModel);
},
validator: (value) {
if (value !=
null &&
value
.isEmpty) {
return TranslationBase
.of(
context)
.pleaseEnterYourProject;
}
return null;
})
]))
: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius
.all(
Radius.circular(
6.0)),
border: Border.all(
width: 1.0,
color: HexColor(
"#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: [
Padding(
padding: EdgeInsets
.only(
left: 10,
top: 10),
child: AppText(
TranslationBase
.of(context)
.selectYourProject,
fontWeight: FontWeight
.w800,
fontSize: 14,
)),
AppTextFormField(
readOnly: true,
borderColor: Colors
.white,
prefix: IconButton(
icon: Icon(Icons
.arrow_drop_down),
iconSize: 30,
padding: EdgeInsets
.only(
bottom: 30),
),
)
])),
]),
),
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);
},
)),
],
)
],
),
)
],
)
]))
]),
),
);
}
SizedBox buildSizedBox() {
@ -511,15 +442,14 @@ class _LoginScreenState extends State<LoginScreen> {
);
}
login(context,
AuthenticationViewModel model,) async {
login(context,) async {
if (loginFormKey.currentState.validate()) {
loginFormKey.currentState.save();
GifLoaderDialogUtils.showMyDialog(context);
await model.login(model.userInfo);
if (model.state == ViewState.ErrorLocal) {
await authenticationViewModel.login(authenticationViewModel.userInfo);
if (authenticationViewModel.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
Helpers.showErrorToast(model.error);
Helpers.showErrorToast(authenticationViewModel.error);
} else {
GifLoaderDialogUtils.hideDialog(context);
@ -527,7 +457,7 @@ class _LoginScreenState extends State<LoginScreen> {
MaterialPageRoute(
builder: (BuildContext context) =>
VerificationMethodsScreen(
password: model.userInfo.password,
password: authenticationViewModel.userInfo.password,
),
),
);
@ -535,23 +465,23 @@ class _LoginScreenState extends State<LoginScreen> {
}
}
onSelectProject(index, AuthenticationViewModel model) {
onSelectProject(index) {
setState(() {
model.userInfo.projectID = projectsList[index].facilityId;
authenticationViewModel.userInfo.projectID = projectsList[index].facilityId;
projectIdController.text = projectsList[index].facilityName;
});
primaryFocus.unfocus();
}
getProjects(memberID, AuthenticationViewModel model)async {
getProjects(memberID)async {
if (memberID != null && memberID != '') {
if (projectsList.length == 0) {
await model.getHospitalsList(memberID);
if(model.state == ViewState.Idle) {
projectsList = model.hospitals;
await authenticationViewModel.getHospitalsList(memberID);
if(authenticationViewModel.state == ViewState.Idle) {
projectsList = authenticationViewModel.hospitals;
setState(() {
model.userInfo.projectID = projectsList[0].facilityId;
authenticationViewModel.userInfo.projectID = projectsList[0].facilityId;
projectIdController.text = projectsList[0].facilityName;
});
}

@ -4,8 +4,8 @@ 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';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/doctor_profile_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/auth/sms-popup.dart';
@ -19,7 +19,6 @@ import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import '../../config/size_config.dart';
import '../../core/viewModel/doctor_profile_view_model.dart';
import '../../landing_page.dart';
import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
@ -46,28 +45,25 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
DoctorProfileViewModel doctorProfileViewModel;
AuthMethodTypes fingerPrintBefore;
AuthMethodTypes selectedOption;
AuthenticationViewModel model;
AuthenticationViewModel authenticationViewModel;
@override
Widget build(BuildContext context) {
doctorProfileViewModel = Provider.of<DoctorProfileViewModel>(context);
projectsProvider = Provider.of<ProjectViewModel>(context);
return BaseView<AuthenticationViewModel>(
onModelReady: (model) async {
this.model = model;
await model.getInitUserInfo();
},
builder: (_, model, w) => AppScaffold(
isShowAppBar: false,
baseViewModel: model,
body: SingleChildScrollView(
child: Center(
child: FractionallySizedBox(
child: Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
height: SizeConfig.realScreenHeight * .95,
width: SizeConfig.realScreenWidth,
child: Column(
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
return AppScaffold(
isShowAppBar: false,
// baseViewModel: model,
body: SingleChildScrollView(
child: Center(
child: FractionallySizedBox(
child: Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
height: SizeConfig.realScreenHeight * .95,
width: SizeConfig.realScreenWidth,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
@ -77,284 +73,280 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
SizedBox(
height: 100,
),
model.user != null && isMoreOption == false
authenticationViewModel.user != null && isMoreOption == false
? Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AppText(
TranslationBase.of(context).welcomeBack),
AppText(
Helpers.capitalize(authenticationViewModel.user.doctorName),
fontSize: SizeConfig.textMultiplier * 3.5,
fontWeight: FontWeight.bold,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).accountInfo,
fontSize: SizeConfig.textMultiplier * 2.5,
fontWeight: FontWeight.w600,
),
SizedBox(
height: 20,
),
Card(
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,
),
))
],
)),
],
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
this.onlySMSBox == false
? AppText(
TranslationBase.of(context)
.verifyLoginWith,
fontSize:
SizeConfig.textMultiplier * 3.5,
textAlign: TextAlign.left,
)
: AppText(
TranslationBase.of(context)
.verifyFingerprint2,
fontSize:
SizeConfig.textMultiplier * 2.5,
textAlign: TextAlign.start,
),
]),
authenticationViewModel.user != null && isMoreOption == false
? Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: InkWell(
onTap: () =>
{
// TODO check this logic it seem it will create bug to us
authenticateUser(
AuthMethodTypes
.Fingerprint, true)
},
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType: SelectedAuthMethodTypesService
.getMethodsTypeService(
authenticationViewModel.user
.logInTypeID),
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
)),
),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.MoreOptions,
onShowMore: () {
setState(() {
isMoreOption = true;
});
},
))
]),
])
: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
onlySMSBox == false
? Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
MainAxisAlignment.center,
children: <Widget>[
AppText(
TranslationBase.of(context).welcomeBack),
AppText(
Helpers.capitalize(model.user.doctorName),
fontSize: SizeConfig.textMultiplier * 3.5,
fontWeight: FontWeight.bold,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).accountInfo,
fontSize: SizeConfig.textMultiplier * 2.5,
fontWeight: FontWeight.w600,
),
SizedBox(
height: 20,
),
Card(
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(
model.getType(
model.user
.logInTypeID,
context),
fontSize: 14,
))),
Flexible(
flex: 2,
child: ListTile(
title: AppText(
model.user.editedOn !=
null
? DateUtils.getDayMonthYearDateFormatted(
DateUtils.convertStringToDate(
model.user
.editedOn))
: model.user.createdOn !=
null
? DateUtils.getDayMonthYearDateFormatted(
DateUtils.convertStringToDate(model
.user
.createdOn))
: '--',
textAlign:
TextAlign.right,
fontSize: 14,
fontWeight:
FontWeight.w800,
),
subtitle: AppText(
model.user.editedOn !=
null
? DateUtils.getHour(
DateUtils.convertStringToDate(
model.user
.editedOn))
: model.user.createdOn !=
null
? DateUtils.getHour(
DateUtils.convertStringToDate(model
.user
.createdOn))
: '--',
textAlign:
TextAlign.right,
fontSize: 14,
),
))
],
)),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.Fingerprint,
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
)),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.FaceID,
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
))
],
)
: Column(
: SizedBox(),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
this.onlySMSBox == false
? AppText(
TranslationBase.of(context)
.verifyLoginWith,
fontSize:
SizeConfig.textMultiplier * 3.5,
textAlign: TextAlign.left,
)
: AppText(
TranslationBase.of(context)
.verifyFingerprint2,
fontSize:
SizeConfig.textMultiplier * 2.5,
textAlign: TextAlign.start,
),
]),
model.user != null && isMoreOption == false
? Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: InkWell(
onTap: () =>
{
// TODO check this logic it seem it will create bug to us
authenticateUser(
AuthMethodTypes
.Fingerprint, true)
},
child: VerificationMethodsList(
model: model,
authMethodType: SelectedAuthMethodTypesService
.getMethodsTypeService(
model.user
.logInTypeID),
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
)),
),
Expanded(
child: VerificationMethodsList(
model: model,
authMethodType:
AuthMethodTypes.MoreOptions,
onShowMore: () {
setState(() {
isMoreOption = true;
});
},
))
]),
])
: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
onlySMSBox == false
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: VerificationMethodsList(
model: model,
authMethodType:
AuthMethodTypes.Fingerprint,
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
)),
Expanded(
child: VerificationMethodsList(
model: model,
authMethodType:
AuthMethodTypes.FaceID,
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
))
],
)
: SizedBox(),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: VerificationMethodsList(
model: model,
authMethodType: AuthMethodTypes
.SMS,
authenticateUser:
(
AuthMethodTypes authMethodType,
isActive) =>
authenticateUser(
authMethodType, isActive),
)),
Expanded(
child: VerificationMethodsList(
model: model,
authMethodType:
AuthMethodTypes.WhatsApp,
authenticateUser:
(
AuthMethodTypes authMethodType,
isActive) =>
authenticateUser(
authMethodType, isActive),
))
],
),
]),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType: AuthMethodTypes
.SMS,
authenticateUser:
(
AuthMethodTypes authMethodType,
isActive) =>
authenticateUser(
authMethodType, isActive),
)),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.WhatsApp,
authenticateUser:
(
AuthMethodTypes authMethodType,
isActive) =>
authenticateUser(
authMethodType, isActive),
))
],
),
]),
// )
],
),
),
],
),
),
),
),
),
bottomSheet: model.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(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AppButton(
title: TranslationBase
.of(context)
.useAnotherAccount,
color: Colors.red[700],
onPressed: () {
Navigator.of(context).pushNamed(LOGIN);
},
),
SizedBox(height: 25,)
],
),
),
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(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AppButton(
title: TranslationBase
.of(context)
.useAnotherAccount,
color: Colors.red[700],
onPressed: () {
Navigator.of(context).pushNamed(LOGIN);
},
),
),
),),
)
SizedBox(height: 25,)
],
),
),
),),
);
}
@ -365,12 +357,12 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
GifLoaderDialogUtils.showMyDialog(context);
await model.sendActivationCodeForDoctorApp(authMethodType:authMethodType, password: widget.password );
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
await authenticationViewModel.sendActivationCodeForDoctorApp(authMethodType:authMethodType, password: widget.password );
if (authenticationViewModel.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(authenticationViewModel.error);
GifLoaderDialogUtils.hideDialog(context);
} else {
model.setDataAfterSendActivationSuccsess(model.activationCodeForDoctorAppRes);
authenticationViewModel.setDataAfterSendActivationSuccsess(authenticationViewModel.activationCodeForDoctorAppRes);
sharedPref.setString(PASSWORD, widget.password);
GifLoaderDialogUtils.hideDialog(context);
this.startSMSService(authMethodType);
@ -385,14 +377,14 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
sendActivationCodeVerificationScreen(AuthMethodTypes authMethodType) async {
GifLoaderDialogUtils.showMyDialog(context);
await model
await authenticationViewModel
.sendActivationCodeVerificationScreen(authMethodType);
if (model.state == ViewState.ErrorLocal) {
if (authenticationViewModel.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
Helpers.showErrorToast(model.error);
Helpers.showErrorToast(authenticationViewModel.error);
} else {
model.setDataAfterSendActivationSuccsess(model.activationCodeVerificationScreenRes);
authenticationViewModel.setDataAfterSendActivationSuccsess(authenticationViewModel.activationCodeVerificationScreenRes);
if (authMethodType == AuthMethodTypes.SMS ||
authMethodType == AuthMethodTypes.WhatsApp) {
GifLoaderDialogUtils.hideDialog(context);
@ -432,7 +424,7 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
}
sendActivationCode(AuthMethodTypes authMethodType) async {
if (model.user != null) {
if (authenticationViewModel.user != null) {
sendActivationCodeVerificationScreen(authMethodType);
} else {
sendActivationCodeByOtpNotificationType(authMethodType);
@ -444,7 +436,7 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
new SMSOTP(
context,
type,
model.loggedUser != null ? model.loggedUser.mobileNumber : model.user.mobile,
authenticationViewModel.loggedUser != null ? authenticationViewModel.loggedUser.mobileNumber : authenticationViewModel.user.mobile,
(value) {
showDialog(
context: context,
@ -465,14 +457,14 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
loginWithFingerPrintOrFaceID(AuthMethodTypes authMethodTypes,
isActive) async {
if (isActive) {
await model.showIOSAuthMessages();
await authenticationViewModel.showIOSAuthMessages();
if (!mounted) return;
if (model.user != null &&
if (authenticationViewModel.user != null &&
(SelectedAuthMethodTypesService.getMethodsTypeService(
model.user.logInTypeID) ==
authenticationViewModel.user.logInTypeID) ==
AuthMethodTypes.Fingerprint ||
SelectedAuthMethodTypesService.getMethodsTypeService(
model.user.logInTypeID) == AuthMethodTypes.FaceID)) {
authenticationViewModel.user.logInTypeID) == AuthMethodTypes.FaceID)) {
this.sendActivationCode(authMethodTypes);
} else {
setState(() {
@ -483,19 +475,19 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
}
checkActivationCode({value}) async {
await model.checkActivationCodeForDoctorApp(activationCode: value);
if (model.state == ViewState.ErrorLocal) {
await authenticationViewModel.checkActivationCodeForDoctorApp(activationCode: value);
if (authenticationViewModel.state == ViewState.ErrorLocal) {
Navigator.pop(context);
Helpers.showErrorToast(model.error);
Helpers.showErrorToast(authenticationViewModel.error);
} else {
await model.onCheckActivationCodeSuccess();
await authenticationViewModel.onCheckActivationCodeSuccess();
navigateToLandingPage();
}
}
navigateToLandingPage() {
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
if (authenticationViewModel.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(authenticationViewModel.error);
} else {
projectsProvider.isLogin = true;

@ -75,13 +75,14 @@ class _HomeScreenState extends State<HomeScreen> {
var clinicId;
var _patientSearchFormValues;
AuthenticationViewModel _IMEIViewModel = locator<AuthenticationViewModel>();
AuthenticationViewModel authenticationViewModel;
void didChangeDependencies() async {
super.didChangeDependencies();
if (_isInit) {
projectsProvider = Provider.of<ProjectViewModel>(context);
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
projectsProvider.getDoctorClinicsList();
// _firebaseMessaging.setAutoInitEnabled(true);
@ -97,7 +98,7 @@ class _HomeScreenState extends State<HomeScreen> {
_firebaseMessaging.getToken().then((String token) async {
if (token != '') {
DEVICE_TOKEN = token;
await _IMEIViewModel.insertDeviceImei();
await authenticationViewModel.insertDeviceImei();
changeIsLoading(false);
}

@ -11,14 +11,14 @@ class VerificationMethodsList extends StatefulWidget {
final AuthMethodTypes authMethodType;
final Function(AuthMethodTypes type, bool isActive) authenticateUser;
final Function onShowMore;
final AuthenticationViewModel model;
final AuthenticationViewModel authenticationViewModel;
const VerificationMethodsList(
{Key key,
this.authMethodType,
this.authenticateUser,
this.onShowMore,
this.model})
this.authenticationViewModel})
: super(key: key);
@override
@ -54,7 +54,7 @@ class _VerificationMethodsListState extends State<VerificationMethodsList> {
return MethodTypeCard(
assetPath: 'assets/images/verification_fingerprint_icon.png',
onTap: () async {
if (await widget.model
if (await widget.authenticationViewModel
.checkIfBiometricAvailable(BiometricType.fingerprint)) {
widget.authenticateUser(AuthMethodTypes.Fingerprint, true);
@ -67,7 +67,7 @@ class _VerificationMethodsListState extends State<VerificationMethodsList> {
return MethodTypeCard(
assetPath: 'assets/images/verification_faceid_icon.png',
onTap: () async {
if (await widget.model
if (await widget.authenticationViewModel
.checkIfBiometricAvailable(BiometricType.face)) {
widget.authenticateUser(AuthMethodTypes.FaceID, true);
}

Loading…
Cancel
Save