Merge branch 'elham' into 'development'

Elham

See merge request Cloud_Solution/doctor_app_flutter!134
merge-requests/135/head
Elham 6 years ago
commit c35c6f7444

@ -20,57 +20,58 @@ const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
class AuthProvider with ChangeNotifier { class AuthProvider with ChangeNotifier {
List <ClinicModel>doctorsClinicList=[]; List<ClinicModel> doctorsClinicList = [];
bool isLogin= false; String selectedClinicName;
bool isLogin = false;
bool isLoading = true; bool isLoading = true;
AuthProvider(){ AuthProvider() {
getUserAuthentication(); getUserAuthentication();
} }
void getUserAuthentication() async{ void getUserAuthentication() async {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE); Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
if(profile != null) if (profile != null) {
{ isLoading = false;
isLoading = false; isLogin = true;
isLogin = true; } else {
} else { isLoading = false;
isLoading = false; isLogin = false;
isLogin = false;
} }
notifyListeners(); notifyListeners();
} }
APP_STATUS get stutas { APP_STATUS get stutas {
if (isLoading) { if (isLoading) {
return APP_STATUS.LOADING; return APP_STATUS.LOADING;
} else{ } else {
if ( this.isLogin) { if (this.isLogin) {
return APP_STATUS.AUTHENTICATED; return APP_STATUS.AUTHENTICATED;
} else { } else {
return APP_STATUS.UNAUTHENTICATED; return APP_STATUS.UNAUTHENTICATED;
} }
} }
} }
Future<dynamic> login(UserModel userInfo) async { Future<dynamic> login(UserModel userInfo) async {
try { try {
dynamic localRes; dynamic localRes;
await BaseAppClient.post(LOGIN_URL, await BaseAppClient.post(LOGIN_URL,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: { }, body: {
"UserID": userInfo.UserID, "UserID": userInfo.UserID,
"Password": userInfo.Password, "Password": userInfo.Password,
"ProjectID": userInfo.ProjectID, "ProjectID": userInfo.ProjectID,
"LanguageID": userInfo.LanguageID, "LanguageID": userInfo.LanguageID,
"IPAdress": userInfo.IPAdress, "IPAdress": userInfo.IPAdress,
"VersionID": userInfo.VersionID, "VersionID": userInfo.VersionID,
"Channel": userInfo.Channel, "Channel": userInfo.Channel,
"SessionID": userInfo.SessionID "SessionID": userInfo.SessionID
}); });
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
@ -85,10 +86,10 @@ class AuthProvider with ChangeNotifier {
await BaseAppClient.post(INSERT_DEVICE_IMEI, await BaseAppClient.post(INSERT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: imei); }, body: imei);
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
print(error); print(error);
@ -101,10 +102,10 @@ class AuthProvider with ChangeNotifier {
dynamic localRes; dynamic localRes;
await BaseAppClient.post(SELECT_DEVICE_IMEI, await BaseAppClient.post(SELECT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: imei); }, body: imei);
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
print(error); print(error);
@ -112,16 +113,15 @@ class AuthProvider with ChangeNotifier {
} }
} }
Future sendActivationCodeByOtpNotificationType( Future sendActivationCodeByOtpNotificationType(activationCodeModel) async {
activationCodeModel) async {
try { try {
var localRes; var localRes;
await BaseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE, await BaseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: activationCodeModel); }, body: activationCodeModel);
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
print(error); print(error);
@ -134,15 +134,16 @@ class AuthProvider with ChangeNotifier {
dynamic localRes; dynamic localRes;
await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW, await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
selectedClinicName =
response['List_DoctorsClinic'].forEach((v) { ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName;
doctorsClinicList.add(new ClinicModel.fromJson(v)); notifyListeners();
}); response['List_DoctorsClinic'].forEach((v) {
doctorsClinicList.add(new ClinicModel.fromJson(v));
}, onFailure: (String error, int statusCode) { });
throw error; }, onFailure: (String error, int statusCode) {
}, body: activationCodeModel); throw error;
}, body: activationCodeModel);
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
print(error); print(error);
@ -162,16 +163,17 @@ class AuthProvider with ChangeNotifier {
dynamic localRes; dynamic localRes;
await BaseAppClient.post(GET_DOC_PROFILES, await BaseAppClient.post(GET_DOC_PROFILES,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { //ClinicDescription
throw error; selectedClinicName = response['DoctorProfileList'][0]['ClinicDescription'];
}, body: docInfo); notifyListeners();
}, onFailure: (String error, int statusCode) {
throw error;
}, body: docInfo);
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
print(error); print(error);
throw error; throw error;
} }
} }
} }

@ -77,7 +77,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Container( Container(
margin: EdgeInsets.only(left: 10, top: 10), margin: EdgeInsets.only(left: 10, top: 10),
child: AppText( child: AppText(
TranslationBase.of(context).familyMedicine, authProvider.selectedClinicName != null?authProvider.selectedClinicName:'',
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: SizeConfig.textMultiplier * 2.5, fontSize: SizeConfig.textMultiplier * 2.5,
), ),

@ -300,8 +300,8 @@ class _LoginFormState extends State<LoginForm> {
try { try {
platformImei = platformImei =
await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false); await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false);
idunique = await ImeiPlugin.getId(); idunique = await ImeiPlugin.getImei();
} on PlatformException { } catch(e) {
platformImei = 'Failed to get platform version.'; platformImei = 'Failed to get platform version.';
} }

Loading…
Cancel
Save