diff --git a/Certs/APNSDevPushCert.p12 b/Certs/APNSDevPushCert.p12 new file mode 100644 index 00000000..dba27aec Binary files /dev/null and b/Certs/APNSDevPushCert.p12 differ diff --git a/Certs/APNSProdCert.certSigningRequest b/Certs/APNSProdCert.certSigningRequest new file mode 100644 index 00000000..3f13a387 --- /dev/null +++ b/Certs/APNSProdCert.certSigningRequest @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIICkDCCAXgCAQAwSzEjMCEGCSqGSIb3DQEJARYUaGFyb29uNjEzOEBnbWFpbC5j +b20xFzAVBgNVBAMMDk1vaGFtZWQgTWVrYXd5MQswCQYDVQQGEwJBRTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALcPrk09MmhQhRNe8LYdaeN4mYtoKJg3 +SndMLgpxnaRqP7a6f4sp118wCFZsTXnwhPVP4DzmXWc2AzZtsusmhdw1tzNFtme0 +PtEjDXIPI2lHU3Zhi2zukZdAVxF+uNi3pcp0axina60ZQciIfb/7Fx6hNbqpk90E +O8a2Ob17Wq/ZTYIP4H7ZGydUe2ra9QyDtjmGj9vpEv+xXYWX685sgEylTG14DSOP +ozGsQmaf+QCMbCT3osq7idWc1IQ+3Oed0kUTx1jmRtZwPzQkJJ1Bx3vYSXN/EOlb +u+ei1Nqtc14aVCYvmcuvGDtMyRtw6w+syCw2CpJCPGNkxNz+EH9h+EUCAwEAAaAA +MA0GCSqGSIb3DQEBCwUAA4IBAQBYdu2AaZY6kReuT1Xp8ktlyPfjBRKhPPChuaeR +tFnYMsJtG0aIA/xOu4/RYDgmL92seimULXd9DIPvkJ2DuaB+bdfGTw0qXUlihkm8 +ui5O0L2F9OZbQxJogvTmrMsKnkoR27O5vyfCn9VMOLk3x1nyEzAXIj/5GHWw9T6t +r65jPUOfm6ikiZtICBzSaTPBtyfZB8mrbwG2dpOvVNSa1dj3xip4L8CL6TxH+qM3 ++N90QFYjvjphJkpn2Kt0ow9IyIyeqJbIYJmsWoV9pXddOHCjKdTWUjq7D2Jn3eUA +DAKjKgVqF4/dU10k7EtSfrw01aHLXjj5FxsD5YhVrgTA5xSq +-----END CERTIFICATE REQUEST----- diff --git a/Certs/APNSProdCert.p12 b/Certs/APNSProdCert.p12 new file mode 100644 index 00000000..b0ada453 Binary files /dev/null and b/Certs/APNSProdCert.p12 differ diff --git a/Certs/ApplePushServicesSandbox.certSigningRequest b/Certs/ApplePushServicesSandbox.certSigningRequest new file mode 100644 index 00000000..7d509a0a --- /dev/null +++ b/Certs/ApplePushServicesSandbox.certSigningRequest @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIICkDCCAXgCAQAwSzEjMCEGCSqGSIb3DQEJARYUaGFyb29uNjEzOEBnbWFpbC5j +b20xFzAVBgNVBAMMDk1vaGFtZWQgTWVrYXd5MQswCQYDVQQGEwJBRTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnHqsyE7WfiVcE1Lpa4t4OVO6qlll2q +1djs0XG06R/dlDtIqv4940/XLj+hU93mzAcVvFW4DSIEdD3InM3+T6oMTjPu6meU +69h9ryaVkluQRrT/tdGI1EKO4MWGMe4MDIt7DqMhMfAcxTwekwdxdKaCEhaw3qnA +l/64AelY6URW1pHHJMA0VV7j+pE3jVNai+muMXPrhQ1VrOrV8FftpY3bEeRJR2Cl +T0tv0LhEMu4SfLnVWCzGQQC82hilDw3rH3ZDs8DFxF9agNVdwKlYamarh1dQXwRq +Yx2+sjY1/51r9L4VS+GAh9ECxz0e+43NpzfZ/N+mTeDYKDepaBwPQ6kCAwEAAaAA +MA0GCSqGSIb3DQEBCwUAA4IBAQB89OyLfywKT7ftmpEqCmgsmaJexb580q9w8wOk +1JhJkNV5ec+p1dnge2NZeJ4LGII/5wmPj1vANNW0GZdmJDgnC+2gg9toq1QLCAsF +rW7/LMpgAoEH+P5bhrHV9RRv6BQi0ZmN0apBHjp/pqZfm2Cl5jQPEWjUEf2tIF4l +LSKdok6IPO9n4Fgyk0XdUNSEhgVhsLtZkGiXnkI1YovKDnupTFYPXMLp103bc9zP +xDxwscvOysNDijlzZAkJPg2z8NrJIRDrKvLRHzxQwZ/1LHVB/51bp/1iyks3vOjh +qw5XVsrtGAjCjU9md7q3XkPSyKzhK9UqPdOxdvl1OY0KKIIY +-----END CERTIFICATE REQUEST----- diff --git a/Certs/aps.cer b/Certs/aps.cer index fb46df86..d95bac40 100644 Binary files a/Certs/aps.cer and b/Certs/aps.cer differ diff --git a/Certs/aps_development.cer b/Certs/aps_development.cer new file mode 100644 index 00000000..9a9934bb Binary files /dev/null and b/Certs/aps_development.cer differ diff --git a/CustomFlutterFirebaseMessagingService.java b/CustomFlutterFirebaseMessagingService.java new file mode 100644 index 00000000..0a4d83be --- /dev/null +++ b/CustomFlutterFirebaseMessagingService.java @@ -0,0 +1,17 @@ +package io.flutter.plugins.firebasemessaging; + +import android.content.Intent; + +import com.google.firebase.messaging.RemoteMessage; + +public class CustomFlutterFirebaseMessagingService extends FlutterFirebaseMessagingService { + @Override + public void onMessageReceived(RemoteMessage remoteMessage) { + if (remoteMessage.getData().containsKey("is_call")) { + Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); + startActivity(intent); + super.onMessageReceived(remoteMessage); + } else + super.onMessageReceived(remoteMessage); + } +} \ No newline at end of file diff --git a/android/CustomFlutterFirebaseMessagingService.java b/android/CustomFlutterFirebaseMessagingService.java new file mode 100644 index 00000000..0a4d83be --- /dev/null +++ b/android/CustomFlutterFirebaseMessagingService.java @@ -0,0 +1,17 @@ +package io.flutter.plugins.firebasemessaging; + +import android.content.Intent; + +import com.google.firebase.messaging.RemoteMessage; + +public class CustomFlutterFirebaseMessagingService extends FlutterFirebaseMessagingService { + @Override + public void onMessageReceived(RemoteMessage remoteMessage) { + if (remoteMessage.getData().containsKey("is_call")) { + Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); + startActivity(intent); + super.onMessageReceived(remoteMessage); + } else + super.onMessageReceived(remoteMessage); + } +} \ No newline at end of file diff --git a/lib/config/config.dart b/lib/config/config.dart index fc636ceb..c9a37d70 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -69,9 +69,15 @@ const GET_QR_PARKING = '/Services/SWP.svc/REST/GetQRParkingByID'; //URL to get clinic list const GET_CLINICS_LIST_URL = "Services/lists.svc/REST/GetClinicCentralized"; +//URL to get projects list +const GET_PROJECTS_LIST = 'Services/Lists.svc/REST/GetProject'; + //URL to get doctors list const GET_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/SearchDoctorsByTime"; +//URL to dental doctors list +const GET_DENTAL_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/Dental_DoctorChiefComplaintMapping"; + //URL to get doctor free slots const GET_DOCTOR_FREE_SLOTS = "Services/Doctors.svc/REST/GetDoctorFreeSlots"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index ddd98917..bc50d61c 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -449,4 +449,18 @@ const Map> localizedValues = { "OrderDetails": {"en": "Order Details", "ar": "تفاصيل الطلب"}, "VitalSign": {"en": "Vital Sign", "ar": "العلامة حيوية"}, "MonthlyReports": {"en": "Monthly Reports", "ar": "تقارير شهرية"}, + "textToSpeech": {"en": "How May I Help You?", "ar": "كيف يمكنني مساعدتك؟"}, + "locationDialogMessage": {"en": "Allow the HMG app to access your location will assist you in showing the hospitals according to the nearest to you.", "ar": "السماح لتطبيق مجموعة الحبيب الطبية بالوصول إلى موقعك سيساعدك في إظهار المستشفيات وفقًا للأقرب إليك."}, + "parking":{"en":"Parking","ar":"مواقف"}, + "alhabiServices":{"en":"HMG Service","ar":"خدمات الحبيب"}, + "parkingTitle":{"en":"Car service, car service, service to save parking information, return to it later, 1- By clicking on (Read the code), save the parking data. 2- By clicking on the button (view my car park), it shows you the car’s location in Google Maps. 3- Read another position by pressing the Clear Position Data button.","ar":" خدمة المواقف، تتيح هذه الخدمة للمستخدم معلومات عن موقف السيارة ليسهل عليه العودة لها لاحقاً ، 1- بالضغط على زر(قراءة الكود) تستطيع حفظ البيانات الخاصة بالموقف. 2-بالضغط على زر(عرض موقف سيارتي) يعرض لك موقع السيارة في خرائط قوقل. 3- لإعادة قراءة موقف آخرعن طريق الضغط على زر(مسح بيانات الموقف). "}, + "readBarcode":{"en":"Read Barcode","ar":"قراءة الكود"}, + "showMyPark":{"en":"Show My Park","ar":"عرض بارك"}, + "clearMyData":{"en":"clear My Data","ar":"امسح البيانات"}, + "floor":{"en":"Floor:","ar":"الطابق"}, + "gate":{"en":"Gate:","ar":"بوابة"}, + "building":{"en":"Building:","ar":"المبنى"}, + "branch":{"en":"Branch:","ar":"الفرع"}, + "emergencyServices":{"en":"Emergency Services:","ar":"خدمات الطوارئ"}, + "km":{"en":"KMs:","ar":"كم"}, }; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index c9da9fe7..61e36022 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -11,4 +11,6 @@ const AUTH_DATA = 'auth-data'; const IMEI_USER_DATA = 'imei-user-data'; const NHIC_DATA = 'nhic-data'; const FAMILY_FILE = 'family-file'; +const USER_LAT = 'user-lat'; +const USER_LONG = 'user-long'; const IS_GO_TO_PARKING = 'IS_GO_TO_PARKING'; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index aa48c49d..04bc88d6 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -2,14 +2,11 @@ import 'dart:convert'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; -import '../../../locator.dart'; import '../../../routes.dart'; AppSharedPreferences sharedPref = new AppSharedPreferences(); @@ -33,9 +30,11 @@ class BaseAppClient { var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); var user = await sharedPref.getObject(USER_PROFILE); - body['SetupID'] = body.containsKey('SetupID') - ? body['SetupID'] != null ? body['SetupID'] : SETUP_ID - : SETUP_ID; + if (body.containsKey('SetupID')) { + body['SetupID'] = body.containsKey('SetupID') + ? body['SetupID'] != null ? body['SetupID'] : SETUP_ID + : SETUP_ID; + } body['VersionID'] = VERSION_ID; body['Channel'] = CHANNEL; body['LanguageID'] = languageID == 'ar' ? 1 : 2; @@ -44,16 +43,29 @@ class BaseAppClient { body['PatientOutSA'] = body.containsKey('PatientOutSA') ? body['PatientOutSA'] != null ? body['PatientOutSA'] : PATIENT_OUT_SA : PATIENT_OUT_SA; - body['isDentalAllowedBackend'] = IS_DENTAL_ALLOWED_BACKEND; + + if (body.containsKey('isDentalAllowedBackend')) { + body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null ? body['isDentalAllowedBackend'] : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; + } + body['DeviceTypeID'] = DeviceTypeID; - body['PatientType'] = body.containsKey('PatientType') - ? body['PatientType'] != null ? body['PatientType'] : PATIENT_TYPE - : PATIENT_TYPE; - body['PatientTypeID'] = body.containsKey('PatientTypeID') - ? body['PatientTypeID'] != null - ? body['PatientTypeID'] - : PATIENT_TYPE_ID - : PATIENT_TYPE_ID; + + if (body.containsKey('PatientType')) { + body['PatientType'] = body.containsKey('PatientType') + ? body['PatientType'] != null ? body['PatientType'] : PATIENT_TYPE + : PATIENT_TYPE; + } + + if (body.containsKey('PatientTypeID')) { + body['PatientTypeID'] = body.containsKey('PatientTypeID') + ? body['PatientTypeID'] != null + ? body['PatientTypeID'] + : PATIENT_TYPE_ID + : PATIENT_TYPE_ID; + } + if (user != null) { body['TokenID'] = token; body['PatientID'] = diff --git a/lib/main.dart b/lib/main.dart index ce0e097c..f641f22e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,4 @@ -import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart'; -import 'package:diplomaticquarterapp/pages/login/login.dart'; import 'package:diplomaticquarterapp/routes.dart'; -import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; diff --git a/lib/models/Appointments/AppoimentAllHistoryResultList.dart b/lib/models/Appointments/AppoimentAllHistoryResultList.dart index a935542a..9ba1fb8e 100644 --- a/lib/models/Appointments/AppoimentAllHistoryResultList.dart +++ b/lib/models/Appointments/AppoimentAllHistoryResultList.dart @@ -272,3 +272,13 @@ class AppoitmentAllHistoryResultList { return data; } } + +class PatientAppointmentList { + String filterName = ""; + List patientDoctorAppointmentList = List(); + + PatientAppointmentList( + {this.filterName, AppoitmentAllHistoryResultList patientDoctorAppointment}) { + patientDoctorAppointmentList.add(patientDoctorAppointment); + } +} diff --git a/lib/models/Appointments/DentalChiefComplaintsModel.dart b/lib/models/Appointments/DentalChiefComplaintsModel.dart new file mode 100644 index 00000000..c15b828a --- /dev/null +++ b/lib/models/Appointments/DentalChiefComplaintsModel.dart @@ -0,0 +1,48 @@ +class DentalChiefComplaintsModel { + List listDentalChiefComplain; + + DentalChiefComplaintsModel({this.listDentalChiefComplain}); + + DentalChiefComplaintsModel.fromJson(Map json) { + if (json['List_DentalChiefComplain'] != null) { + listDentalChiefComplain = new List(); + json['List_DentalChiefComplain'].forEach((v) { + listDentalChiefComplain.add(new ListDentalChiefComplain.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.listDentalChiefComplain != null) { + data['List_DentalChiefComplain'] = + this.listDentalChiefComplain.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ListDentalChiefComplain { + int projectID; + int iD; + String name; + String nameN; + + ListDentalChiefComplain({this.projectID, this.iD, this.name, this.nameN}); + + ListDentalChiefComplain.fromJson(Map json) { + projectID = json['ProjectID']; + iD = json['ID']; + name = json['Name']; + nameN = json['NameN']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['ID'] = this.iD; + data['Name'] = this.name; + data['NameN'] = this.nameN; + return data; + } +} diff --git a/lib/models/Appointments/DoctorListResponse.dart b/lib/models/Appointments/DoctorListResponse.dart index 1ef6ee72..3b5557bc 100644 --- a/lib/models/Appointments/DoctorListResponse.dart +++ b/lib/models/Appointments/DoctorListResponse.dart @@ -1,5 +1,3 @@ -import 'package:intl/intl.dart'; - class DoctorList { int clinicID; String clinicName; @@ -32,7 +30,7 @@ class DoctorList { int noOfPatientsRate; int originalClinicID; int personRate; - int projectDistanceInKiloMeters; + dynamic projectDistanceInKiloMeters; String qR; dynamic qRString; int rateNumber; @@ -170,12 +168,13 @@ class DoctorList { } } -class DoctorListAppointmentList { +class PatientDoctorAppointmentList { String filterName = ""; + String distanceInKMs = ""; List patientDoctorAppointmentList = List(); - DoctorListAppointmentList( - {this.filterName, DoctorList patientDoctorAppointment}) { + PatientDoctorAppointmentList( + {this.filterName, this.distanceInKMs, DoctorList patientDoctorAppointment}) { patientDoctorAppointmentList.add(patientDoctorAppointment); } } diff --git a/lib/models/Appointments/SearchInfoModel.dart b/lib/models/Appointments/SearchInfoModel.dart new file mode 100644 index 00000000..f5500bca --- /dev/null +++ b/lib/models/Appointments/SearchInfoModel.dart @@ -0,0 +1,10 @@ +class SearchInfo { + int ProjectID; + int ClinicID; + String DoctorName; + String SelectedDate; + String SelectedTime; + String currentLat; + String currentLong; + DateTime date; +} diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 8c1d781c..88ecdb6b 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -502,8 +502,6 @@ class _BookConfirmState extends State { Future navigateToBookSuccess(context, DoctorList docObject, PatientShareResponse patientShareResponse) async { - print(widget.appoDateFormatted); -// print(widget.appoTimeFormatted); Navigator.push( context, diff --git a/lib/pages/BookAppointment/BookingOptions.dart b/lib/pages/BookAppointment/BookingOptions.dart index dacb25e9..b6dc5500 100644 --- a/lib/pages/BookAppointment/BookingOptions.dart +++ b/lib/pages/BookAppointment/BookingOptions.dart @@ -1,19 +1,36 @@ import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/CardCommon.dart'; -import 'package:diplomaticquarterapp/services/robo_search/search_provider.dart'; +import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import '../../uitl/translations_delegate_base.dart'; -class BookingOptions extends StatelessWidget { +class BookingOptions extends StatefulWidget { final bool isAppbar; + BookingOptions({this.isAppbar = false}); + + @override + _BookingOptionsState createState() => _BookingOptionsState(); +} + +class _BookingOptionsState extends State { + LocationUtils locationUtils; + + @override + void initState() { + locationUtils = + new LocationUtils(isShowConfirmDialog: true, context: context); + WidgetsBinding.instance + .addPostFrameCallback((_) => locationUtils.getCurrentLocation()); + + super.initState(); + } + @override Widget build(BuildContext context) { - final searchValue = Provider.of(context); return AppScaffold( - isShowAppBar: isAppbar, + isShowAppBar: widget.isAppbar, appBarTitle: TranslationBase.of(context).bookAppo, body: Container( margin: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 10.0), diff --git a/lib/pages/BookAppointment/DentalComplaints.dart b/lib/pages/BookAppointment/DentalComplaints.dart new file mode 100644 index 00000000..9d3da450 --- /dev/null +++ b/lib/pages/BookAppointment/DentalComplaints.dart @@ -0,0 +1,82 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/models/Appointments/DentalChiefComplaintsModel.dart'; +import 'package:diplomaticquarterapp/models/Appointments/SearchInfoModel.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DentalComplaintCard.dart'; +import 'package:diplomaticquarterapp/pages/livecare/widgets/clinic_card.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:smart_progress_bar/smart_progress_bar.dart'; + +class DentalComplaints extends StatefulWidget { + SearchInfo searchInfo; + + DentalComplaints({@required this.searchInfo}); + + @override + _DentalComplaintsState createState() => _DentalComplaintsState(); +} + +class _DentalComplaintsState extends State { + List complaintsList = []; + AppSharedPreferences sharedPref = AppSharedPreferences(); + bool isDataLoaded = false; + var languageID; + + @override + void initState() { + WidgetsBinding.instance + .addPostFrameCallback((_) => getChiefComplaintsList()); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + isShowAppBar: true, + appBarTitle: "Symptoms", + body: Container( + margin: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0.0), + child: ListView.builder( + itemCount: complaintsList.length, + itemBuilder: (BuildContext context, int index) { + return Container( + margin: EdgeInsets.only(bottom: 10.0), + child: DentalComplaintCard( + listDentalChiefComplain: complaintsList[index], + languageID: languageID, + ), + ); + }, + ), + ), + ); + } + + getLanguageID() async { + languageID = await sharedPref.getString(APP_LANGUAGE); + } + + getChiefComplaintsList() { + getLanguageID(); + ClinicListService service = new ClinicListService(); + service + .getChiefComplaintsList( + widget.searchInfo.ClinicID, widget.searchInfo.ProjectID, context) + .then((res) { + if (res['MessageStatus'] == 1) { + print(res['List_DentalChiefComplain']); + setState(() { + res['List_DentalChiefComplain'].forEach((v) { + complaintsList.add(new ListDentalChiefComplain.fromJson(v)); + }); + print(complaintsList.length); + }); + } else {} + }).catchError((err) { + print(err); + }).showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); + } +} diff --git a/lib/pages/BookAppointment/Search.dart b/lib/pages/BookAppointment/Search.dart index 9af6b449..08b49462 100644 --- a/lib/pages/BookAppointment/Search.dart +++ b/lib/pages/BookAppointment/Search.dart @@ -1,13 +1,17 @@ import 'package:diplomaticquarterapp/pages/BookAppointment/components/SearchByClinic.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/components/SearchByDoctor.dart'; +import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart'; -import 'package:diplomaticquarterapp/widgets/others/floating_button_search.dart'; import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; class Search extends StatefulWidget { final int type; + Search({this.type = 0}); + @override _SearchState createState() => _SearchState(); } diff --git a/lib/pages/BookAppointment/SearchResults.dart b/lib/pages/BookAppointment/SearchResults.dart index 7da5112b..2b5fac17 100644 --- a/lib/pages/BookAppointment/SearchResults.dart +++ b/lib/pages/BookAppointment/SearchResults.dart @@ -1,15 +1,17 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DoctorView.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; -import 'widgets/DoctorView.dart'; - class SearchResults extends StatefulWidget { List doctorsList = []; + List patientDoctorAppointmentListHospital; - SearchResults({@required this.doctorsList}); + SearchResults( + {@required this.doctorsList, this.patientDoctorAppointmentListHospital}); @override _SearchResultsState createState() => _SearchResultsState(); @@ -21,23 +23,7 @@ class _SearchResultsState extends State { @override void initState() { - event.controller.stream.listen((p) { - // if (p['project_id'] != null) { - // tempList = []; - // widget.doctorsList.forEach((e) => { - // if (e.projectID == int.parse(p['project_id'])) {tempList.add(e)} - // }); - // } else if (p['doctor_id'] != null) { - // tempList = []; - // widget.doctorsList.forEach((e) => { - // if (e.doctorID == int.parse(p['doctor_id'])) {tempList.add(e)} - // }); - // DoctorView().getDoctorsProfile(context, tempList[0], isAppo: true); - // } - // setState(() { - // widget.doctorsList = tempList; - // }); - }); + event.controller.stream.listen((p) {}); super.initState(); } @@ -47,20 +33,31 @@ class _SearchResultsState extends State { appBarTitle: TranslationBase.of(context).bookAppo, isShowAppBar: true, body: Container( - margin: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.all(10.0), child: SingleChildScrollView( - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - padding: EdgeInsets.all(0.0), - itemCount: widget.doctorsList.length, - itemBuilder: (context, index) { - return DoctorView( - //AJ note - doctor: widget.doctorsList[index], - ); - }, + physics: BouncingScrollPhysics(), + child: Column( + children: [ + ...List.generate( + widget.patientDoctorAppointmentListHospital.length, + (index) => AppExpandableNotifier( + title: widget + .patientDoctorAppointmentListHospital[index].filterName + " - " +widget + .patientDoctorAppointmentListHospital[index].distanceInKMs + " " + TranslationBase.of(context).km, + bodyWidget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: widget + .patientDoctorAppointmentListHospital[index] + .patientDoctorAppointmentList + .map((doctor) { + return DoctorView( + doctor: doctor, + ); + }).toList(), + )), + ) + ], ), ), ), diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index bfadd3b0..6b3eff38 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -1,21 +1,19 @@ -import 'dart:convert'; +import "dart:collection"; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/models/Appointments/SearchInfoModel.dart'; import 'package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/DentalComplaints.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; -import 'package:diplomaticquarterapp/services/robo_search/search_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; -import '../SearchResults.dart'; -import "dart:collection"; - class SearchByClinic extends StatefulWidget { @override _SearchByClinicState createState() => _SearchByClinicState(); @@ -24,20 +22,15 @@ class SearchByClinic extends StatefulWidget { class _SearchByClinicState extends State { bool nearestAppo = false; String dropdownValue; + String projectDropdownValue; var event = RobotProvider(); List clinicsList = []; + List projectsList = []; + bool isMobileAppDentalAllow = false; @override void initState() { WidgetsBinding.instance.addPostFrameCallback((_) => getClinicsList()); - // event.controller.stream.listen((p) { - // if (p['clinic_id'] != null) { - // // setState(() { - // dropdownValue = p['clinic_id'].toString(); - // //}); - // getDoctorsList(context); - // } - // }); super.initState(); } @@ -89,25 +82,91 @@ class _SearchByClinicState extends State { onChanged: (newValue) { setState(() { dropdownValue = newValue; - - getDoctorsList(context); + if (!isDentalSelectedAndSupported() && !nearestAppo) { + projectDropdownValue = ""; + getDoctorsList(context); + } }); }, ), )), + isDentalSelectedAndSupported() == true || nearestAppo + ? Container( + height: 60.0, + decoration: BoxDecoration( + color: Colors.white, + border: Border.all( + color: Colors.grey[400], + width: 1.0, + ), + borderRadius: BorderRadius.circular(10), + ), + padding: EdgeInsets.all(8.0), + width: MediaQuery.of(context).size.width, + margin: EdgeInsets.only(top: 15.0), + child: DropdownButtonHideUnderline( + child: DropdownButton( + hint: new Text("Select Project"), + value: projectDropdownValue, + items: projectsList.map((item) { + return new DropdownMenuItem( + value: item.mainProjectID.toString(), + child: new Text(item.name), + ); + }).toList(), + onChanged: (newValue) { + setState(() { + projectDropdownValue = newValue; + getDoctorsList(context); + }); + }, + ), + )) + : Container(), ], ), ); } + bool isDentalSelectedAndSupported() { + return dropdownValue != "" && + (dropdownValue == "17") && + isMobileAppDentalAllow; + } + getClinicsList() { ClinicListService service = new ClinicListService(); - service.getClinicsList(context).then((res) { + service + .getClinicsList(context) + .then((res) { + if (res['MessageStatus'] == 1) { + setState(() { + isMobileAppDentalAllow = res['ISMobileAppDentalAllow']; + res['ListClinicCentralized'].forEach((v) { + clinicsList.add(new ListClinicCentralized.fromJson(v)); + }); + }); + } else {} + }) + .catchError((err) { + print(err); + }) + .showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)) + .then((value) { + getProjectsList(); + }); + } + + getProjectsList() { + ClinicListService service = new ClinicListService(); + service.getProjectsList(context).then((res) { if (res['MessageStatus'] == 1) { setState(() { - res['ListClinicCentralized'].forEach((v) { - clinicsList.add(new ListClinicCentralized.fromJson(v)); + res['ListProject'].forEach((v) { + projectsList.add(new HospitalsModel.fromJson(v)); }); + print(projectsList.length); }); } else {} }).catchError((err) { @@ -117,54 +176,81 @@ class _SearchByClinicState extends State { } getDoctorsList(BuildContext context) { - List doctorsList = []; - //======================== + SearchInfo searchInfo = new SearchInfo(); + if (dropdownValue == "17") { + searchInfo.ProjectID = int.parse(projectDropdownValue); + searchInfo.ClinicID = int.parse(dropdownValue); + searchInfo.date = DateTime.now(); - List arr = []; - var distinctIds; - List result; - int numAll; - //========================= - DoctorsListService service = new DoctorsListService(); - service.getDoctorsList(int.parse(dropdownValue), 0, context).then((res) { - if (res['MessageStatus'] == 1) { - setState(() { - if (res['DoctorList'].length != 0) { - doctorsList.clear(); - res['DoctorList'].forEach((v) { - doctorsList.add(new DoctorList.fromJson(v)); + navigateToDentalComplaints(context, searchInfo); + } else { + List doctorsList = []; + List arr = []; + List arrDistance = []; + List result; + int numAll; + DoctorsListService service = new DoctorsListService(); + service + .getDoctorsList( + int.parse(dropdownValue), + projectDropdownValue != "" ? int.parse(projectDropdownValue) : 0, + nearestAppo, + context) + .then((res) { + if (res['MessageStatus'] == 1) { + setState(() { + if (res['DoctorList'].length != 0) { + print(res['DoctorList']); + doctorsList.clear(); + res['DoctorList'].forEach((v) { + doctorsList.add(new DoctorList.fromJson(v)); - arr.add(new DoctorList.fromJson(v).projectName); - // print(DoctorList.fromJson(v).projectName); - // print(DoctorList.fromJson(v).projectDistanceInKiloMeters); - // distinctIds = result.toSet().toList(); - }); - } else {} - }); + arr.add(new DoctorList.fromJson(v).projectName); + arrDistance.add(new DoctorList.fromJson(v) + .projectDistanceInKiloMeters + .toString()); + }); + } else {} + }); - result = LinkedHashSet.from(arr).toList(); - numAll = result.length; - // print(result); - print("numAll=" + numAll.toString()); + result = LinkedHashSet.from(arr).toList(); + numAll = result.length; - navigateToSearchResults(context, doctorsList, result, numAll); - } else { - AppToast.showErrorToast(message: res['ErrorEndUserMessage']); - } - }).catchError((err) { - print(err); - }).showProgressBar( - text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); + navigateToSearchResults( + context, doctorsList, result, numAll, arrDistance); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }).catchError((err) { + print(err); + }).showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); + } } - Future navigateToSearchResults(context, docList, result, numAll) async { + Future navigateToDentalComplaints( + BuildContext context, SearchInfo searchInfo) async { Navigator.push( context, MaterialPageRoute( - builder: (context) => - BranchView(doctorsList: docList, result: result, num: numAll), + builder: (context) => DentalComplaints(searchInfo: searchInfo), ), ); - //builder: (context) => SearchResults(doctorsList: docList))); + } + + Future navigateToSearchResults( + context, docList, result, numAll, resultDistance) async { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => BranchView( + doctorsList: docList, + result: result, + num: numAll, + resultDistance: resultDistance), + ), + ).then((value) { + getProjectsList(); + }); } } diff --git a/lib/pages/BookAppointment/components/SearchByDoctor.dart b/lib/pages/BookAppointment/components/SearchByDoctor.dart index 3e817878..1e7deb38 100644 --- a/lib/pages/BookAppointment/components/SearchByDoctor.dart +++ b/lib/pages/BookAppointment/components/SearchByDoctor.dart @@ -84,6 +84,10 @@ class _SearchByDoctorState extends State { getDoctorsList(BuildContext context) { List doctorsList = []; DoctorsListService service = new DoctorsListService(); + + List _patientDoctorAppointmentListHospital = + List(); + service .getDoctorsListByName(doctorNameController.text, context) .then((res) { @@ -93,9 +97,35 @@ class _SearchByDoctorState extends State { res['DoctorList'].forEach((v) { doctorsList.add(new DoctorList.fromJson(v)); }); + + doctorsList.forEach((element) { + List doctorByHospital = + _patientDoctorAppointmentListHospital + .where( + (elementClinic) => + elementClinic.filterName == element.projectName, + ) + .toList(); + + if (doctorByHospital.length != 0) { + _patientDoctorAppointmentListHospital[ + _patientDoctorAppointmentListHospital + .indexOf(doctorByHospital[0])] + .patientDoctorAppointmentList + .add(element); + } else { + _patientDoctorAppointmentListHospital.add( + PatientDoctorAppointmentList( + filterName: element.projectName, + distanceInKMs: element.projectDistanceInKiloMeters.toString(), + patientDoctorAppointment: element)); + } + }); } else {} }); - navigateToSearchResults(context, doctorsList); + + navigateToSearchResults( + context, doctorsList, _patientDoctorAppointmentListHospital); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } @@ -107,7 +137,7 @@ class _SearchByDoctorState extends State { _onDocTextChanged(content) { print(content); - if (content.length >= 4) { + if (content.length >= 3) { setState(() { _isButtonDisabled = false; }); @@ -123,10 +153,17 @@ class _SearchByDoctorState extends State { getDoctorsList(context); } - Future navigateToSearchResults(context, List docList) async { + Future navigateToSearchResults( + context, + List docList, + List + patientDoctorAppointmentListHospital) async { Navigator.push( context, MaterialPageRoute( - builder: (context) => SearchResults(doctorsList: docList))); + builder: (context) => SearchResults( + doctorsList: docList, + patientDoctorAppointmentListHospital: + patientDoctorAppointmentListHospital))); } } diff --git a/lib/pages/BookAppointment/widgets/BranchView.dart b/lib/pages/BookAppointment/widgets/BranchView.dart index 82c38cb2..88912a3f 100644 --- a/lib/pages/BookAppointment/widgets/BranchView.dart +++ b/lib/pages/BookAppointment/widgets/BranchView.dart @@ -1,8 +1,6 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:flutter/material.dart'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -12,9 +10,11 @@ class BranchView extends StatefulWidget { final List doctorsList; final List result; + final List resultDistance; final int num; - const BranchView({Key key, this.doctorsList, this.result, this.num}) + const BranchView( + {Key key, this.doctorsList, this.result, this.resultDistance, this.num}) : super(key: key); @override @@ -30,8 +30,8 @@ class _BranchViewState extends State { body: new ListView.builder( itemBuilder: (BuildContext context, int index) { return new ExpandableListView( - result2: widget.result, + resultDistance: widget.resultDistance, val: index, doctorsList2: widget.doctorsList); }, @@ -42,13 +42,13 @@ class _BranchViewState extends State { } class ExpandableListView extends StatefulWidget { - final List result2; + final List resultDistance; final List doctorsList2; final val; const ExpandableListView( - {Key key, this.result2, this.val, this.doctorsList2}) + {Key key, this.result2, this.resultDistance, this.val, this.doctorsList2}) : super(key: key); @override @@ -61,11 +61,9 @@ class _ExpandableListViewState extends State { @override Widget build(BuildContext context) { return new Container( - // margin: new EdgeInsets.symmetric(vertical: 1.0), width: MediaQuery.of(context).size.width * 0.6, - margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0), + margin: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 0.0), child: Card( - // margin: EdgeInsets.fromLTRB(20.0, 16.0, 20.0, 8.0), color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), @@ -77,19 +75,22 @@ class _ExpandableListViewState extends State { child: new Column( children: [ new Container( + margin: EdgeInsets.only(left: 5.0, right: 5.0), color: Colors.white, - // padding: new EdgeInsets.symmetric(horizontal: 5.0), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ new Text( - widget.result2[widget.val].toString()+" "+ "22 كم", + widget.result2[widget.val].toString() + + " " + + getProjectDistance( + widget.resultDistance[widget.val].toString()), style: new TextStyle( fontWeight: FontWeight.bold, color: Colors.black), ), new IconButton( icon: new Container( - height: 30.0, + height: 28.0, width: 30.0, decoration: new BoxDecoration( color: Colors.red, @@ -124,13 +125,14 @@ class _ExpandableListViewState extends State { itemCount: widget.doctorsList2.length, itemBuilder: (context, index) { return widget.result2[widget.val].toString() == - widget.doctorsList2[index].projectName.toString()? DoctorView( - //AJ note - doctor: - widget.doctorsList2[index] - - // widget.doctorsList2[index] - ):Container(); + widget.doctorsList2[index].projectName.toString() + ? DoctorView( + //AJ note + doctor: widget.doctorsList2[index] + + // widget.doctorsList2[index] + ) + : Container(); }, ), ) @@ -140,6 +142,14 @@ class _ExpandableListViewState extends State { ), ); } + + String getProjectDistance(String distance) { + if (distance != "0") + return " - " + distance + " " + TranslationBase.of(context).km; + else { + return ""; + } + } } class ExpandableContainer extends StatelessWidget { @@ -162,7 +172,7 @@ class ExpandableContainer extends StatelessWidget { duration: new Duration(milliseconds: 500), curve: Curves.easeInOut, width: screenWidth, - height: expanded ? expandedHeight : collapsedHeight, + height: expanded ? MediaQuery.of(context).size.height : collapsedHeight, child: new Container( child: child, decoration: new BoxDecoration( diff --git a/lib/pages/BookAppointment/widgets/DentalComplaintCard.dart b/lib/pages/BookAppointment/widgets/DentalComplaintCard.dart new file mode 100644 index 00000000..27f37d0a --- /dev/null +++ b/lib/pages/BookAppointment/widgets/DentalComplaintCard.dart @@ -0,0 +1,135 @@ +import 'package:diplomaticquarterapp/models/Appointments/DentalChiefComplaintsModel.dart'; +import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:flutter/material.dart'; +import 'package:smart_progress_bar/smart_progress_bar.dart'; + +// ignore: must_be_immutable +class DentalComplaintCard extends StatefulWidget { + final ListDentalChiefComplain listDentalChiefComplain; + var languageID; + + DentalComplaintCard( + {@required this.listDentalChiefComplain, this.languageID}); + + @override + _DentalComplaintCardState createState() => _DentalComplaintCardState(); +} + +class _DentalComplaintCardState extends State { + @override + Widget build(BuildContext context) { + return Container( + child: InkWell( + onTap: () { + getChiefComplaintsList(); + }, + child: Card( + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.85, + padding: EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + child: Text(widget.listDentalChiefComplain.name, + style: + TextStyle(fontSize: 16.0, color: Colors.black)), + ), + ], + ), + ), + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Icon(Icons.arrow_forward_ios, + size: 20.0, color: Colors.black54), + ], + ), + ), + ], + ), + ), + ), + ); + } + + getChiefComplaintsList() { + List doctorsList = []; + List _patientDoctorAppointmentListHospital = + List(); + + ClinicListService service = new ClinicListService(); + service + .getChiefComplaintDoctorList(widget.listDentalChiefComplain.iD, + widget.listDentalChiefComplain.projectID, context) + .then((res) { + if (res['MessageStatus'] == 1) { + print(res['List_DentalDoctorChiefComplaintMapping']); + setState(() { + doctorsList.clear(); + res['List_DentalDoctorChiefComplaintMapping'].forEach((v) { + doctorsList.add(new DoctorList.fromJson(v)); + }); + + doctorsList.forEach((element) { + List doctorByHospital = + _patientDoctorAppointmentListHospital + .where( + (elementClinic) => + elementClinic.filterName == element.projectName, + ) + .toList(); + + if (doctorByHospital.length != 0) { + _patientDoctorAppointmentListHospital[ + _patientDoctorAppointmentListHospital + .indexOf(doctorByHospital[0])] + .patientDoctorAppointmentList + .add(element); + } else { + _patientDoctorAppointmentListHospital.add( + PatientDoctorAppointmentList( + filterName: element.projectName, + distanceInKMs: + element.projectDistanceInKiloMeters.toString(), + patientDoctorAppointment: element)); + } + }); + navigateToSearchResults( + context, doctorsList, _patientDoctorAppointmentListHospital); + }); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }).catchError((err) { + print(err); + }).showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); + } + + Future navigateToSearchResults( + context, + List docList, + List + patientDoctorAppointmentListHospital) async { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SearchResults( + doctorsList: docList, + patientDoctorAppointmentListHospital: + patientDoctorAppointmentListHospital))); + } +} diff --git a/lib/pages/BookAppointment/widgets/DoctorView.dart b/lib/pages/BookAppointment/widgets/DoctorView.dart index 4cdc3977..d3150459 100644 --- a/lib/pages/BookAppointment/widgets/DoctorView.dart +++ b/lib/pages/BookAppointment/widgets/DoctorView.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart import 'package:diplomaticquarterapp/models/Appointments/DoctorProfile.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:flutter/material.dart'; import 'package:rating_bar/rating_bar.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; @@ -21,7 +22,7 @@ class DoctorView extends StatelessWidget { getDoctorsProfile(context, doctor); }, child: Card( - margin: EdgeInsets.fromLTRB(20.0, 16.0, 20.0, 8.0), + margin: EdgeInsets.fromLTRB(10.0, 16.0, 10.0, 8.0), color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), @@ -44,7 +45,7 @@ class DoctorView extends StatelessWidget { Expanded( flex: 4, child: Container( - width: MediaQuery.of(context).size.width * 0.6, + width: MediaQuery.of(context).size.width * 0.55, margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -81,6 +82,16 @@ class DoctorView extends StatelessWidget { color: Colors.grey[600], letterSpacing: 1.0)), ), + this.doctor.nearestFreeSlot != null ? Container( + margin: EdgeInsets.only(top: 3.0, bottom: 3.0), + child: Text( + getDate(this.doctor.nearestFreeSlot), + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.bold, + color: Colors.green[600], + letterSpacing: 1.0)), + ) : Container(), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, @@ -144,6 +155,29 @@ class DoctorView extends StatelessWidget { }).showProgressBar(text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); } + String getDate(String date) { + DateTime dateObj = DateUtil.convertStringToDate(date); + return DateUtil.getWeekDay(dateObj.weekday) + + ", " + + dateObj.day.toString() + + " " + + DateUtil.getMonth(dateObj.month) + + " " + + dateObj.year.toString() + + " " + + dateObj.hour.toString() + + ":" + + getMinute(dateObj); + } + + String getMinute(DateTime dateObj) { + if(dateObj.minute == 0) { + return dateObj.minute.toString() + "0"; + } else { + return dateObj.minute.toString(); + } + } + Future navigateToDoctorProfile(context, docObject, docProfile, {isAppo}) async { Navigator.push( diff --git a/lib/pages/MyAppointments/MyAppointments.dart b/lib/pages/MyAppointments/MyAppointments.dart index af4c47c0..782b5012 100644 --- a/lib/pages/MyAppointments/MyAppointments.dart +++ b/lib/pages/MyAppointments/MyAppointments.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/AppointmentCar import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; @@ -15,6 +16,13 @@ class MyAppointments extends StatefulWidget { List confirmedAppoList = []; List arrivedAppoList = []; + List _patientBookedAppointmentListHospital = List(); + + List _patientConfirmedAppointmentListHospital = + List(); + + List _patientArrivedAppointmentListHospital = List(); + @override _MyAppointmentsState createState() => _MyAppointmentsState(); } @@ -40,7 +48,6 @@ class _MyAppointmentsState extends State isShowAppBar: true, body: Container( child: Column(children: [ - /// this is will not colored with theme data TabBar( tabs: [ Tab(text: TranslationBase.of(context).booked), @@ -94,7 +101,8 @@ class _MyAppointmentsState extends State } }).catchError((err) { print(err); - }).showProgressBar(text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); + }).showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); } bool isConfirmed(AppoitmentAllHistoryResultList appo) { @@ -123,15 +131,85 @@ class _MyAppointmentsState extends State widget.arrivedAppoList.add(v); } }); + + widget.bookedAppoList.forEach((element) { + List doctorByHospital = + widget._patientBookedAppointmentListHospital + .where( + (elementClinic) => + elementClinic.filterName == element.clinicName, + ) + .toList(); + + if (doctorByHospital.length != 0) { + widget + ._patientBookedAppointmentListHospital[widget + ._patientBookedAppointmentListHospital + .indexOf(doctorByHospital[0])] + .patientDoctorAppointmentList + .add(element); + } else { + widget._patientBookedAppointmentListHospital.add(PatientAppointmentList( + filterName: element.clinicName, patientDoctorAppointment: element)); + } + }); + + widget.confirmedAppoList.forEach((element) { + List doctorByHospital = + widget._patientConfirmedAppointmentListHospital + .where( + (elementClinic) => + elementClinic.filterName == element.clinicName, + ) + .toList(); + + if (doctorByHospital.length != 0) { + widget + ._patientConfirmedAppointmentListHospital[widget + ._patientConfirmedAppointmentListHospital + .indexOf(doctorByHospital[0])] + .patientDoctorAppointmentList + .add(element); + } else { + widget._patientConfirmedAppointmentListHospital.add( + PatientAppointmentList( + filterName: element.clinicName, + patientDoctorAppointment: element)); + } + }); + + widget.arrivedAppoList.forEach((element) { + List doctorByHospital = + widget._patientArrivedAppointmentListHospital + .where( + (elementClinic) => + elementClinic.filterName == element.clinicName, + ) + .toList(); + + if (doctorByHospital.length != 0) { + widget + ._patientArrivedAppointmentListHospital[widget + ._patientArrivedAppointmentListHospital + .indexOf(doctorByHospital[0])] + .patientDoctorAppointmentList + .add(element); + } else { + widget._patientArrivedAppointmentListHospital.add( + PatientAppointmentList( + filterName: element.clinicName, + patientDoctorAppointment: element)); + } + }); } openAppointmentsTab() { if (widget.bookedAppoList.length != 0) { - _tabController.animateTo((_tabController.index + 1) % 1); + _tabController.index = 0; } else if (widget.confirmedAppoList.length != 0) { - _tabController.animateTo((_tabController.index + 1) % 2); + _tabController.index = 1; } else if (widget.arrivedAppoList.length != 0) { - _tabController.animateTo((_tabController.index + 1) % 3); + _tabController.index = 2; return; } } @@ -164,23 +242,91 @@ class _MyAppointmentsState extends State )), ), ], + margin: EdgeInsets.only(top: 10.0), + child: Container( + child: widget.bookedAppoList.length != 0 + ? SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + ...List.generate( + widget._patientBookedAppointmentListHospital.length, + (index) => AppExpandableNotifier( + title: widget + ._patientBookedAppointmentListHospital[index] + .filterName, + bodyWidget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: widget + ._patientBookedAppointmentListHospital[index] + .patientDoctorAppointmentList + .map((doctor) { + return AppointmentCard( + appo: doctor, + onReloadAppointmentHistory: + getPatientAppointmentHistory, + ); + }).toList(), + )), + ) + ], + ), + ) + : Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + "assets/images/new-design/noAppointmentIcon.png"), + Container( + margin: EdgeInsets.only(top: 10.0), + child: Text("No Booked Appointments", + style: TextStyle( + fontSize: 16.0, + )), + ), + ], + ), ), ), - ), + ), ); } Widget getConfirmedAppointments() { return widget.confirmedAppoList.length != 0 ? Container( - child: new ListView.builder( - itemCount: widget.confirmedAppoList.length, - itemBuilder: (context, i) { - return AppointmentCard( - appo: widget.confirmedAppoList[i], - onReloadAppointmentHistory: getPatientAppointmentHistory, - ); - }, + margin: EdgeInsets.only(top: 10.0), + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + ...List.generate( + widget._patientConfirmedAppointmentListHospital.length, + (index) => AppExpandableNotifier( + title: widget + ._patientConfirmedAppointmentListHospital[index] + .filterName, + bodyWidget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: widget + ._patientConfirmedAppointmentListHospital[index] + .patientDoctorAppointmentList + .map((doctor) { + return AppointmentCard( + appo: doctor, + onReloadAppointmentHistory: + getPatientAppointmentHistory, + ); + }).toList(), + )), + ) + ], + ), ), ) : Container( @@ -206,16 +352,47 @@ class _MyAppointmentsState extends State Widget getArrivedAppointments() { return widget.arrivedAppoList.length != 0 ? Container( - child: new ListView.builder( - itemCount: widget.arrivedAppoList.length, - itemBuilder: (context, i) { - return AppointmentCard( - appo: widget.arrivedAppoList[i], - onReloadAppointmentHistory: getPatientAppointmentHistory, - ); - }, + margin: EdgeInsets.only(top: 10.0), + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + ...List.generate( + widget._patientArrivedAppointmentListHospital.length, + (index) => AppExpandableNotifier( + title: widget + ._patientArrivedAppointmentListHospital[index] + .filterName, + bodyWidget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: widget + ._patientArrivedAppointmentListHospital[index] + .patientDoctorAppointmentList + .map((doctor) { + return AppointmentCard( + appo: doctor, + onReloadAppointmentHistory: + getPatientAppointmentHistory, + ); + }).toList(), + )), + ) + ], + ), ), ) +// Container( +// child: new ListView.builder( +// itemCount: widget.arrivedAppoList.length, +// itemBuilder: (context, i) { +// return AppointmentCard( +// appo: widget.arrivedAppoList[i], +// onReloadAppointmentHistory: getPatientAppointmentHistory, +// ); +// }, +// ), +// ) : Container( child: Center( child: Column( diff --git a/lib/pages/MyAppointments/widgets/AppointmentCardView.dart b/lib/pages/MyAppointments/widgets/AppointmentCardView.dart index e2f6f706..b64bd232 100644 --- a/lib/pages/MyAppointments/widgets/AppointmentCardView.dart +++ b/lib/pages/MyAppointments/widgets/AppointmentCardView.dart @@ -42,7 +42,7 @@ class _ApointmentCardState extends State { fit: BoxFit.fill, height: 60.0, width: 60.0), ), Container( - width: MediaQuery.of(context).size.width * 0.6, + width: MediaQuery.of(context).size.width * 0.57, margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -95,7 +95,7 @@ class _ApointmentCardState extends State { emptyIcon: Icons.star, ), Container( - transform: Matrix4.translationValues(0.0, -40.0, 0.0), + transform: Matrix4.translationValues(15.0, -40.0, 0.0), child: Image.asset( "assets/images/new-design/arrow.png", width: 25.0, diff --git a/lib/pages/conference/conference_button_bar.dart b/lib/pages/conference/conference_button_bar.dart index d9abd212..d49c4e4a 100644 --- a/lib/pages/conference/conference_button_bar.dart +++ b/lib/pages/conference/conference_button_bar.dart @@ -212,6 +212,11 @@ class _ConferenceButtonBarState extends State with AfterLay key: Key('microphone-button'), onPressed: () => _onPressed(widget.onAudioEnabled), ), + CircleButton( + child: const Icon(Icons.switch_camera, color: Colors.white), + key: Key('switch-camera-button'), + onPressed: () => _onPressed(widget.onSwitchCamera), + ), CircleButton( radius: 35, child: const RotationTransition( @@ -226,11 +231,6 @@ class _ConferenceButtonBarState extends State with AfterLay key: Key('hangup-button'), onPressed: () => _onPressed(widget.onHangup), ), - CircleButton( - child: const Icon(Icons.switch_camera, color: Colors.white), - key: Key('switch-camera-button'), - onPressed: () => _onPressed(widget.onSwitchCamera), - ), ], ), ); diff --git a/lib/pages/conference/conference_page.dart b/lib/pages/conference/conference_page.dart index 60ffb0d5..7848d4f7 100644 --- a/lib/pages/conference/conference_page.dart +++ b/lib/pages/conference/conference_page.dart @@ -217,21 +217,21 @@ class _ConferencePageState extends State { ); } - if (length <= 3) { - buildInCols(true, false, 1); - } else if (length == 5) { - buildInCols(false, true, 2); - } else if (length <= 6 || length == 8) { - buildInCols(false, false, 2); - } else if (length == 7 || length == 9) { - buildInCols(true, false, 2); - } else if (length == 10) { - buildInCols(false, true, 3); - } else if (length == 13 || length == 16) { - buildInCols(true, false, 3); - } else if (length <= 18) { - buildInCols(false, false, 3); - } +// if (length <= 3) { +// buildInCols(true, false, 1); +// } else if (length == 5) { +// buildInCols(false, true, 2); +// } else if (length <= 6 || length == 8) { +// buildInCols(false, false, 2); +// } else if (length == 7 || length == 9) { +// buildInCols(true, false, 2); +// } else if (length == 10) { +// buildInCols(false, true, 3); +// } else if (length == 13 || length == 16) { +// buildInCols(true, false, 3); +// } else if (length <= 18) { +// buildInCols(false, false, 3); +// } return Column( children: children, diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 073a1d52..8cfbbbcd 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -15,6 +15,7 @@ import 'package:diplomaticquarterapp/services/robo_search/search_provider.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; @@ -107,6 +108,18 @@ class _LandingPageState extends State with WidgetsBindingObserver { }); pageController = PageController(keepPage: true); _firebaseMessaging.setAutoInitEnabled(true); + + if (Platform.isIOS) { + _firebaseMessaging.requestNotificationPermissions( +// const IosNotificationSettings( +// sound: true, +// badge: true, +// alert: true, +// provisional: true, +// ), + ); + } + _firebaseMessaging.getToken().then((String token) { sharedPref.setString(PUSH_TOKEN, token); if (token != null) { @@ -118,6 +131,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { //_firebase Background message handler _firebaseMessaging.configure( onMessage: (Map message) async { + showDialog("onMessage: $message"); print("onMessage: $message"); print(message); print(message['name']); @@ -187,19 +201,68 @@ class _LandingPageState extends State with WidgetsBindingObserver { onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler, onLaunch: (Map message) async { print("onLaunch: $message"); + showDialog("onLaunch: $message"); }, onResume: (Map message) async { print("onResume: $message"); + print(message); + print(message['name']); + print(message['appointmentdate']); + + showDialog("onResume: $message"); + + if (Platform.isIOS) { + if (message['is_call'] == "true") { + var route = ModalRoute.of(context); + + if (route != null) { + print(route.settings.name); + } + + Map myMap = + new Map.from(message); + print(myMap); + LandingPage.isOpenCallPage = true; + LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + if (!isPageNavigated) { + isPageNavigated = true; + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => IncomingCall( + incomingCallData: LandingPage.incomingCallData))) + .then((value) { + isPageNavigated = false; + }); + } + } else { + print("Is Call Not Found iOS"); + } + } else { + print("Is Call Not Found iOS"); + } }, ); } + showDialog(String message) { + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: message, + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () => {}, + cancelFunction: () => {}); + dialog.showAlertDialog(context); + } + void requestPermissions() async { await [ Permission.location, Permission.storage, Permission.camera, Permission.photos, + Permission.notification, Permission.accessMediaLocation ].request(); } diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index 77c3e741..9100a64e 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -14,7 +14,6 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; @@ -49,7 +48,7 @@ class _clinic_listState extends State { liveCareClinicsListResponse = new LiveCareClinicsListResponse(); WidgetsBinding.instance.addPostFrameCallback((_) { // Future.delayed(new Duration(milliseconds: 1200), () { - getLiveCareClinicsList(); + getLiveCareClinicsList(); // }); }); getLanguageID(); @@ -58,79 +57,82 @@ class _clinic_listState extends State { @override Widget build(BuildContext context) { - return AppScaffold( - isShowAppBar: false, - body: SingleChildScrollView( - child: isDataLoaded - ? Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.all(15.0), - child: Text("Online Clinics: ", - style: TextStyle( - fontSize: 20.0, fontWeight: FontWeight.bold)), - ), - ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - padding: EdgeInsets.all(0.0), - itemCount: liveCareClinicsListResponse - .patientERGetClinicsList.length, - itemBuilder: (context, index) { - return InkWell( - onTap: () { - updateSelectedIndex(liveCareClinicsListResponse - .patientERGetClinicsList[index]); - }, - child: ClinicCard( - isSelected: selectedClinicID == - liveCareClinicsListResponse - .patientERGetClinicsList[index] - .serviceID - ? true - : false, - patientERGetClinicsList: liveCareClinicsListResponse - .patientERGetClinicsList[index], - languageID: languageID, - ), - ); - }, - ), - Container( - height: 80.0, - ), - ], - ), - ) - : Container(), - ), - bottomSheet: Container( - width: MediaQuery.of(context).size.width, - height: 50.0, - margin: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), - child: ButtonTheme( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10.0), - ), - minWidth: MediaQuery.of(context).size.width * 0.7, - height: 45.0, - child: RaisedButton( - color: new Color(0xFF60686b), - textColor: Colors.white, - disabledTextColor: Colors.white, - disabledColor: new Color(0xFFbcc2c4), - onPressed: startLiveCare, - child: Text("Start", style: TextStyle(fontSize: 18.0)), - ), - ), + return SingleChildScrollView( + child: Column( + children: [ + isDataLoaded + ? Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.all(15.0), + child: Text("Online Clinics: ", + style: TextStyle( + fontSize: 20.0, fontWeight: FontWeight.bold)), + ), + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + padding: EdgeInsets.all(0.0), + itemCount: liveCareClinicsListResponse + .patientERGetClinicsList.length, + itemBuilder: (context, index) { + return InkWell( + onTap: () { + updateSelectedIndex(liveCareClinicsListResponse + .patientERGetClinicsList[index]); + }, + child: ClinicCard( + isSelected: selectedClinicID == + liveCareClinicsListResponse + .patientERGetClinicsList[index] + .serviceID + ? true + : false, + patientERGetClinicsList: + liveCareClinicsListResponse + .patientERGetClinicsList[index], + languageID: languageID, + ), + ); + }, + ), + Container( + height: 10.0, + ), + ], + ), + ) + : Container(), + isDataLoaded ? Container( + width: MediaQuery.of(context).size.width, + height: 50.0, + margin: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + minWidth: MediaQuery.of(context).size.width * 0.7, + height: 45.0, + child: RaisedButton( + color: new Color(0xFF60686b), + textColor: Colors.white, + disabledTextColor: Colors.white, + disabledColor: new Color(0xFFbcc2c4), + onPressed: startLiveCare, + child: Text("Start", style: TextStyle(fontSize: 18.0)), + ), + ), + ) : Container(), + ], ), ); } void startLiveCare() { + bool isError = false; LiveCareService service = new LiveCareService(); ERAppointmentFeesResponse erAppointmentFeesResponse = new ERAppointmentFeesResponse(); @@ -141,12 +143,15 @@ class _clinic_listState extends State { }) .catchError((err) { print(err); + isError = true; + AppToast.showErrorToast(message: err); }) .showProgressBar( text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)) .then((value) { - getERAppointmentTime( - erAppointmentFeesResponse.getERAppointmentFeesList); + if (!isError) + getERAppointmentTime( + erAppointmentFeesResponse.getERAppointmentFeesList); }); } @@ -158,6 +163,7 @@ class _clinic_listState extends State { getERAppointmentFeesList, res['WatingtimeInteger']); }).catchError((err) { print(err); + AppToast.showErrorToast(message: err); }).showProgressBar( text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); } @@ -339,14 +345,17 @@ class _clinic_listState extends State { service .addNewCallForPatientER(selectedClinicID, clientRequestID, context) .then((res) { - AppToast.showSuccessToast( - message: "New Call has been added successfully"); - }).catchError((err) { - print(err); - }).showProgressBar( - text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)).then((value) { - widget.getLiveCareHistory(); - }); + AppToast.showSuccessToast( + message: "New Call has been added successfully"); + }) + .catchError((err) { + print(err); + }) + .showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)) + .then((value) { + widget.getLiveCareHistory(); + }); } getLanguageID() async { diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index f223f91f..7510987c 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -2,22 +2,17 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/appointment_rate_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; -import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; -import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; -import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; -import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/routes.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -26,7 +21,6 @@ import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; class Login extends StatefulWidget { @override @@ -48,9 +42,16 @@ class _Login extends State { @override void initState() { +// getDeviceToken(); super.initState(); } + getDeviceToken() async { + setState(() async { + nationalIDorFile.text = await sharedPref.getString(PUSH_TOKEN); + }); + } + @override Widget build(BuildContext context) { return AppScaffold( @@ -196,7 +197,10 @@ class _Login extends State { this.sharedPref.setObject(USER_PROFILE, result.list), this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), this.sharedPref.setString(TOKEN, result.authenticationTokenID), - + //this.checkIfUserAgreedBefore(result), + Navigator.of(context).pushNamed( + HOME, + ), appointmentRateViewModel .getIsLastAppointmentRatedList() .then((value) => { @@ -219,7 +223,6 @@ class _Login extends State { ) } }) - // SMSOTP.showLoadingDialog(context, false), }); } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index ba3ad56e..c992e8e9 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -10,7 +10,6 @@ import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:flutter/cupertino.dart'; class DoctorsListService extends BaseService { @@ -20,7 +19,11 @@ class DoctorsListService extends BaseService { AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); - Future getDoctorsList(int clinicID, int projectID, BuildContext context, + double lat; + double long; + + Future getDoctorsList( + int clinicID, int projectID, bool isNearest, BuildContext context, {doctorId}) async { //Utils.showProgressDialog(context); Map request; @@ -31,6 +34,12 @@ class DoctorsListService extends BaseService { authUser = data; } + if (await this.sharedPref.getDouble(USER_LAT) != null && + await this.sharedPref.getDouble(USER_LONG) != null) { + lat = await this.sharedPref.getDouble(USER_LAT); + long = await this.sharedPref.getDouble(USER_LONG); + } + var languageID = await sharedPref.getString(APP_LANGUAGE); Request req = appGlobal.getPublicRequest(); request = { @@ -52,8 +61,11 @@ class DoctorsListService extends BaseService { "gender": authUser.gender != null ? authUser.gender : 0, "age": authUser.age != null ? authUser.age : 0, "IsGetNearAppointment": false, - "Latitude": 0, - "Longitude": 0, + "Latitude": lat.toString(), + "Longitude": long.toString(), + "IsGetNearAppointment": isNearest, + if (isNearest) + "SelectedDate": DateUtil.convertDateToString(DateTime.now()), "License": true }; @@ -71,12 +83,21 @@ class DoctorsListService extends BaseService { Future getDoctorsListByName(String docName, BuildContext context) async { Map request; + double lat; + double long; + if (await this.sharedPref.getObject(USER_PROFILE) != null) { var data = AuthenticatedUser.fromJson( await this.sharedPref.getObject(USER_PROFILE)); authUser = data; } + if (await this.sharedPref.getDouble(USER_LAT) != null && + await this.sharedPref.getDouble(USER_LONG) != null) { + lat = await this.sharedPref.getDouble(USER_LAT); + long = await this.sharedPref.getDouble(USER_LONG); + } + var languageID = await sharedPref.getString(APP_LANGUAGE); Request req = appGlobal.getPublicRequest(); request = { @@ -98,8 +119,8 @@ class DoctorsListService extends BaseService { "gender": authUser.gender != null ? authUser.gender : 0, "age": authUser.age != null ? authUser.age : 0, "IsGetNearAppointment": false, - "Latitude": 0, - "Longitude": 0, + "Latitude": lat, + "Longitude": long, "License": true }; diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 42c9754c..8cc1e469 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -1,13 +1,22 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:flutter/material.dart'; class ClinicListService extends BaseService { AppSharedPreferences sharedPref = AppSharedPreferences(); AppGlobal appGlobal = new AppGlobal(); + AuthenticatedUser authUser = new AuthenticatedUser(); + AuthProvider authProvider = new AuthProvider(); + + double lat; + double long; + Future getClinicsList(context) async { Map request; var languageID = await sharedPref.getString(APP_LANGUAGE); @@ -28,10 +37,128 @@ class ClinicListService extends BaseService { await baseAppClient.post(GET_CLINICS_LIST_URL, onSuccess: (response, statusCode) async { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: request); + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future getProjectsList(context) async { + Map request; + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + request = { + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": "10.20.10.20", + "VersionID": req.VersionID, + "Channel": req.Channel, + "generalid": 'Cs2020@2016\$2958', + "PatientOutSA": 0, + "TokenID": "", + "DeviceTypeID": req.DeviceTypeID, + "SessionID": null + }; + + dynamic localRes; + + await baseAppClient.post(GET_PROJECTS_LIST, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future getChiefComplaintsList( + int clinicID, int projectID, BuildContext context, + {doctorId}) async { + //Utils.showProgressDialog(context); + Map request; + + if (await this.sharedPref.getObject(USER_PROFILE) != null) { + var data = AuthenticatedUser.fromJson( + await this.sharedPref.getObject(USER_PROFILE)); + authUser = data; + } + + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + request = { + "ClinicID": clinicID, + "ProjectID": projectID, + "SelectedDate": "", + "SelectedTime": "", + "License": true, + "VersionID": 5.6, + "Channel": 3, + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": "10.20.10.20", + "generalid": "Cs2020@2016\$2958", + "PatientOutSA": 0, + "SessionID": null, + "isDentalAllowedBackend": true, + "DeviceTypeID": 1, + "PatientID": 1, + "ContinueDentalPlan": true, + "IsSearchAppointmnetByClinicID": false + }; + + dynamic localRes; + + await baseAppClient.post(GET_DOCTORS_LIST_URL, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future getChiefComplaintDoctorList( + int chiefComplaintID, int projectID, BuildContext context, + {doctorId}) async { + Map request; + + if (await this.sharedPref.getObject(USER_PROFILE) != null) { + var data = AuthenticatedUser.fromJson( + await this.sharedPref.getObject(USER_PROFILE)); + authUser = data; + } + + if (await this.sharedPref.getDouble(USER_LAT) != null && + await this.sharedPref.getDouble(USER_LONG) != null) { + lat = await this.sharedPref.getDouble(USER_LAT); + long = await this.sharedPref.getDouble(USER_LONG); + } + + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + request = { + "ChiefComplaintID": chiefComplaintID, + "ProjectID": projectID, + "VersionID": 5.6, + "Channel": 3, + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": req.IPAdress, + "generalid": req.generalid, + "PatientOutSA": 0, + "SessionID": null, + "isDentalAllowedBackend": true, + "Latitude": lat.toString(), + "Longitude": long.toString(), + "DeviceTypeID": 1 + }; + + dynamic localRes; + + await baseAppClient.post(GET_DENTAL_DOCTORS_LIST_URL, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); return Future.value(localRes); } } diff --git a/lib/uitl/location_util.dart b/lib/uitl/location_util.dart new file mode 100644 index 00000000..e3012734 --- /dev/null +++ b/lib/uitl/location_util.dart @@ -0,0 +1,69 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:geolocator/geolocator.dart'; + +class LocationUtils { + AppSharedPreferences sharedPref = new AppSharedPreferences(); + + bool isShowConfirmDialog; + BuildContext context; + + LocationUtils({@required this.isShowConfirmDialog, @required this.context}); + + void getCurrentLocation() async { + print("current location"); + isLocationServiceEnabled().then((value) { + if (value) { + checkPermission().then((permission) { + if (permission == LocationPermission.always || + permission == LocationPermission.whileInUse) { + getLastKnownPosition().then((value) => setLocation(value)); + } + + if (permission == LocationPermission.denied || + permission == LocationPermission.deniedForever) { + setZeroLocation(); + if (isShowConfirmDialog) showErrorLocationDialog(false); + } + }).catchError((err) { + print(err); + }); + } else { + if (isShowConfirmDialog) showErrorLocationDialog(false); + } + }).catchError((err) { + print(err); + }); + } + + showErrorLocationDialog(bool isPermissionError) { + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: TranslationBase.of(context).locationDialogMessage, + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () => { + ConfirmDialog.closeAlertDialog(context), + if (isPermissionError) + openAppSettings() + else + openLocationSettings() + }, + cancelFunction: () => {}); + return dialog.showAlertDialog(context); + } + + void setLocation(Position position) { + print(position); + this.sharedPref.setDouble(USER_LAT, position.latitude); + this.sharedPref.setDouble(USER_LONG, position.longitude); + } + + void setZeroLocation() { + this.sharedPref.setDouble(USER_LAT, 0.0); + this.sharedPref.setDouble(USER_LONG, 0.0); + } +} diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 22e39c39..6f069e9c 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -510,6 +510,10 @@ class TranslationBase { String get vitalSign => localizedValues['VitalSign'][locale.languageCode]; String get monthlyReports => localizedValues['MonthlyReports'][locale.languageCode]; + String get locationDialogMessage => + localizedValues['locationDialogMessage'][locale.languageCode]; + String get km => + localizedValues['km'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 526c0f5b..6958e67f 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -1,5 +1,4 @@ import 'package:connectivity/connectivity.dart'; -import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/widgets/others/bottom_bar.dart b/lib/widgets/others/bottom_bar.dart index 32df2dfc..d0fc01f6 100644 --- a/lib/widgets/others/bottom_bar.dart +++ b/lib/widgets/others/bottom_bar.dart @@ -312,7 +312,7 @@ class _SearchBot extends State { List doctorsList = []; DoctorsListService service = new DoctorsListService(); service - .getDoctorsList(clinicId, projectId, context, doctorId: doctorName) + .getDoctorsList(clinicId, projectId, false, context, doctorId: doctorName) .then((res) { if (res['MessageStatus'] == 1) { setState(() { diff --git a/pubspec.yaml b/pubspec.yaml index 4a87b43a..918bca3a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: flutter: sdk: flutter + # Localizations flutter_localizations: sdk: flutter @@ -61,7 +62,7 @@ dependencies: # Notification Banner dropdown_banner: ^1.4.0 - flutter_local_notifications: +# flutter_local_notifications: # charts charts_flutter: ^0.9.0 @@ -107,6 +108,9 @@ dependencies: + #Handle Geolocation + geolocator: ^6.0.0+1 + #Dependencies for video call implementation native_device_orientation: ^0.3.0 enum_to_string: ^1.0.9