diff --git a/lib/config/config.dart b/lib/config/config.dart index 261fcd46..1054b1d0 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -16,6 +16,8 @@ const PATIENT_REFER_TO_DOCTOR_URL = "Services/DoctorApplication.svc/REST/ReferToDoctor"; const PATIENT_GET_DOCTOR_BY_CLINIC_URL = "Services/DoctorApplication.svc/REST/GetDoctorsByClinicID"; +const GET_CLINICS_FOR_DOCTOR = + 'Services/DoctorApplication.svc/REST/GetClinicsForDoctor'; const PATIENT_GET_LIST_REFERAL_URL = "Services/Lists.svc/REST/GetList_STPReferralFrequency"; const PATIENT_GET_CLINIC_BY_PROJECT_URL = @@ -35,23 +37,43 @@ const START_LIVECARE_CALL = 'LiveCareApi/DoctorApp/CallPatient'; const LIVE_CARE_STATISTICS_FOR_CERTAIN_DOCTOR_URL = "Lists.svc/REST/DashBoard_GetLiveCareDoctorsStatsticsForCertainDoctor"; -const GET_PRESCRIPTION_REPORT = 'Services/Patients.svc/REST/GetPrescriptionReport'; +const GET_PRESCRIPTION_REPORT = + 'Services/Patients.svc/REST/GetPrescriptionReport'; -const GT_MY_PATIENT_QUESTION = 'Services/DoctorApplication.svc/REST/GtMyPatientsQuestions'; +const GT_MY_PATIENT_QUESTION = + 'Services/DoctorApplication.svc/REST/GtMyPatientsQuestions'; const GET_PATIENT = 'Services/DoctorApplication.svc/REST/'; -const GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT= 'Services/DoctorApplication.svc/REST/GetPrescriptionReportForInPatient'; +const GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT = + 'Services/DoctorApplication.svc/REST/GetPrescriptionReportForInPatient'; -const GET_MY_REFERRAL_PATIENT = 'Services/DoctorApplication.svc/REST/GtMyReferralPatient'; +const GET_MY_REFERRAL_PATIENT = + 'Services/DoctorApplication.svc/REST/GtMyReferralPatient'; -const ADD_REFERRED_DOCTOR_REMARKS= 'Services/DoctorApplication.svc/REST/AddReferredDoctorRemarks'; +const ADD_REFERRED_DOCTOR_REMARKS = + 'Services/DoctorApplication.svc/REST/AddReferredDoctorRemarks'; -const GET_MY_REFERRED_PATIENT = 'Services/DoctorApplication.svc/REST/GtMyReferredPatient'; +const GET_MY_REFERRED_PATIENT = + 'Services/DoctorApplication.svc/REST/GtMyReferredPatient'; -const GET_DOCTOR_WORKING_HOURS_TABLE = 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; +const GET_DOCTOR_WORKING_HOURS_TABLE = + 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; -const GET_PATIENT_LAB_RESULTS= 'Services/DoctorApplication.svc/REST/GetPatientLabResults'; +const GET_PATIENT_LAB_RESULTS = + 'Services/DoctorApplication.svc/REST/GetPatientLabResults'; +const LOGIN_URL = 'Services/Sentry.svc/REST/MemberLogIN_New'; +const INSERT_DEVICE_IMEI = + 'Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; +const SELECT_DEVICE_IMEI = + 'Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; + +const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = + 'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; + +const MEMBER_CHECK_ACTIVATION_CODE_NEW = + 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; +const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; var selectedPatientType = 1; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 892d54fe..c5332425 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -213,5 +213,7 @@ const Map> localizedValues = { }, 'livecare': {'en': 'Live Care', 'ar': 'Live Care'}, 'beingBad': {'en': 'being bad', 'ar': 'سيء'}, - 'beingGreat': {'en': 'being great', 'ar': 'راثع'}, + 'beingGreat': {'en': 'being great', 'ar': 'رائع'}, + 'cancel': {'en': 'CANCEL', 'ar': 'الغاء'}, + 'done': {'en': 'DONE', 'ar': 'تأكيد'}, }; diff --git a/lib/interceptor/http_interceptor.dart b/lib/interceptor/http_interceptor.dart index 4d0f9c33..7f5488b0 100644 --- a/lib/interceptor/http_interceptor.dart +++ b/lib/interceptor/http_interceptor.dart @@ -8,6 +8,7 @@ import 'package:http_interceptor/http_interceptor.dart'; import '../providers/auth_provider.dart'; import '../util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/config/config.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); List publicUrls = [ @@ -18,10 +19,9 @@ List publicUrls = [ ]; class HttpInterceptor extends InterceptorContract { - - Client getClient(){ - return HttpClientWithInterceptor.build(interceptors: [this]); -} + Client getClient() { + return HttpClientWithInterceptor.build(interceptors: [this]); + } Future interceptRequest({RequestData data}) async { print('RequestData ${data.body}'); @@ -29,26 +29,26 @@ class HttpInterceptor extends InterceptorContract { try { data.headers["Content-Type"] = "application/json"; data.headers["Accept"] = "application/json"; - // if (publicUrls.contains(data.url)) { - // var loggedUserInfo = await sharedPref.getObj('loggedUser'); - // var token = await sharedPref.getString(TOKEN); - // // print("token"+token); - // // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}'); - // // // the sevices handel the token in differat name so I ask to be change - // // // we must change the imple - // var body = json.decode(data.body); - // body['LogInTokenID']=token; - // data.body = json.encode(body); - - // // data.body['LogInTokenID'] = ''; - // } else { - // if (data.body['LogInTokenID']) { - // data.body['LogInTokenID'] = ''; - // } - // if (data.body['TokenID']) { - // data.body['TokenID'] = ''; - // } - // } + // if (publicUrls.contains(data.url)) { + // var loggedUserInfo = await sharedPref.getObj('loggedUser'); + // var token = await sharedPref.getString(TOKEN); + // // print("token"+token); + // // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}'); + // // // the sevices handel the token in differat name so I ask to be change + // // // we must change the imple + // var body = json.decode(data.body); + // body['LogInTokenID']=token; + // data.body = json.encode(body); + + // // data.body['LogInTokenID'] = ''; + // } else { + // if (data.body['LogInTokenID']) { + // data.body['LogInTokenID'] = ''; + // } + // if (data.body['TokenID']) { + // data.body['TokenID'] = ''; + // } + // } } catch (e) { print(e); } diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index 61a61530..69551b7b 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -3,21 +3,10 @@ import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; +import 'package:doctor_app_flutter/config/config.dart'; import '../models/doctor/user_model.dart'; -const LOGIN_URL = 'Services/Sentry.svc/REST/MemberLogIN_New'; -const INSERT_DEVICE_IMEI = - 'Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; -const SELECT_DEVICE_IMEI = - 'Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; - -const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = - 'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; - -const MEMBER_CHECK_ACTIVATION_CODE_NEW = - 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; -const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } @@ -166,11 +155,12 @@ class AuthProvider with ChangeNotifier { onSuccess: (dynamic response, int statusCode) { localRes = response; //ClinicDescription - selectedClinicName = response['DoctorProfileList'][0]['ClinicDescription']; + selectedClinicName = + response['DoctorProfileList'][0]['ClinicDescription']; }, onFailure: (String error, int statusCode) { throw error; }, body: docInfo); - notifyListeners(); + notifyListeners(); return Future.value(localRes); } catch (error) { print(error); diff --git a/lib/providers/project_provider.dart b/lib/providers/project_provider.dart index 4de2251f..7548dc2c 100644 --- a/lib/providers/project_provider.dart +++ b/lib/providers/project_provider.dart @@ -1,8 +1,10 @@ import 'dart:async'; import 'package:connectivity/connectivity.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.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'; import 'package:doctor_app_flutter/providers/auth_provider.dart'; @@ -10,6 +12,7 @@ import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; import 'package:provider/provider.dart'; + Helpers helpers = Helpers(); class ProjectProvider with ChangeNotifier { @@ -18,12 +21,15 @@ class ProjectProvider with ChangeNotifier { String currentLanguage = 'ar'; bool _isArabic = false; bool isInternetConnection = true; + List doctorClinicsList = []; + bool isLoading = false; + bool isError = false; + String error = ''; Locale get appLocal => _appLocale; bool get isArabic => _isArabic; StreamSubscription subscription; - // AuthProvider authProvider = AuthProvider(); ProjectProvider() { loadSharedPrefLanguage(); @@ -66,17 +72,44 @@ class ProjectProvider with ChangeNotifier { currentLanguage = 'en'; sharedPref.setString(APP_Language, 'en'); } - getProfile(); + callServicesAfterChangeLang(); notifyListeners(); } + callServicesAfterChangeLang() { + getProfile(); + getDoctorClinicsList(); + } + @override void dispose() { if (subscription != null) subscription.cancel(); super.dispose(); } - void getProfile()async{ + Future getDoctorClinicsList() async { + try { + dynamic localRes; + + await BaseAppClient.post(GET_CLINICS_FOR_DOCTOR, + onSuccess: (dynamic response, int statusCode) { + doctorClinicsList = []; + response['List_DoctorsClinic'].forEach((v) { + doctorClinicsList.add(new ClinicModel.fromJson(v)); + }); + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: {}); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + + void getProfile() async { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); ProfileReqModel docInfo = new ProfileReqModel( @@ -87,13 +120,12 @@ class ProjectProvider with ChangeNotifier { tokenID: '', languageID: 2); - Provider.of(AppGlobal.CONTEX,listen: false) - .getDocProfiles(docInfo.toJson()).then((res) async { + Provider.of(AppGlobal.CONTEX, listen: false) + .getDocProfiles(docInfo.toJson()) + .then((res) async { sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]); }).catchError((err) { print(err); }); } - - } diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index fe41913b..3dce5276 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -54,6 +54,17 @@ class _DashboardScreenState extends State { AuthProvider authProvider; bool isLoading = false; ProjectProvider projectsProvider; + var _isInit = true; + + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + projectsProvider = Provider.of(context); + projectsProvider.getDoctorClinicsList(); + } + _isInit = false; + } + BuildContext myContext; GlobalKey _one = GlobalKey(); @@ -64,7 +75,6 @@ class _DashboardScreenState extends State { hospitalProvider = Provider.of(context); authProvider = Provider.of(context); projectsProvider = Provider.of(context); - print(authProvider.doctorsClinicList); FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); @@ -95,7 +105,9 @@ class _DashboardScreenState extends State { fontWeight: FontWeight.bold, fontSize: SizeConfig.textMultiplier * 2.5, ), - alignment: Alignment.centerLeft, + alignment: projectsProvider.isArabic + ? Alignment.topRight + : Alignment.topLeft, ), ), Row( @@ -106,8 +118,8 @@ class _DashboardScreenState extends State { InkWell( onTap: () async { showCupertinoPicker( - context: context, - actionList: authProvider.doctorsClinicList); + decKey: '',context: context, + actionList: projectsProvider.doctorClinicsList); }, child: Container( margin: @@ -304,7 +316,9 @@ class _DashboardScreenState extends State { TranslationBase.of(context).patientServices, fontWeight: FontWeight.bold, ), - alignment: Alignment.centerLeft, + alignment: projectsProvider.isArabic + ? Alignment.topRight + : Alignment.topLeft, ), ), Expanded( @@ -532,19 +546,17 @@ class _DashboardScreenState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ CupertinoButton( - child: Text( - 'Cancel'.toUpperCase(), - // style: TextStyle(context) - ), + child: Text(TranslationBase.of(context).cancel + // style: TextStyle(context) + ), onPressed: () { Navigator.pop(context); }, ), CupertinoButton( - child: Text( - 'Done'.toUpperCase(), - // style: textStyle(context), - ), + child: Text(TranslationBase.of(context).done + // style: textStyle(context), + ), onPressed: () { Navigator.pop(context); // onSelectFun(cupertinoPickerIndex); @@ -558,14 +570,19 @@ class _DashboardScreenState extends State { color: Color(0xfff7f7f7), child: Column( children: actionList - .map((e) => Container( - child: InkWell( - onTap: () => - changeClinic(e.clinicID, context), - child: Text( - e.clinicName, - style: TextStyle(fontSize: 15), - )), + .map((e) => Flexible( + child: Container( + child: InkWell( + onTap: () => + changeClinic(e.clinicID, context), + child: Text( + e.clinicName, + style: TextStyle( + fontSize: + SizeConfig.textMultiplier * + 1.9), + )), + ), )) .toList(), )) diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 6807edf3..41c0b4f7 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -11,6 +11,7 @@ import '../util/dr_app_toast_msg.dart'; import 'package:connectivity/connectivity.dart'; import 'dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -51,7 +52,7 @@ class Helpers { mainAxisAlignment: MainAxisAlignment.end, children: [ CupertinoButton( - child: Text('Cancel'.toUpperCase(), + child: Text(TranslationBase.of(context).cancel, style: textStyle(context)), onPressed: () { Navigator.pop(context); @@ -59,7 +60,7 @@ class Helpers { ), CupertinoButton( child: Text( - 'Done'.toUpperCase(), + TranslationBase.of(context).done, style: textStyle(context), ), onPressed: () { diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index ca49936e..ad52edd8 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -233,6 +233,8 @@ class TranslationBase { String get livecare => localizedValues['livecare'][locale.languageCode]; String get beingBad => localizedValues['beingBad'][locale.languageCode]; String get beingGreat => localizedValues['beingGreat'][locale.languageCode]; + String get cancel => localizedValues['cancel'][locale.languageCode]; + String get done => localizedValues['done'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index 033f445c..078cf503 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -301,7 +301,7 @@ class _LoginFormState extends State { platformImei = await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false); idunique = await ImeiPlugin.getImei(); - } catch(e) { + } catch (e) { platformImei = 'Failed to get platform version.'; }