|
|
|
|
@ -1,11 +1,13 @@
|
|
|
|
|
import 'dart:io' show Platform;
|
|
|
|
|
|
|
|
|
|
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/imei_details.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/imei_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/auth/send_activation_code_model2.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/auth/activation_code_for_verification_screen_model.dart';
|
|
|
|
|
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';
|
|
|
|
|
@ -15,6 +17,7 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/otp/sms-popup.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/transitions/fade_page.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
@ -35,10 +38,11 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
|
|
|
|
Helpers helpers = Helpers();
|
|
|
|
|
|
|
|
|
|
class VerificationMethods extends StatefulWidget {
|
|
|
|
|
VerificationMethods({this.changeLoadingState, this.password});
|
|
|
|
|
VerificationMethods({this.changeLoadingState, this.password, this.model});
|
|
|
|
|
|
|
|
|
|
final password;
|
|
|
|
|
final Function changeLoadingState;
|
|
|
|
|
final IMEIViewModel model;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_VerificationMethodsState createState() => _VerificationMethodsState();
|
|
|
|
|
@ -330,8 +334,10 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
oTPSendType, AuthViewModel authProv) async {
|
|
|
|
|
// TODO : build enum for verfication method
|
|
|
|
|
if (oTPSendType == 1 || oTPSendType == 2) {
|
|
|
|
|
widget.changeLoadingState(true);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
// TODO create model for _loggedUser;
|
|
|
|
|
ActivationCodeModel activationCodeModel = ActivationCodeModel(
|
|
|
|
|
facilityId: projectID,
|
|
|
|
|
memberID: _loggedUser['List_MemberInformation'][0]['MemberID'],
|
|
|
|
|
@ -339,49 +345,34 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
mobileNumber: _loggedUser['MobileNumber'],
|
|
|
|
|
otpSendType: oTPSendType.toString(),
|
|
|
|
|
password: widget.password);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
authProv
|
|
|
|
|
.sendActivationCodeForDoctorApp(activationCodeModel)
|
|
|
|
|
.then((res) {
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
print("VerificationCode : " + res["VerificationCode"]);
|
|
|
|
|
sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]);
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]);
|
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]);
|
|
|
|
|
sharedPref.setString(PASSWORD, widget.password);
|
|
|
|
|
this.startSMSService(oTPSendType, authProv);
|
|
|
|
|
} else {
|
|
|
|
|
print(res['ErrorEndUserMessage']);
|
|
|
|
|
Helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print('$err');
|
|
|
|
|
widget.changeLoadingState(false);
|
|
|
|
|
|
|
|
|
|
Helpers.showErrorToast();
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
await widget.model
|
|
|
|
|
.sendActivationCodeForDoctorApp(activationCodeModel);
|
|
|
|
|
if(widget.model.state == ViewState.ErrorLocal) {
|
|
|
|
|
Helpers.showErrorToast(widget.model.error);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
}else{
|
|
|
|
|
print("VerificationCode : " + widget.model.activationCodeForDoctorAppRes["VerificationCode"]);
|
|
|
|
|
sharedPref.setString(VIDA_AUTH_TOKEN_ID, widget.model.activationCodeForDoctorAppRes["VidaAuthTokenID"]);
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
VIDA_REFRESH_TOKEN_ID, widget.model.activationCodeForDoctorAppRes["VidaRefreshTokenID"]);
|
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, widget.model.activationCodeForDoctorAppRes["LogInTokenID"]);
|
|
|
|
|
sharedPref.setString(PASSWORD, widget.password);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
this.startSMSService(oTPSendType, authProv);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// TODO route to this page with parameters to inicate we should present 2 option
|
|
|
|
|
if (Platform.isAndroid && oTPSendType == 3) {
|
|
|
|
|
Helpers.showErrorToast('Your device not support this feature');
|
|
|
|
|
} else {
|
|
|
|
|
// Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
// builder: (BuildContext context) =>
|
|
|
|
|
// VerificationMethodsScreen(password: widget.password,)));
|
|
|
|
|
|
|
|
|
|
// Navigator.of(context).pushNamed(VERIFICATION_METHODS,
|
|
|
|
|
// arguments: {'verificationMethod': oTPSendType});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendActivationCodeVerificationScreen(
|
|
|
|
|
oTPSendType, AuthViewModel authProv) async {
|
|
|
|
|
widget.changeLoadingState(true);
|
|
|
|
|
ActivationCodeModel2 activationCodeModel = ActivationCodeModel2(
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
ActivationCodeForVerificationScreenModel activationCodeModel = ActivationCodeForVerificationScreenModel(
|
|
|
|
|
iMEI: user.iMEI,
|
|
|
|
|
facilityId: user.projectID,
|
|
|
|
|
memberID: user.doctorID,
|
|
|
|
|
@ -392,37 +383,25 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
vidaAuthTokenID: user.vidaAuthTokenID,
|
|
|
|
|
vidaRefreshTokenID: user.vidaRefreshTokenID);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
authProv
|
|
|
|
|
.sendActivationCodeVerificationScreen(activationCodeModel)
|
|
|
|
|
.then((res) {
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
print("VerificationCode : " + res["VerificationCode"]);
|
|
|
|
|
sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]);
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]);
|
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]);
|
|
|
|
|
if (oTPSendType == 1 || oTPSendType == 2) {
|
|
|
|
|
widget.changeLoadingState(false);
|
|
|
|
|
this.startSMSService(oTPSendType, authProv);
|
|
|
|
|
} else {
|
|
|
|
|
checkActivationCode(authProv);
|
|
|
|
|
}
|
|
|
|
|
await widget.model
|
|
|
|
|
.sendActivationCodeVerificationScreen(activationCodeModel);
|
|
|
|
|
|
|
|
|
|
if(widget.model.state == ViewState.ErrorLocal) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Helpers.showErrorToast(widget.model.error);
|
|
|
|
|
} else {
|
|
|
|
|
print("VerificationCode : " + widget.model.activationCodeVerificationScreenRes["VerificationCode"]);
|
|
|
|
|
sharedPref.setString(VIDA_AUTH_TOKEN_ID, widget.model.activationCodeVerificationScreenRes["VidaAuthTokenID"]);
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
VIDA_REFRESH_TOKEN_ID, widget.model.activationCodeVerificationScreenRes["VidaRefreshTokenID"]);
|
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, widget.model.activationCodeVerificationScreenRes["LogInTokenID"]);
|
|
|
|
|
if (oTPSendType == 1 || oTPSendType == 2) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
this.startSMSService(oTPSendType, authProv);
|
|
|
|
|
} else {
|
|
|
|
|
print(res['ErrorEndUserMessage']);
|
|
|
|
|
Helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
checkActivationCode(authProv);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print('$err');
|
|
|
|
|
widget.changeLoadingState(false);
|
|
|
|
|
|
|
|
|
|
Helpers.showErrorToast();
|
|
|
|
|
});
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// checkActivationCode(authProv);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget getButton(flag, authProv) {
|
|
|
|
|
@ -741,7 +720,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
stickyAuth: true,
|
|
|
|
|
iOSAuthStrings: iosStrings);
|
|
|
|
|
} on PlatformException catch (e) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(e);
|
|
|
|
|
DrAppToastMsg.showErrorToast(e.toString());
|
|
|
|
|
}
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
if (user != null && (user.logInTypeID == 3 || user.logInTypeID == 4)) {
|
|
|
|
|
@ -769,30 +748,47 @@ class _VerificationMethodsState extends State<VerificationMethods> {
|
|
|
|
|
activationCode: value ?? '0000',
|
|
|
|
|
oTPSendType: await sharedPref.getInt(OTP_TYPE),
|
|
|
|
|
generalid: "Cs2020@2016\$2958");
|
|
|
|
|
await widget.model.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp);
|
|
|
|
|
|
|
|
|
|
authProv
|
|
|
|
|
.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp)
|
|
|
|
|
.then((res) async {
|
|
|
|
|
widget.changeLoadingState(false);
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
|
|
|
|
|
if (res['List_DoctorProfile'] != null) {
|
|
|
|
|
loginProcessCompleted(res['List_DoctorProfile'][0], authProv);
|
|
|
|
|
sharedPref.setObj(CLINIC_NAME, res['List_DoctorsClinic']);
|
|
|
|
|
} else {
|
|
|
|
|
sharedPref.setObj(CLINIC_NAME, res['List_DoctorsClinic']);
|
|
|
|
|
ClinicModel clinic =
|
|
|
|
|
ClinicModel.fromJson(res['List_DoctorsClinic'][0]);
|
|
|
|
|
getDocProfiles(clinic, authProv);
|
|
|
|
|
}
|
|
|
|
|
if(widget.model.state == ViewState.ErrorLocal){
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Helpers.showErrorToast(widget.model.error);
|
|
|
|
|
} else {
|
|
|
|
|
sharedPref.setString(TOKEN, widget.model.checkActivationCodeForDoctorAppRes['AuthenticationTokenID']);
|
|
|
|
|
if (widget.model.checkActivationCodeForDoctorAppRes['List_DoctorProfile'] != null) {
|
|
|
|
|
loginProcessCompleted(widget.model.checkActivationCodeForDoctorAppRes['List_DoctorProfile'][0], authProv);
|
|
|
|
|
sharedPref.setObj(CLINIC_NAME, widget.model.checkActivationCodeForDoctorAppRes['List_DoctorsClinic']);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
sharedPref.setObj(CLINIC_NAME, widget.model.checkActivationCodeForDoctorAppRes['List_DoctorsClinic']);
|
|
|
|
|
ClinicModel clinic =
|
|
|
|
|
ClinicModel.fromJson(widget.model.checkActivationCodeForDoctorAppRes['List_DoctorsClinic'][0]);
|
|
|
|
|
getDocProfiles(clinic, authProv);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Helpers.showErrorToast(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// authProv
|
|
|
|
|
// .checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp)
|
|
|
|
|
// .then((res) async {
|
|
|
|
|
// widget.changeLoadingState(false);
|
|
|
|
|
// if (res['MessageStatus'] == 1) {
|
|
|
|
|
// sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
|
|
|
|
|
// if (res['List_DoctorProfile'] != null) {
|
|
|
|
|
// loginProcessCompleted(res['List_DoctorProfile'][0], authProv);
|
|
|
|
|
// sharedPref.setObj(CLINIC_NAME, res['List_DoctorsClinic']);
|
|
|
|
|
// } else {
|
|
|
|
|
// sharedPref.setObj(CLINIC_NAME, res['List_DoctorsClinic']);
|
|
|
|
|
// ClinicModel clinic =
|
|
|
|
|
// ClinicModel.fromJson(res['List_DoctorsClinic'][0]);
|
|
|
|
|
// getDocProfiles(clinic, authProv);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// Helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
// }
|
|
|
|
|
// }).catchError((err) {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// Helpers.showErrorToast(err);
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loginProcessCompleted(Map<String, dynamic> profile, authProv) {
|
|
|
|
|
|