Merge branch 'development' into medical-profile-services

merge-requests/672/head
mosazaid 5 years ago
commit 9e552668c7

@ -104,7 +104,7 @@ class BaseAppClient {
if (body['OTP_SendType'] != null) { if (body['OTP_SendType'] != null) {
onFailure(getError(parsed), statusCode); onFailure(getError(parsed), statusCode);
} else if (!isAllowAny) { } else if (!isAllowAny) {
await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX, listen: false).logout(isSessionTimeout: true); await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX, listen: false).logout();
Helpers.showErrorToast('Your session expired Please login again'); Helpers.showErrorToast('Your session expired Please login again');
} }
if (isAllowAny) { if (isAllowAny) {

@ -127,6 +127,7 @@ class AuthenticationService extends BaseService {
Future insertDeviceImei(InsertIMEIDetailsModel insertIMEIDetailsModel)async { Future insertDeviceImei(InsertIMEIDetailsModel insertIMEIDetailsModel)async {
hasError = false; hasError = false;
// insertIMEIDetailsModel.tokenID = "@dm!n";
_insertDeviceImeiRes = {}; _insertDeviceImeiRes = {};
try { try {
await baseAppClient.post(INSERT_DEVICE_IMEI, await baseAppClient.post(INSERT_DEVICE_IMEI,

@ -72,6 +72,8 @@ class AuthenticationViewModel extends BaseViewModel {
bool isLogin = false; bool isLogin = false;
bool unverified = false; bool unverified = false;
bool isFromLogin = false;
APP_STATUS app_status = APP_STATUS.LOADING;
AuthenticationViewModel({bool checkDeviceInfo = false}) { AuthenticationViewModel({bool checkDeviceInfo = false}) {
getDeviceInfoFromFirebase(); getDeviceInfoFromFirebase();
@ -386,27 +388,41 @@ class AuthenticationViewModel extends BaseViewModel {
/// determine the status of the app /// determine the status of the app
APP_STATUS get status { APP_STATUS get status {
if (state == ViewState.Busy) { if (state == ViewState.Busy) {
return APP_STATUS.LOADING; app_status = APP_STATUS.LOADING;
} else { } else {
if (this.unverified) { if(this.doctorProfile !=null)
return APP_STATUS.UNVERIFIED; app_status = APP_STATUS.AUTHENTICATED;
else if (this.unverified) {
app_status = APP_STATUS.UNVERIFIED;
} else if (this.isLogin) { } else if (this.isLogin) {
return APP_STATUS.AUTHENTICATED; app_status = APP_STATUS.AUTHENTICATED;
} else { } else {
return APP_STATUS.UNAUTHENTICATED; app_status = APP_STATUS.UNAUTHENTICATED;
} }
} }
return app_status;
}
setAppStatus(APP_STATUS status){
this.app_status = status;
notifyListeners();
}
setUnverified(bool unverified,{bool isFromLogin = false}){
this.unverified = unverified;
this.isFromLogin = isFromLogin;
notifyListeners();
} }
/// logout function /// logout function
logout({bool isSessionTimeout = false}) async { logout({bool isFromLogin = false}) async {
DEVICE_TOKEN = ""; DEVICE_TOKEN = "";
String lang = await sharedPref.getString(APP_Language); String lang = await sharedPref.getString(APP_Language);
await Helpers.clearSharedPref(); await Helpers.clearSharedPref();
doctorProfile = null;
sharedPref.setString(APP_Language, lang); sharedPref.setString(APP_Language, lang);
deleteUser(); deleteUser();
if(isSessionTimeout)
await getDeviceInfoFromFirebase(); await getDeviceInfoFromFirebase();
this.isFromLogin = isFromLogin;
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
AppGlobal.CONTEX, AppGlobal.CONTEX,
FadePage( FadePage(
@ -419,7 +435,7 @@ class AuthenticationViewModel extends BaseViewModel {
user = null; user = null;
unverified = false; unverified = false;
isLogin = false; isLogin = false;
notifyListeners(); // notifyListeners();
} }
} }

@ -47,8 +47,8 @@ class BaseViewModel extends ChangeNotifier {
} }
} }
setDoctorProfile(DoctorProfileModel doctorProfile){ setDoctorProfile(DoctorProfileModel doctorProfile)async {
sharedPref.setObj(DOCTOR_PROFILE, doctorProfile); await sharedPref.setObj(DOCTOR_PROFILE, doctorProfile);
doctorProfile = doctorProfile; this.doctorProfile = doctorProfile;
} }
} }

@ -259,15 +259,16 @@ class _LoginScreenState extends State<LoginScreen> {
Helpers.showErrorToast(authenticationViewModel.error); Helpers.showErrorToast(authenticationViewModel.error);
} else { } else {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
authenticationViewModel.setUnverified(true,isFromLogin: true);
Navigator.of(context).pushReplacement( // Navigator.of(context).pushReplacement(
MaterialPageRoute( // MaterialPageRoute(
builder: (BuildContext context) => // builder: (BuildContext context) =>
VerificationMethodsScreen( // VerificationMethodsScreen(
password: authenticationViewModel.userInfo.password, // password: authenticationViewModel.userInfo.password,
), // isFromLogin: true,
), // ),
); // ),
// );
} }
} }
} }

@ -13,6 +13,7 @@ import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_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/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/secondary_button.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.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:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -32,10 +33,13 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers(); Helpers helpers = Helpers();
class VerificationMethodsScreen extends StatefulWidget { class VerificationMethodsScreen extends StatefulWidget {
VerificationMethodsScreen({this.password});
final password; final password;
VerificationMethodsScreen({this.password, });
@override @override
_VerificationMethodsScreenState createState() => _VerificationMethodsScreenState(); _VerificationMethodsScreenState createState() => _VerificationMethodsScreenState();
} }
@ -72,9 +76,11 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
SizedBox( SizedBox(
height: 80, height: 80,
), ),
if(authenticationViewModel.isFromLogin)
InkWell( InkWell(
onTap: (){ onTap: (){
Navigator.of(context).pop(); authenticationViewModel.setUnverified(false,isFromLogin: false);
authenticationViewModel.setAppStatus(APP_STATUS.UNAUTHENTICATED);
}, },
child: Icon(Icons.arrow_back_ios,color: Color(0xFF2B353E),) child: Icon(Icons.arrow_back_ios,color: Color(0xFF2B353E),)
@ -392,20 +398,21 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
AppButton( SecondaryButton(
title: TranslationBase label: TranslationBase
.of(context) .of(context)
.useAnotherAccount, .useAnotherAccount,
color: Color(0xFFD02127),fontWeight: FontWeight.w700, color: Color(0xFFD02127),
onPressed: () { //fontWeight: FontWeight.w700,
onTap: () {
authenticationViewModel.deleteUser(); authenticationViewModel.deleteUser();
authenticationViewModel.setAppStatus(APP_STATUS.UNAUTHENTICATED);
Navigator.pushAndRemoveUntil( // Navigator.pushAndRemoveUntil(
AppGlobal.CONTEX, // AppGlobal.CONTEX,
FadePage( // FadePage(
page: RootPage(), // page: RootPage(),
), // ),
(r) => false); // (r) => false);
// Navigator.of(context).pushNamed(LOGIN); // Navigator.of(context).pushNamed(LOGIN);
}, },
), ),
@ -425,13 +432,13 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await authenticationViewModel.sendActivationCodeForDoctorApp(authMethodType:authMethodType, password: widget.password ); await authenticationViewModel.sendActivationCodeForDoctorApp(authMethodType:authMethodType, password: authenticationViewModel.userInfo.password );
if (authenticationViewModel.state == ViewState.ErrorLocal) { if (authenticationViewModel.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(authenticationViewModel.error); Helpers.showErrorToast(authenticationViewModel.error);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} else { } else {
authenticationViewModel.setDataAfterSendActivationSuccess(authenticationViewModel.activationCodeForDoctorAppRes); authenticationViewModel.setDataAfterSendActivationSuccess(authenticationViewModel.activationCodeForDoctorAppRes);
sharedPref.setString(PASSWORD, widget.password); sharedPref.setString(PASSWORD, authenticationViewModel.userInfo.password);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
this.startSMSService(authMethodType); this.startSMSService(authMethodType);
} }

@ -1,3 +1,4 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
@ -19,6 +20,7 @@ import 'package:doctor_app_flutter/screens/patients/patient_search/patient_searc
import 'package:doctor_app_flutter/screens/patients/profile/referral/patient_referral_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/referral/patient_referral_screen.dart';
import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
@ -69,6 +71,7 @@ class _HomeScreenState extends State<HomeScreen> {
await model.setFirebaseNotification( await model.setFirebaseNotification(
projectsProvider, authenticationViewModel); projectsProvider, authenticationViewModel);
await model.getDashboard(); await model.getDashboard();
await model.getDoctorProfile(isGetProfile: true);
}, },
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,

@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/screens/reschedule-leaves/add-rescheduleleave.dart'; import 'package:doctor_app_flutter/screens/reschedule-leaves/add-rescheduleleave.dart';
import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -172,7 +173,8 @@ class _AppDrawerState extends State<AppDrawer> {
), ),
onTap: () async { onTap: () async {
Navigator.pop(context); Navigator.pop(context);
await authenticationViewModel.logout(); GifLoaderDialogUtils.showMyDialog(context);
await authenticationViewModel.logout(isFromLogin: false);
}, },
), ),
], ],

Loading…
Cancel
Save