From c62340e8346568d18a9251d550fff95b8aacbfbf Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 21 Jun 2020 11:02:07 +0300 Subject: [PATCH 1/2] modify IMEI --- lib/widgets/auth/login_form.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index 1b800613..033f445c 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -300,8 +300,8 @@ class _LoginFormState extends State { try { platformImei = await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false); - idunique = await ImeiPlugin.getId(); - } on PlatformException { + idunique = await ImeiPlugin.getImei(); + } catch(e) { platformImei = 'Failed to get platform version.'; } From 89241460da78f8c9e6792d46f0e83f1d6eeabf2c Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 22 Jun 2020 15:28:29 +0300 Subject: [PATCH 2/2] change clinic name --- lib/providers/auth_provider.dart | 116 +++++++++++++++--------------- lib/screens/dashboard_screen.dart | 2 +- 2 files changed, 60 insertions(+), 58 deletions(-) diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index 11f1667f..22bd80f6 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -20,57 +20,58 @@ const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } - class AuthProvider with ChangeNotifier { - List doctorsClinicList=[]; - bool isLogin= false; + List doctorsClinicList = []; + String selectedClinicName; + bool isLogin = false; bool isLoading = true; - AuthProvider(){ + AuthProvider() { getUserAuthentication(); } - void getUserAuthentication() async{ + void getUserAuthentication() async { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - if(profile != null) - { - isLoading = false; - isLogin = true; - } else { - isLoading = false; - isLogin = false; + if (profile != null) { + isLoading = false; + isLogin = true; + } else { + isLoading = false; + isLogin = false; } notifyListeners(); } + APP_STATUS get stutas { if (isLoading) { return APP_STATUS.LOADING; - } else{ - if ( this.isLogin) { + } else { + if (this.isLogin) { return APP_STATUS.AUTHENTICATED; - } else { + } else { return APP_STATUS.UNAUTHENTICATED; } } } + Future login(UserModel userInfo) async { try { dynamic localRes; await BaseAppClient.post(LOGIN_URL, onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: { - "UserID": userInfo.UserID, - "Password": userInfo.Password, - "ProjectID": userInfo.ProjectID, - "LanguageID": userInfo.LanguageID, - "IPAdress": userInfo.IPAdress, - "VersionID": userInfo.VersionID, - "Channel": userInfo.Channel, - "SessionID": userInfo.SessionID - }); + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: { + "UserID": userInfo.UserID, + "Password": userInfo.Password, + "ProjectID": userInfo.ProjectID, + "LanguageID": userInfo.LanguageID, + "IPAdress": userInfo.IPAdress, + "VersionID": userInfo.VersionID, + "Channel": userInfo.Channel, + "SessionID": userInfo.SessionID + }); return Future.value(localRes); } catch (error) { @@ -85,10 +86,10 @@ class AuthProvider with ChangeNotifier { await BaseAppClient.post(INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: imei); + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: imei); return Future.value(localRes); } catch (error) { print(error); @@ -101,10 +102,10 @@ class AuthProvider with ChangeNotifier { dynamic localRes; await BaseAppClient.post(SELECT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: imei); + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: imei); return Future.value(localRes); } catch (error) { print(error); @@ -112,16 +113,15 @@ class AuthProvider with ChangeNotifier { } } - Future sendActivationCodeByOtpNotificationType( - activationCodeModel) async { + Future sendActivationCodeByOtpNotificationType(activationCodeModel) async { try { var localRes; await BaseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE, onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: activationCodeModel); + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: activationCodeModel); return Future.value(localRes); } catch (error) { print(error); @@ -134,15 +134,16 @@ class AuthProvider with ChangeNotifier { dynamic localRes; await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW, onSuccess: (dynamic response, int statusCode) { - localRes = response; - - response['List_DoctorsClinic'].forEach((v) { - doctorsClinicList.add(new ClinicModel.fromJson(v)); - }); - - }, onFailure: (String error, int statusCode) { - throw error; - }, body: activationCodeModel); + localRes = response; + selectedClinicName = + ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName; + notifyListeners(); + response['List_DoctorsClinic'].forEach((v) { + doctorsClinicList.add(new ClinicModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + throw error; + }, body: activationCodeModel); return Future.value(localRes); } catch (error) { print(error); @@ -162,16 +163,17 @@ class AuthProvider with ChangeNotifier { dynamic localRes; await BaseAppClient.post(GET_DOC_PROFILES, onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: docInfo); + localRes = response; + //ClinicDescription + selectedClinicName = response['DoctorProfileList'][0]['ClinicDescription']; + notifyListeners(); + }, onFailure: (String error, int statusCode) { + throw error; + }, body: docInfo); return Future.value(localRes); } catch (error) { print(error); throw error; } } - - } diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index b4448d23..fd4d0ffb 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -74,7 +74,7 @@ class _DashboardScreenState extends State { Container( margin: EdgeInsets.only(left: 10, top: 10), child: AppText( - TranslationBase.of(context).familyMedicine, + authProvider.selectedClinicName != null?authProvider.selectedClinicName:'', fontWeight: FontWeight.bold, fontSize: SizeConfig.textMultiplier * 2.5, ),