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) {
onFailure(getError(parsed), statusCode);
} 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');
}
if (isAllowAny) {

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

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

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

@ -259,15 +259,16 @@ class _LoginScreenState extends State<LoginScreen> {
Helpers.showErrorToast(authenticationViewModel.error);
} else {
GifLoaderDialogUtils.hideDialog(context);
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (BuildContext context) =>
VerificationMethodsScreen(
password: authenticationViewModel.userInfo.password,
),
),
);
authenticationViewModel.setUnverified(true,isFromLogin: true);
// Navigator.of(context).pushReplacement(
// MaterialPageRoute(
// builder: (BuildContext context) =>
// VerificationMethodsScreen(
// 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_texts_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/transitions/fade_page.dart';
import 'package:flutter/material.dart';
@ -32,10 +33,13 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
class VerificationMethodsScreen extends StatefulWidget {
VerificationMethodsScreen({this.password});
final password;
VerificationMethodsScreen({this.password, });
@override
_VerificationMethodsScreenState createState() => _VerificationMethodsScreenState();
}
@ -72,9 +76,11 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
SizedBox(
height: 80,
),
if(authenticationViewModel.isFromLogin)
InkWell(
onTap: (){
Navigator.of(context).pop();
authenticationViewModel.setUnverified(false,isFromLogin: false);
authenticationViewModel.setAppStatus(APP_STATUS.UNAUTHENTICATED);
},
child: Icon(Icons.arrow_back_ios,color: Color(0xFF2B353E),)
@ -392,20 +398,21 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AppButton(
title: TranslationBase
SecondaryButton(
label: TranslationBase
.of(context)
.useAnotherAccount,
color: Color(0xFFD02127),fontWeight: FontWeight.w700,
onPressed: () {
color: Color(0xFFD02127),
//fontWeight: FontWeight.w700,
onTap: () {
authenticationViewModel.deleteUser();
Navigator.pushAndRemoveUntil(
AppGlobal.CONTEX,
FadePage(
page: RootPage(),
),
(r) => false);
authenticationViewModel.setAppStatus(APP_STATUS.UNAUTHENTICATED);
// Navigator.pushAndRemoveUntil(
// AppGlobal.CONTEX,
// FadePage(
// page: RootPage(),
// ),
// (r) => false);
// Navigator.of(context).pushNamed(LOGIN);
},
),
@ -425,13 +432,13 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
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) {
Helpers.showErrorToast(authenticationViewModel.error);
GifLoaderDialogUtils.hideDialog(context);
} else {
authenticationViewModel.setDataAfterSendActivationSuccess(authenticationViewModel.activationCodeForDoctorAppRes);
sharedPref.setString(PASSWORD, widget.password);
sharedPref.setString(PASSWORD, authenticationViewModel.userInfo.password);
GifLoaderDialogUtils.hideDialog(context);
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/model/patient_muse/PatientSearchRequestModel.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/util/date-utils.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/widgets/patients/profile/profile-welcome-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(
projectsProvider, authenticationViewModel);
await model.getDashboard();
await model.getDoctorProfile(isGetProfile: true);
},
builder: (_, model, w) => AppScaffold(
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/util/helpers.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/widgets.dart';
import 'package:provider/provider.dart';
@ -172,7 +173,8 @@ class _AppDrawerState extends State<AppDrawer> {
),
onTap: () async {
Navigator.pop(context);
await authenticationViewModel.logout();
GifLoaderDialogUtils.showMyDialog(context);
await authenticationViewModel.logout(isFromLogin: false);
},
),
],

Loading…
Cancel
Save