|
|
|
|
@ -23,6 +23,7 @@ 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/root_page.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/auth/login_screen.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
|
|
|
@ -77,6 +78,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
getDoctorProfile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// select Device IMEI
|
|
|
|
|
Future selectDeviceImei(imei) async {
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
await _authService.selectDeviceImei(imei);
|
|
|
|
|
@ -87,6 +89,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Insert Device IMEI
|
|
|
|
|
Future insertDeviceImei() async {
|
|
|
|
|
var loggedIn = await sharedPref.getObj(LOGGED_IN_USER);
|
|
|
|
|
var user = await sharedPref.getObj(LAST_LOGIN_USER);
|
|
|
|
|
@ -125,6 +128,8 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// first step login
|
|
|
|
|
Future login(UserModel userInfo) async {
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
await _authService.login(userInfo);
|
|
|
|
|
@ -141,6 +146,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// send activation code for for msg methods
|
|
|
|
|
Future sendActivationCodeVerificationScreen( AuthMethodTypes authMethodType) async {
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
ActivationCodeForVerificationScreenModel activationCodeModel =
|
|
|
|
|
@ -162,6 +168,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// send activation code for silent login
|
|
|
|
|
Future sendActivationCodeForDoctorApp({AuthMethodTypes authMethodType, String password }) async {
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
@ -180,6 +187,8 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// check activation
|
|
|
|
|
Future checkActivationCodeForDoctorApp({String activationCode}) async {
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp =
|
|
|
|
|
@ -204,7 +213,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// get list of Hospitals
|
|
|
|
|
Future getHospitalsList(memberID) async {
|
|
|
|
|
GetHospitalsRequestModel getHospitalsRequestModel =GetHospitalsRequestModel();
|
|
|
|
|
getHospitalsRequestModel.memberID = memberID;
|
|
|
|
|
@ -216,6 +225,8 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// get type name based on id.
|
|
|
|
|
getType(type, context) {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 1:
|
|
|
|
|
@ -242,7 +253,8 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setDataAfterSendActivationSuccsess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) {
|
|
|
|
|
/// add some logic in case of send activation code is success
|
|
|
|
|
setDataAfterSendActivationSuccess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) {
|
|
|
|
|
print("VerificationCode : " +
|
|
|
|
|
sendActivationCodeForDoctorAppResponseModel.verificationCode);
|
|
|
|
|
sharedPref.setString(VIDA_AUTH_TOKEN_ID,
|
|
|
|
|
@ -257,6 +269,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
sharedPref.setObj(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// ask user to add his biometric
|
|
|
|
|
showIOSAuthMessages() async {
|
|
|
|
|
const iosStrings = const IOSAuthMessages(
|
|
|
|
|
cancelButton: 'cancel',
|
|
|
|
|
@ -275,10 +288,12 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// add profile to base view model super class
|
|
|
|
|
localSetDoctorProfile(DoctorProfileModel profile) {
|
|
|
|
|
super.setDoctorProfile(profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// get doctor profile based on clinic model
|
|
|
|
|
Future getDoctorProfileBasedOnClinic(ClinicModel clinicInfo) async {
|
|
|
|
|
ProfileReqModel docInfo = new ProfileReqModel(
|
|
|
|
|
doctorID: clinicInfo.doctorID,
|
|
|
|
|
@ -297,6 +312,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// add some logic in case of check activation code is success
|
|
|
|
|
onCheckActivationCodeSuccess() async {
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
TOKEN,
|
|
|
|
|
@ -317,6 +333,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// check specific biometric if it available or not
|
|
|
|
|
Future <bool> checkIfBiometricAvailable(BiometricType biometricType) async {
|
|
|
|
|
bool isAvailable = false;
|
|
|
|
|
await _getAvailableBiometrics();
|
|
|
|
|
@ -328,6 +345,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
return isAvailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// get all available biometric on the device for local Auth service
|
|
|
|
|
Future<void> _getAvailableBiometrics() async {
|
|
|
|
|
try {
|
|
|
|
|
_availableBiometrics = await auth.getAvailableBiometrics();
|
|
|
|
|
@ -336,7 +354,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// call firebase service to check if the user already login in before or not
|
|
|
|
|
getDeviceInfoFromFirebase() async {
|
|
|
|
|
_firebaseMessaging.setAutoInitEnabled(true);
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
@ -367,7 +385,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// determine the status of the app
|
|
|
|
|
APP_STATUS get status {
|
|
|
|
|
if (state == ViewState.Busy) {
|
|
|
|
|
return APP_STATUS.LOADING;
|
|
|
|
|
@ -382,7 +400,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// logout function
|
|
|
|
|
logout() async {
|
|
|
|
|
DEVICE_TOKEN = "";
|
|
|
|
|
String lang = await sharedPref.getString(APP_Language);
|
|
|
|
|
@ -392,7 +410,7 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
AppGlobal.CONTEX,
|
|
|
|
|
FadePage(
|
|
|
|
|
page: LoginScreen(),
|
|
|
|
|
page: RootPage(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
}
|
|
|
|
|
|