diff --git a/lib/config/config.dart b/lib/config/config.dart index 55c0d584..04863ca7 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -112,7 +112,7 @@ const SEND_CALL_REQUEST = 'Services/Doctors.svc/REST/InsertCallInfo'; const CHANNEL = 3; const GENERAL_ID = 'Cs2020@2016\$2958'; const IP_ADDRESS = '10.20.10.20'; -const VERSION_ID = 5.5; +const VERSION_ID = 5.6; const SETUP_ID = '91877'; const LANGUAGE = 1; const PATIENT_OUT_SA = 0; @@ -140,7 +140,7 @@ class AppGlobal { Request getPublicRequest() { Request request = new Request(); - request.VersionID = 5.5; //3.6; + request.VersionID = 5.6; //3.6; request.Channel = 3; request.IPAdress = "10.20.10.20"; request.generalid = 'Cs2020@2016\$2958'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 987feb96..7e783090 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -11,7 +11,7 @@ const Map> localizedValues = { 'services': {'en': 'SERVICES', 'ar': 'الخدمات'}, 'mySchedule': {'en': 'My Schedule', 'ar': 'جدولي'}, 'logout': {'en': 'Logout', 'ar': 'تسجيل خروج'}, - 'respirationRate':{'en': 'Respiration Rate', 'ar': 'معدل التنفس'}, + 'respirationRate': {'en': 'Respiration Rate', 'ar': 'معدل التنفس'}, 'bookAppo': {'en': 'Book Appointment', 'ar': 'حجز موعد'}, 'searchBy': {'en': 'Search By:', 'ar': 'البحث عن طريق:'}, 'clinic': {'en': 'Clinic', 'ar': 'العيادة'}, @@ -58,15 +58,41 @@ const Map> localizedValues = { 'viewQR': {'en': 'View QR Code', 'ar': 'عرض رمز الاستجابة السريعة'}, 'instruction': {'en': 'Instructions', 'ar': 'تعليمات'}, 'livecare': {'en': 'LiveCare', 'ar': 'لايف كير'}, - 'cancelAppoMsg': {'en': 'Are you sure you want to cancel this appointment?', 'ar': 'هل أنت متأكد أنك تريد إلغاء هذا الموعد؟'}, + 'cancelAppoMsg': { + 'en': 'Are you sure you want to cancel this appointment?', + 'ar': 'هل أنت متأكد أنك تريد إلغاء هذا الموعد؟' + }, - 'upcoming-noAction': {'en': 'No Action Required', 'ar': 'لا يوجد إجراء مطلوب'}, - 'upcoming-confirm': {'en': 'Please confirm the appointment to avoid cancellation', 'ar': 'يرجى تأكيد الموعد لتفادي الإلغاء'}, - 'upcoming-payment-pending': {'en': 'Online Payment will be Activated before 24 Hours of Appointment Time', 'ar': 'سيتم تفعيل خدمة الدفع الالكتروني قبل 24 ساعة من موعد الحجز'}, - 'upcoming-payment-now': {'en': 'Pay Online now to avoid long waiting queue', 'ar': 'ادفع الآن لتفادي الانتظار'}, - 'upcoming-QR': {'en': 'Use the QR Code to Check-In in hospital', 'ar': 'استخدم الرمز لتسجيل الحضور في المستشفى'}, - 'upcoming-virtual': {'en': 'This is a virtual appointment, Please adhere to the instructions for a seamless experience.', 'ar': 'هذا موعد اتصال مرئي عن بعد ، يرجى اتباع تعليمات الخدمة.'}, - 'upcoming-livecare': {'en': 'This is a LiveCare appointment', 'ar': 'هذا موعد لايف كير'}, + 'upcoming-noAction': { + 'en': 'No Action Required', + 'ar': 'لا يوجد إجراء مطلوب' + }, + 'upcoming-confirm': { + 'en': 'Please confirm the appointment to avoid cancellation', + 'ar': 'يرجى تأكيد الموعد لتفادي الإلغاء' + }, + 'upcoming-payment-pending': { + 'en': + 'Online Payment will be Activated before 24 Hours of Appointment Time', + 'ar': 'سيتم تفعيل خدمة الدفع الالكتروني قبل 24 ساعة من موعد الحجز' + }, + 'upcoming-payment-now': { + 'en': 'Pay Online now to avoid long waiting queue', + 'ar': 'ادفع الآن لتفادي الانتظار' + }, + 'upcoming-QR': { + 'en': 'Use the QR Code to Check-In in hospital', + 'ar': 'استخدم الرمز لتسجيل الحضور في المستشفى' + }, + 'upcoming-virtual': { + 'en': + 'This is a virtual appointment, Please adhere to the instructions for a seamless experience.', + 'ar': 'هذا موعد اتصال مرئي عن بعد ، يرجى اتباع تعليمات الخدمة.' + }, + 'upcoming-livecare': { + 'en': 'This is a LiveCare appointment', + 'ar': 'هذا موعد لايف كير' + }, 'upcoming-details': {'en': 'More Details', 'ar': 'المزيد'}, 'reschedule': {'en': 'Reschedule', 'ar': 'إعادة جدولة'}, 'raise': {'en': 'Raise', 'ar': 'رفع'}, @@ -161,27 +187,67 @@ const Map> localizedValues = { "before": {"en": "Before", "ar": "قبل"}, "minute": {"en": "Minutes", "ar": "دقيقة"}, "hour": {"en": "Hour", "ar": "ساعة"}, - "reminderSuccess": {"en": "The reminder has been added successfully", "ar": "يضاف التذكير بنجاح"}, - "patientShareToDo": {"en": "Amount before tax: ", "ar": "المبلغ قبل الضريبة:"}, + "reminderSuccess": { + "en": "The reminder has been added successfully", + "ar": "يضاف التذكير بنجاح" + }, + "patientShareToDo": { + "en": "Amount before tax: ", + "ar": "المبلغ قبل الضريبة:" + }, "patientTaxToDo": {"en": "Tax amount: ", "ar": "قيمة الضريبة:"}, - "patientShareTotalToDo": {"en": "Total amount Due: ", "ar": "المبلغ الإجمالي المستحق:"}, + "patientShareTotalToDo": { + "en": "Total amount Due: ", + "ar": "المبلغ الإجمالي المستحق:" + }, 'paymentMethod': {'en': 'Payment Method', 'ar': 'طريقة الدفع او السداد'}, - 'noNeedToWaitInLine': {'en': 'No need to stand in line.', 'ar': 'لا داعي للوقوف في الطابور.'}, - 'useQRAppoAttend': {'en': 'Use the QR code to register the appointment attendance.', 'ar': 'استخدم الكود لتسجيل الحضور في المستشفى.'}, - 'passQRAppoAttend': {'en': 'Pass the QR code through the attendance devices available in the Hospital.', 'ar': 'تمرير الكود من خلال اجهزة تسجيل الحضور المتوفرة في الفرع.'}, - 'sitWaitingQR': {'en': 'Sit in the waiting rooms until called by the nurse.', 'ar': 'الجلوس في غرف الانتظار لحين منادتك من قبل الممرضة.'}, - 'attendRegisterCode': {'en': 'Attendance registration code', 'ar': 'رمز تسجيل الحضور'}, - 'scanQRHospital': {'en': 'Scan above QR Code to Check-In on the Machine in Hospital', 'ar': 'مسح فوق رمز الاستجابة السريعة للتحقق في الجهاز في المستشفى'}, + 'noNeedToWaitInLine': { + 'en': 'No need to stand in line.', + 'ar': 'لا داعي للوقوف في الطابور.' + }, + 'useQRAppoAttend': { + 'en': 'Use the QR code to register the appointment attendance.', + 'ar': 'استخدم الكود لتسجيل الحضور في المستشفى.' + }, + 'passQRAppoAttend': { + 'en': + 'Pass the QR code through the attendance devices available in the Hospital.', + 'ar': 'تمرير الكود من خلال اجهزة تسجيل الحضور المتوفرة في الفرع.' + }, + 'sitWaitingQR': { + 'en': 'Sit in the waiting rooms until called by the nurse.', + 'ar': 'الجلوس في غرف الانتظار لحين منادتك من قبل الممرضة.' + }, + 'attendRegisterCode': { + 'en': 'Attendance registration code', + 'ar': 'رمز تسجيل الحضور' + }, + 'scanQRHospital': { + 'en': 'Scan above QR Code to Check-In on the Machine in Hospital', + 'ar': 'مسح فوق رمز الاستجابة السريعة للتحقق في الجهاز في المستشفى' + }, "sendEmail": {"en": "Send Email", "ar": "ارسال نسخة"}, "close": {"en": "Close", "ar": "مغلق"}, "booked": {"en": "Booked", "ar": "محجوز"}, "confirmed": {"en": "Confirmed", "ar": "مؤكد"}, "arrived": {"en": "Arrived", "ar": "تم الحضور"}, - "payNowBookSuccess": {"en": "Pay now via Al Habib App", "ar": "ادفع الآن عبر تطبيق الحبيب"}, - "payNowBookSuccesstext1": {"en": "Pay Now using online payment service From secure payment gateways", "ar": "ادفع الآن باستخدام خدمة الدفع عبر الإنترنت من بوابات الدفع الآمنة"}, - "payNowBookSuccesstext2": {"en": "You can also Pay Later via online payment Or in Hospital", "ar": "يمكنك أيضًا الدفع لاحقًا عبر الدفع عبر الإنترنت أو في المستشفى"}, + "payNowBookSuccess": { + "en": "Pay now via Al Habib App", + "ar": "ادفع الآن عبر تطبيق الحبيب" + }, + "payNowBookSuccesstext1": { + "en": "Pay Now using online payment service From secure payment gateways", + "ar": "ادفع الآن باستخدام خدمة الدفع عبر الإنترنت من بوابات الدفع الآمنة" + }, + "payNowBookSuccesstext2": { + "en": "You can also Pay Later via online payment Or in Hospital", + "ar": "يمكنك أيضًا الدفع لاحقًا عبر الدفع عبر الإنترنت أو في المستشفى" + }, 'payLater': {'en': 'Pay Later', 'ar': 'ادفع لاحقا'}, - 'askDocNotAllowed': {'en': 'This service will be available for last 15 days doctor Visit only', 'ar': 'هذه الخدمة متاحة للزيارات خلال اخر 15 يوم فقط'}, + 'askDocNotAllowed': { + 'en': 'This service will be available for last 15 days doctor Visit only', + 'ar': 'هذه الخدمة متاحة للزيارات خلال اخر 15 يوم فقط' + }, "more-verify": { "en": "More Verification Options", "ar": "المزيد من خيارات التحقق" @@ -221,9 +287,9 @@ const Map> localizedValues = { 'respiration': {'en': 'Respiration', 'ar': 'التنفس'}, 'bloodPressure': {'en': 'Blood Pressure', 'ar': 'ضغط الدم'}, 'painScale': {'en': 'Pain Scale', 'ar': 'مقياس الألم'}, - 'weight' : {'en':'Weight','ar':'الوزن'}, - 'height' : {'en':'Height','ar':'الطول'}, - 'heart' :{'en':'Heart','ar':'قلب'}, + 'weight': {'en': 'Weight', 'ar': 'الوزن'}, + 'height': {'en': 'Height', 'ar': 'الطول'}, + 'heart': {'en': 'Heart', 'ar': 'قلب'}, "request": {"en": "Request", "ar": "طلبات الاضافة"}, "member-name": {"en": "Member Name", "ar": "اسم العضو"}, @@ -252,5 +318,13 @@ const Map> localizedValues = { "policyNumber": {"en": "Policy Number: ", "ar": "رقم بوليصة التاميت:"}, "seeDetails": {"en": "SEE DETAILS", "ar": "منافعك التامينية"}, "insuranceCards": {"en": "Insurance Cards", "ar": "بطاقات التأمين"}, - "requestType": {"en": "Request Type", "ar": "نوع الاستفسار"} + "requestType": {"en": "Request Type", "ar": "نوع الاستفسار"}, + "register-info-family": { + "en": "How would like to add the new member?", + "ar": "كيف ترغب باضافة العضو الجديد؟" + }, + "remove-family-member": { + "en": "Remove this member?", + "ar": "إزالة ملف العضو؟" + }, }; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 53fa08dd..414c6a80 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -10,3 +10,4 @@ const ONLY_SMS = 'only-sms'; const AUTH_DATA = 'auth-data'; const IMEI_USER_DATA = 'imei-user-data'; const NHIC_DATA = 'nhic-data'; +const FAMILY_FILE = 'family-file'; diff --git a/lib/core/model/family-file/add_family_file_request.dart b/lib/core/model/family-file/add_family_file_request.dart new file mode 100644 index 00000000..cfec8e39 --- /dev/null +++ b/lib/core/model/family-file/add_family_file_request.dart @@ -0,0 +1,92 @@ +class AddFamilyFileReq { + int searchType; + int sharedPatientID; + String sharedPatientIdentificationID; + String sharedPatientMobileNumber; + String zipCode; + bool isRegister; + int patientStatus; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + + AddFamilyFileReq( + {this.searchType, + this.sharedPatientID, + this.sharedPatientIdentificationID, + this.sharedPatientMobileNumber, + this.zipCode, + this.isRegister, + this.patientStatus, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType}); + + AddFamilyFileReq.fromJson(Map json) { + searchType = json['SearchType']; + sharedPatientID = json['SharedPatientID']; + sharedPatientIdentificationID = json['SharedPatientIdentificationID']; + sharedPatientMobileNumber = json['SharedPatientMobileNumber']; + zipCode = json['ZipCode']; + isRegister = json['isRegister']; + patientStatus = json['PatientStatus']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + } + + Map toJson() { + final Map data = new Map(); + data['SearchType'] = this.searchType; + data['SharedPatientID'] = this.sharedPatientID; + data['SharedPatientIdentificationID'] = this.sharedPatientIdentificationID; + data['SharedPatientMobileNumber'] = this.sharedPatientMobileNumber; + data['ZipCode'] = this.zipCode; + data['isRegister'] = this.isRegister; + data['PatientStatus'] = this.patientStatus; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + return data; + } +} diff --git a/lib/core/model/family-file/insert b/lib/core/model/family-file/insert new file mode 100644 index 00000000..e69de29b diff --git a/lib/core/model/family-file/insert_share_file_request.dart b/lib/core/model/family-file/insert_share_file_request.dart new file mode 100644 index 00000000..02fa9a0b --- /dev/null +++ b/lib/core/model/family-file/insert_share_file_request.dart @@ -0,0 +1,80 @@ +class InsertSharePatientFileReq { + int responseID; + String shareFamilyPatientName; + int status; + int regionID; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + + InsertSharePatientFileReq( + {this.responseID, + this.shareFamilyPatientName, + this.status, + this.regionID, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType}); + + InsertSharePatientFileReq.fromJson(Map json) { + responseID = json['ResponseID']; + shareFamilyPatientName = json['ShareFamilyPatientName']; + status = json['Status']; + regionID = json['RegionID']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + } + + Map toJson() { + final Map data = new Map(); + data['ResponseID'] = this.responseID; + data['ShareFamilyPatientName'] = this.shareFamilyPatientName; + data['Status'] = this.status; + data['RegionID'] = this.regionID; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + return data; + } +} diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 717239ca..541228db 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -25,7 +25,7 @@ class BaseAppClient { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); var languageID = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + 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 @@ -77,11 +77,13 @@ class BaseAppClient { } else { if (isAllowAny) { onSuccess(parsed, statusCode); - } else if (!parsed['IsAuthenticated']) { + } else if (parsed['IsAuthenticated'] == null) { if (parsed['isSMSSent'] == true) { onSuccess(parsed, statusCode); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); + } else if (parsed['Result'] == 'OK') { + onSuccess(parsed, statusCode); } else { onFailure( parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], @@ -91,8 +93,6 @@ class BaseAppClient { } else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { onSuccess(parsed, statusCode); - } else if (parsed['Result'] == 'OK') { - onSuccess(parsed, statusCode); } else { if (parsed['SameClinicApptList'] != null) { onSuccess(parsed, statusCode); diff --git a/lib/pages/BookAppointment/DoctorProfile.dart b/lib/pages/BookAppointment/DoctorProfile.dart index 42f2b3e8..860ebcd6 100644 --- a/lib/pages/BookAppointment/DoctorProfile.dart +++ b/lib/pages/BookAppointment/DoctorProfile.dart @@ -5,7 +5,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:rating_bar/rating_bar.dart'; - +import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'BookConfirm.dart'; import 'components/DocAvailableAppointments.dart'; import 'components/DocInfo.dart'; @@ -13,8 +13,11 @@ import 'components/DocInfo.dart'; class DoctorProfile extends StatefulWidget { DoctorList doctor; DoctorProfileList docProfileList; - - DoctorProfile({@required this.doctor, @required this.docProfileList}); + final bool isOpenAppt; + DoctorProfile( + {@required this.doctor, + @required this.docProfileList, + this.isOpenAppt = false}); @override _DoctorProfileState createState() => _DoctorProfileState(); @@ -24,10 +27,24 @@ class _DoctorProfileState extends State with SingleTickerProviderStateMixin { TabController _tabController; bool showFooterButton = false; - + var event = RobotProvider(); @override void initState() { - _tabController = new TabController(length: 2, vsync: this); + _tabController = new TabController( + length: 2, + vsync: this, + initialIndex: widget.isOpenAppt == true ? 1 : 0); + + event.controller.stream.listen((p) { + if (p['clinic_id'] != null && + p['doctor_id'] != null && + p['project_id'] != null) { + setState(() { + // need to take the data from here + // dropdownValue = p['clinic_id']; + }); + } + }); super.initState(); } diff --git a/lib/pages/BookAppointment/SearchResults.dart b/lib/pages/BookAppointment/SearchResults.dart index 57a88991..05330111 100644 --- a/lib/pages/BookAppointment/SearchResults.dart +++ b/lib/pages/BookAppointment/SearchResults.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; @@ -15,9 +16,28 @@ class SearchResults extends StatefulWidget { } class _SearchResultsState extends State { + var event = RobotProvider(); + List tempList = []; + @override void initState() { - // TODO: implement 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; + // }); + }); super.initState(); } diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index 8a6321ad..68f5c329 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -26,20 +26,19 @@ class _SearchByClinicState extends State { @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(); } @override Widget build(BuildContext context) { - event.controller.stream.listen((p) { - if (p['Id'] != null) { - setState(() { - dropdownValue = p['Id']; - getDoctorsList(context); - }); - } - }); return Container( margin: EdgeInsets.all(10.0), child: Column( diff --git a/lib/pages/BookAppointment/components/SearchByDoctor.dart b/lib/pages/BookAppointment/components/SearchByDoctor.dart index 668426ad..02443c98 100644 --- a/lib/pages/BookAppointment/components/SearchByDoctor.dart +++ b/lib/pages/BookAppointment/components/SearchByDoctor.dart @@ -69,7 +69,11 @@ class _SearchByDoctorState extends State { textColor: Colors.white, disabledTextColor: Colors.white, disabledColor: new Color(0xFFbcc2c4), - onPressed: _isButtonDisabled ? null : _searchDoctor(context), + onPressed: () { + if (_isButtonDisabled == false) { + _searchDoctor(context); + } + }, child: Text(TranslationBase.of(context).search, style: TextStyle(fontSize: 18.0)), ), @@ -79,14 +83,16 @@ class _SearchByDoctorState extends State { getDoctorsList(BuildContext context) { List doctorsList = []; DoctorsListService service = new DoctorsListService(); - service.getDoctorsListByName(doctorNameController.text, context).then((res) { + service + .getDoctorsListByName(doctorNameController.text, context) + .then((res) { if (res['MessageStatus'] == 1) { setState(() { - if(res['DoctorList'].length != 0) { - res['DoctorList'].forEach((v) { - doctorsList.add(new DoctorList.fromJson(v)); - }); - } else {} + if (res['DoctorList'].length != 0) { + res['DoctorList'].forEach((v) { + doctorsList.add(new DoctorList.fromJson(v)); + }); + } else {} }); navigateToSearchResults(context, doctorsList); } else { diff --git a/lib/pages/BookAppointment/widgets/DoctorView.dart b/lib/pages/BookAppointment/widgets/DoctorView.dart index 031f53c3..62153f2e 100644 --- a/lib/pages/BookAppointment/widgets/DoctorView.dart +++ b/lib/pages/BookAppointment/widgets/DoctorView.dart @@ -111,12 +111,12 @@ class DoctorView extends StatelessWidget { return docSpeciality; } - getDoctorsProfile(context, DoctorList docObject) { + getDoctorsProfile(context, DoctorList docObject, {isAppo}) { List docProfileList = []; DoctorsListService service = new DoctorsListService(); service - .getDoctorsProfile( - docObject.doctorID, docObject.clinicID, docObject.projectID, context) + .getDoctorsProfile(docObject.doctorID, docObject.clinicID, + docObject.projectID, context) .then((res) { if (res['MessageStatus'] == 1) { if (res['DoctorProfileList'].length != 0) { @@ -124,7 +124,8 @@ class DoctorView extends StatelessWidget { docProfileList.add(new DoctorProfileList.fromJson(v)); }); } else {} - navigateToDoctorProfile(context, docObject, docProfileList[0]); + navigateToDoctorProfile(context, docObject, docProfileList[0], + isAppo: isAppo); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } @@ -133,11 +134,15 @@ class DoctorView extends StatelessWidget { }); } - Future navigateToDoctorProfile(context, docObject, docProfile) async { + Future navigateToDoctorProfile(context, docObject, docProfile, + {isAppo}) async { Navigator.push( context, MaterialPageRoute( - builder: (context) => - DoctorProfile(doctor: docObject, docProfileList: docProfile))); + builder: (context) => DoctorProfile( + doctor: docObject, + docProfileList: docProfile, + isOpenAppt: isAppo, + ))); } } diff --git a/lib/pages/family/add-family-member.dart b/lib/pages/family/add-family-member.dart new file mode 100644 index 00000000..f1742141 --- /dev/null +++ b/lib/pages/family/add-family-member.dart @@ -0,0 +1,245 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/family-file/add_family_file_request.dart'; +import 'package:diplomaticquarterapp/core/model/family-file/insert_share_file_request.dart'; +import 'package:diplomaticquarterapp/routes.dart'; +import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; +import 'package:diplomaticquarterapp/pages/family/add-family_type.dart'; +import 'package:diplomaticquarterapp/services/family_files/family_files_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/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.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'; +import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart'; +import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; + +class AddMember extends StatefulWidget { + @override + _AddMember createState() => _AddMember(); +} + +class _AddMember extends State { + final util = Utils(); + final nationalIDorFile = TextEditingController(); + final int loginType = AddFamilyMemberType.loginType; + String mobileNo; + String countryCode = '966'; + bool isButtonDisabled = true; + var sharedPref = new AppSharedPreferences(); + final authService = new AuthProvider(); + bool isLoading = false; + var familyFileProvider = FamilyFilesProvider(); + + var patientShareRequestID; + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: TranslationBase.of(context).myFamilyFiles, + isShowAppBar: true, + body: isLoading == true + ? AppCircularProgressIndicator() + : SingleChildScrollView( + child: Container( + padding: + EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30), + height: SizeConfig.realScreenHeight * .9, + width: SizeConfig.realScreenWidth, + child: Column(children: [ + Expanded( + flex: 2, + child: AppText( + TranslationBase.of(context).enterNationalId, + fontSize: SizeConfig.textMultiplier * 3.5, + textAlign: TextAlign.left, + )), + Expanded( + flex: 3, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + MobileNo( + onNumberChange: (value) => + {mobileNo = value, validateForm()}, + onCountryChange: (value) => countryCode = value), + Container( + child: TextFields( + controller: nationalIDorFile, + onChanged: (value) => {validateForm()}, + prefixIcon: Icon( + loginType == 1 + ? Icons.chrome_reader_mode + : Icons.receipt, + color: Colors.red), + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + hintText: loginType == 1 + ? TranslationBase.of(context).nationalID + : TranslationBase.of(context).fileNo, + )) + ], + ), + ), + Expanded( + flex: 3, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + children: [ + Expanded( + child: DefaultButton( + TranslationBase.of(context).add, + () => {this.addMember()}, + color: isButtonDisabled == true + ? Colors.grey + : Colors.grey[900], + textColor: Colors.white, + )) + ], + ), + ], + )) + ]), + ))); + } + + void validateForm() { + if (util.validateIDBox(nationalIDorFile.text, loginType) == true && + mobileNo.length >= 9 && + util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { + setState(() { + isButtonDisabled = false; + }); + } else { + setState(() { + isButtonDisabled = true; + }); + } + } + + addMember() { + var request = AddFamilyFileReq(); + if (this.loginType == 1) { + request.sharedPatientID = 0; + request.sharedPatientIdentificationID = this.nationalIDorFile.text; + } else if (this.loginType == 2) { + request.sharedPatientID = int.parse(this.nationalIDorFile.text); + request.sharedPatientIdentificationID = ''; + } + request.searchType = this.loginType; + request.sharedPatientMobileNumber = this.mobileNo; + request.zipCode = countryCode; + request.isRegister = false; + request.patientStatus = 2; + loading(true); + familyFileProvider + .addFamilyFile(request) + .then((value) => manageFamily(value)) + .catchError(() { + loading(false); + }); + } + + manageFamily(addMemberResult) { + loading(false); + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: addMemberResult['ShareFamilyFileObj']['Message'], + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () => { + insertFamilyData(addMemberResult), + ConfirmDialog.closeAlertDialog(context) + }, + cancelFunction: () => {}); + dialog.showAlertDialog(context); + } + + insertFamilyData(addMemberResult) { + var request = InsertSharePatientFileReq(); + request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID']; + request.shareFamilyPatientName = + addMemberResult['ShareFamilyFileObj']['SharedPatientName']; + request.status = 2; + if (request.patientOutSA == 1) { + request.regionID = 2; + } else { + request.regionID = 1; + } + loading(true); + this + .familyFileProvider + .insertNewMember(request) + .then((value) => sendActivationCode(value)); + } + + sendActivationCode(result) { + // var request = this.getCommonRequest(); + loading(true); + patientShareRequestID = result['PatientShareRequestID']; + this + .familyFileProvider + .sendActivationCode(mobileNo, countryCode, nationalIDorFile.text) + .then((result) => { + if (result != null && result['isSMSSent'] == true) + {this.startSMSService(1, result)} + // {loading(false), this.startSMSService(type)} + // else + // {loading(false)} + }); + } + + startSMSService(type, result) { + loading(false); + new SMSOTP( + context, + type, + this.mobileNo, + (value) => {this.checkActivationCode(value, result)}, + () => { + print('Faild..'), + }, + ).displayDialog(context); + } + + checkActivationCode(value, result) { + this + .familyFileProvider + .checkActivationCode( + result['LogInTokenID'], value, nationalIDorFile.text, mobileNo) + .then((result) => { + SMSOTP.hideSMSBox(context), + handleFamilyRequests(this.patientShareRequestID, 3) + }); + } + + handleFamilyRequests(id, stauts) { + this + .familyFileProvider + .acceptAndRejectRecievedRequests(id, stauts) + .then((result) => { + sharedPref.remove(FAMILY_FILE), + Navigator.of(context).pushNamed( + MY_FAMILIY, + ) + }); + } + + loading(flag) { + setState(() { + isLoading = flag; + }); + } +} diff --git a/lib/pages/family/add-family_type.dart b/lib/pages/family/add-family_type.dart new file mode 100644 index 00000000..96e055b3 --- /dev/null +++ b/lib/pages/family/add-family_type.dart @@ -0,0 +1,154 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/routes.dart'; + +class AddFamilyMemberType extends StatelessWidget { + static int loginType = 0; + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: TranslationBase.of(context).myFamilyFiles, + isShowAppBar: true, + body: Padding( + padding: EdgeInsets.all(20), + child: Column( + children: [ + Expanded( + flex: 6, + child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Image.asset( + 'assets/images/habib-logo.png', + height: 80, + width: 80, + ), + Padding( + padding: EdgeInsets.all(20), + child: AppText( + TranslationBase.of(context).registerInfoFamily, + fontSize: SizeConfig.textMultiplier * 3.5, + textAlign: TextAlign.left, + ), + ), + Padding( + padding: EdgeInsets.all(20), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: InkWell( + onTap: () => { + AddFamilyMemberType.loginType = 1, + Navigator.of(context) + .pushNamed(ADD_FAMILY_MEMBER) + }, + child: RoundedContainer( + borderColor: Colors.grey, + showBorder: true, + child: Padding( + padding: EdgeInsets.fromLTRB( + 20, 10, 20, 10), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/id_card_icon.png', + height: SizeConfig + .imageSizeMultiplier * + 12, + width: SizeConfig + .imageSizeMultiplier * + 15, + ), + SizedBox( + height: 20, + ), + AppText( + TranslationBase.of(context) + .nationalID, + fontSize: SizeConfig + .textMultiplier * + 2, + ) + ], + ), + )))), + Expanded( + child: InkWell( + onTap: () => { + AddFamilyMemberType.loginType = 2, + Navigator.of(context) + .pushNamed(ADD_FAMILY_MEMBER) + }, + child: RoundedContainer( + borderColor: Colors.grey, + showBorder: true, + child: Padding( + padding: EdgeInsets.fromLTRB( + 25, 10, 25, 10), + child: Column( + children: [ + Image.asset( + 'assets/images/my_file_white_icon.png', + height: SizeConfig + .imageSizeMultiplier * + 12, + width: SizeConfig + .imageSizeMultiplier * + 15, + ), + SizedBox( + height: 20, + ), + AppText( + TranslationBase.of(context) + .fileNo, + fontSize: SizeConfig + .textMultiplier * + 2, + ) + ], + ), + )))) + ], + )), + Divider( + color: Colors.grey, + height: 2, + ), + ]), + ), + // Expanded( + // flex: 2, + // child: Column( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Row( + // children: [ + // Expanded( + // child: DefaultButton( + // TranslationBase.of(context).registerNow, + // () => { + // Navigator.of(context).pushNamed( + // REGISTER, + // ) + // }, + // )) + // ], + // ), + // ], + // )) + ], + ))); + } +} diff --git a/lib/pages/family/my-family.dart b/lib/pages/family/my-family.dart index 83152e36..af5919ff 100644 --- a/lib/pages/family/my-family.dart +++ b/lib/pages/family/my-family.dart @@ -2,24 +2,20 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/routes.dart'; -class MyFamily extends StatefulWidget { - @override - _MyFamily createState() => _MyFamily(); -} +class MyFamily extends StatelessWidget { + //bool isLoading = true; + final familyFileProvider = FamilyFilesProvider(); -class _MyFamily extends State { - bool isLoading = true; - var familyFileProvider = FamilyFilesProvider(); - @override - void initState() { - isLoading = true; - // checkUser(context); - super.initState(); - } + var userID; Widget build(BuildContext context) { return AppScaffold( @@ -48,42 +44,32 @@ class _MyFamily extends State { ], ), TabBarView( - children: [myFamilyDetails(), myFamilyRequest()], + children: [ + myFamilyDetails(context), + myFamilyRequest(context) + ], ) ], ))))); } - Widget myFamilyDetails() { - return Padding( - padding: EdgeInsets.only(top: 50), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 3, child: Text(TranslationBase.of(context).request)), - Expanded( - flex: 2, - child: Text( - TranslationBase.of(context).switchUser, - )), - Expanded( - flex: 1, - child: Text( - TranslationBase.of(context).deleteView, - )), - ], - ), - FutureBuilder( + Widget myFamilyDetails(context) { + return // Padding( + //padding: EdgeInsets.only(top: 50), + //child: + Column( + // mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + flex: 3, + child: FutureBuilder( future: getFamilyFiles(), // async work builder: (BuildContext context, AsyncSnapshot snapshot) { switch (snapshot.connectionState) { case ConnectionState.waiting: return Padding( - padding: EdgeInsets.all(10), + padding: EdgeInsets.only(top: 50), child: Text('Loading....')); default: if (snapshot.hasError) @@ -91,39 +77,132 @@ class _MyFamily extends State { padding: EdgeInsets.all(10), child: Text(snapshot.error)); else - return Column( - children: snapshot - .data.getAllSharedRecordsByStatusList - .map((result) { - return result.status == 3 - ? Padding( - padding: EdgeInsets.all(10), - child: Row( - children: [ - Expanded( - flex: 3, - child: Text(result.patientName)), - Expanded(flex: 2, child: Icon(Icons.group)), - Expanded( - flex: 1, child: Icon(Icons.delete)), - ], - )) - : SizedBox(); - }).toList()); + return Padding( + padding: EdgeInsets.only(top: 50), + child: Column(children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 3, + child: Text( + TranslationBase.of(context).request)), + Expanded( + flex: 2, + child: Text( + TranslationBase.of(context).switchUser, + )), + Expanded( + flex: 1, + child: Text( + TranslationBase.of(context).deleteView, + )), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: snapshot + .data.getAllSharedRecordsByStatusList + .map((result) { + return result.status == 3 + ? Padding( + padding: EdgeInsets.all(10), + child: Row( + children: [ + Expanded( + flex: 3, + child: + Text(result.patientName)), + Expanded( + flex: 2, + child: Icon(Icons.group)), + Expanded( + flex: 1, + child: IconButton( + icon: Icon( + Icons.delete, + color: Colors.black, + ), + onPressed: () { + deleteFamily( + result, context); + }, + )), + ], + )) + : SizedBox(); + }).toList()) + ])); } }, - ) - ], - )); + )), + Expanded( + flex: 1, + child: Column( + children: [ + Row( + children: [ + Expanded( + child: DefaultButton( + TranslationBase.of(context).addFamilyMember, + () => { + Navigator.of(context).pushNamed(ADD_FAMILY_MEMBER_TYPE) + }, + color: Colors.grey[900], + textColor: Colors.white, + )) + ], + ), + ], + )) + ], + ); } - Widget myFamilyRequest() { + addMember() {} + Widget myFamilyRequest(context) { return Column( children: [], ); } - Future getFamilyFiles() { - return familyFileProvider.getSharedRecordByStatus(); + Future getFamilyFiles() async { + if (await sharedPref.getObject(FAMILY_FILE) != null) { + // print(await sharedPref.getObject(FAMILY_FILE)); + return Future.value(GetAllSharedRecordsByStatusResponse.fromJson( + await sharedPref.getObject(FAMILY_FILE))); + } else { + return familyFileProvider.getSharedRecordByStatus(); + } + } + + deleteFamily(family, context) { + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: TranslationBase.of(context).removeFamilyMember, + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () => { + removeFamily(family, context), + ConfirmDialog.closeAlertDialog(context) + }, + cancelFunction: () => {}); + dialog.showAlertDialog(context); + } + + removeFamily(GetAllSharedRecordsByStatusList family, context) { + this.userID = family.iD; + Map request = {}; + request['ID'] = this.userID; + request['IsActive'] = false; + this + .familyFileProvider + .deativateActivateMemberFile(request) + .then((value) => refreshFamily(context)); + } + + refreshFamily(context) { + sharedPref.remove(FAMILY_FILE); + (context as Element).reassemble(); } } diff --git a/lib/routes.dart b/lib/routes.dart index d4e38a9a..4b1a0ef2 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -7,7 +7,8 @@ import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/pages/login/login.dart'; import 'package:diplomaticquarterapp/pages/login/register.dart'; -import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/pages/family/add-family_type.dart'; +import 'package:diplomaticquarterapp/pages/family/add-family-member.dart'; const String INIT_ROUTE = '/'; const String ROOT = 'root'; @@ -21,6 +22,8 @@ const String REGISTER = 'register'; const String CONFIRM_LOGIN = 'confrim-login'; const String REGISTER_INFO = 'register-info'; const String MY_FAMILIY = 'my-family'; +const String ADD_FAMILY_MEMBER_TYPE = 'add-family-member-type'; +const String ADD_FAMILY_MEMBER = 'add-family-member'; var routes = { // ROOT: (_) => RootPage(), HOME: (_) => LandingPage(), @@ -31,5 +34,8 @@ var routes = { REGISTER: (_) => Register(), CONFIRM_LOGIN: (_) => ConfirmLogin(), REGISTER_INFO: (_) => RegisterInfo(), - MY_FAMILIY: (_) => MyFamily() + MY_FAMILIY: (_) => MyFamily(), + ADD_FAMILY_MEMBER_TYPE: (_) => AddFamilyMemberType(), + + ADD_FAMILY_MEMBER: (_) => AddMember() }; diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 05205de2..fe5ed6fb 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -20,8 +20,8 @@ class DoctorsListService extends BaseService { AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); - Future getDoctorsList( - int clinicID, int projectID, BuildContext context) async { + Future getDoctorsList(int clinicID, int projectID, BuildContext context, + {doctorId}) async { Utils.showProgressDialog(context); Map request; @@ -48,8 +48,8 @@ class DoctorsListService extends BaseService { "ContinueDentalPlan": false, "IsSearchAppointmnetByClinicID": true, "PatientID": authUser.patientID != null ? authUser.patientID : 0, - "gender": authUser.gender != null ? authUser.gender : 0, - "age": authUser.age != null ? authUser.age : 0, + "gender": authUser.gender != null ? authUser.gender : 0, + "age": authUser.age != null ? authUser.age : 0, "IsGetNearAppointment": false, "Latitude": 0, "Longitude": 0, @@ -96,8 +96,8 @@ class DoctorsListService extends BaseService { "IsSearchAppointmnetByClinicID": false, "DoctorName": docName, "PatientID": authUser.patientID != null ? authUser.patientID : 0, - "gender": authUser.gender != null ? authUser.gender : 0, - "age": authUser.age != null ? authUser.age : 0, + "gender": authUser.gender != null ? authUser.gender : 0, + "age": authUser.age != null ? authUser.age : 0, "IsGetNearAppointment": false, "Latitude": 0, "Longitude": 0, diff --git a/lib/services/family_files/family_files_provider.dart b/lib/services/family_files/family_files_provider.dart index ee20a63c..2154e68a 100644 --- a/lib/services/family_files/family_files_provider.dart +++ b/lib/services/family_files/family_files_provider.dart @@ -1,9 +1,13 @@ -import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/family-file/add_family_file_request.dart'; +import 'package:diplomaticquarterapp/core/model/family-file/insert_share_file_request.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; +import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; +import 'package:diplomaticquarterapp/models/Authentication/send_activation_request.dart'; import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordsByStatusReq.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:flutter/cupertino.dart'; // SharedPreferences sharedPref = new SharedPreferences(); @@ -12,6 +16,19 @@ AppSharedPreferences sharedPref = new AppSharedPreferences(); const String GET_SHARED_RECORD_BY_STATUS = 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus'; +const String ADD_FAMILY_FILES = + 'Services/Patients.svc/REST/ShareFamilyFileService'; +const String SEND_FAMILY_FILE_ACTIVATION = + 'Services/Authentication.svc/REST/SendActivationCodeForFamilyFile'; +const String INSERT_PATIENT_FILE = + 'Services/Authentication.svc/REST/Insert_SharePatientFile'; +const String CHECK_ACTIVATION_CODE = + 'Services/Authentication.svc/REST/CheckActivationCodeForFamilyFile'; + +const String UPDATE_FILE_STATUS = + 'Services/Authentication.svc/REST/Update_FileStatus'; +const String REMOVE_FILE_STATUS = + 'Services/Authentication.svc/REST/ActiveDeactive_PatientFile'; class FamilyFilesProvider with ChangeNotifier { bool isLogin = false; @@ -27,8 +44,10 @@ class FamilyFilesProvider with ChangeNotifier { onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); throw error; }, body: request.toJson()); + sharedPref.setObject(FAMILY_FILE, localRes); return Future.value( GetAllSharedRecordsByStatusResponse.fromJson(localRes)); } catch (error) { @@ -36,4 +55,166 @@ class FamilyFilesProvider with ChangeNotifier { throw error; } } + + Future addFamilyFile(AddFamilyFileReq request) async { + try { + dynamic localRes; + // var request = GetAllSharedRecordsByStatusReq(); + //request.status = 0; + await new BaseAppClient().post(ADD_FAMILY_FILES, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request.toJson()); + //sharedPref.setObject(FAMILY_FILE, localRes); + return Future.value(localRes); + } catch (error) { + print(error); + + return Future.value(error); + } + } + + Future insertNewMember(InsertSharePatientFileReq request) async { + try { + dynamic localRes; + // var request = GetAllSharedRecordsByStatusReq(); + //request.status = 0; + await new BaseAppClient().post(INSERT_PATIENT_FILE, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request.toJson()); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + + Future sendActivationCode( + cellNumber, zipCode, patientIdentificationID) async { + try { + dynamic localRes; + var request = SendActivationRequest(); + request.zipCode = zipCode; + request.patientMobileNumber = int.parse(cellNumber); + request.patientIdentificationID = patientIdentificationID; + request.projectOutSA = zipCode == '966' ? 0 : 1; + request.loginType = request.searchType = 1; + request.oTPSendType = 1; + request.isRegister = false; + await new BaseAppClient().post(SEND_FAMILY_FILE_ACTIVATION, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request.toJson()); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + + Future checkActivationCode( + loginTokenID, activationCode, indentification, mobileNo) async { + try { + dynamic localRes; + Map request = {}; + // request['ZipCode'] = user.ZipCode; + request['PatientMobileNumber'] = mobileNo; + request['PatientIdentificationID'] = indentification; + request['LogInTokenID'] = loginTokenID; + request['activationCode'] = activationCode; + // this.authService.authenticateRequest(request); + await new BaseAppClient().post(CHECK_ACTIVATION_CODE, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + + Future acceptAndRejectRecievedRequests(id, stauts) async { + try { + dynamic localRes; + Map request = {}; + request['ID'] = id; + request['Status'] = stauts; + await new BaseAppClient().post(UPDATE_FILE_STATUS, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + + Future deativateActivateMemberFile(request) async { + try { + dynamic localRes; + + await new BaseAppClient().post(REMOVE_FILE_STATUS, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + + silentLoggin(switchUser, {onSuccess}) async { + //var currentUser = this.authService.getAuthenticatedUser(); + //const request = new SwitchUserRequest(); + Map request = {}; + request['LogInTokenID'] = ''; + // request['PatientOutSA'] = currentUser.PatientOutSA ? 1 : 0; + request['PatientMobileNumber'] = switchUser.MobileNumber; + request['SearchType'] = 2; + // request['SuperUser'] = currentUser.PatientID; + request['PatientIdentificationID'] = ''; + request['IsSilentLogin'] = true; + try { + dynamic localRes; + + await new BaseAppClient().post(REMOVE_FILE_STATUS, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + AppToast.showErrorToast(message: error); + throw error; + }, body: request); + + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 93fcf496..867b99f4 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -110,7 +110,6 @@ class TranslationBase { String get time => localizedValues['time'][locale.languageCode]; - String get login => localizedValues['login'][locale.languageCode]; String get loginregister => @@ -130,6 +129,8 @@ class TranslationBase { String get logintypeRadio => localizedValues['logintyperadio'][locale.languageCode]; + String get registerInfoFamily => + localizedValues['register-info-family'][locale.languageCode]; String get registerNow => localizedValues['registernow'][locale.languageCode]; @@ -222,29 +223,21 @@ class TranslationBase { String get upcomingDetails => localizedValues['upcoming-details'][locale.languageCode]; - String get reschedule => - localizedValues['reschedule'][locale.languageCode]; + String get reschedule => localizedValues['reschedule'][locale.languageCode]; - String get raise => - localizedValues['raise'][locale.languageCode]; + String get raise => localizedValues['raise'][locale.languageCode]; - String get complaint => - localizedValues['complaint'][locale.languageCode]; + String get complaint => localizedValues['complaint'][locale.languageCode]; - String get add => - localizedValues['add'][locale.languageCode]; + String get add => localizedValues['add'][locale.languageCode]; - String get reminder => - localizedValues['reminder'][locale.languageCode]; + String get reminder => localizedValues['reminder'][locale.languageCode]; - String get location => - localizedValues['location'][locale.languageCode]; + String get location => localizedValues['location'][locale.languageCode]; - String get online => - localizedValues['online'][locale.languageCode]; + String get online => localizedValues['online'][locale.languageCode]; - String get payment => - localizedValues['payment'][locale.languageCode]; + String get payment => localizedValues['payment'][locale.languageCode]; String get cancel_nocaps => localizedValues['cancel-nocaps'][locale.languageCode]; @@ -280,15 +273,21 @@ class TranslationBase { String get appsetting => localizedValues['app-settings'][locale.languageCode]; String get rateApp => localizedValues['rate-app'][locale.languageCode]; - String get setReminder => localizedValues['set-reminder'][locale.languageCode]; + String get setReminder => + localizedValues['set-reminder'][locale.languageCode]; String get before => localizedValues['before'][locale.languageCode]; String get minute => localizedValues['minute'][locale.languageCode]; String get hour => localizedValues['hour'][locale.languageCode]; - String get reminderSuccess => localizedValues['reminderSuccess'][locale.languageCode]; - String get patientShareToDo => localizedValues['patientShareToDo'][locale.languageCode]; - String get patientTaxToDo => localizedValues['patientTaxToDo'][locale.languageCode]; - String get patientShareTotalToDo => localizedValues['patientShareTotalToDo'][locale.languageCode]; - String get paymentMethod => localizedValues['paymentMethod'][locale.languageCode]; + String get reminderSuccess => + localizedValues['reminderSuccess'][locale.languageCode]; + String get patientShareToDo => + localizedValues['patientShareToDo'][locale.languageCode]; + String get patientTaxToDo => + localizedValues['patientTaxToDo'][locale.languageCode]; + String get patientShareTotalToDo => + localizedValues['patientShareTotalToDo'][locale.languageCode]; + String get paymentMethod => + localizedValues['paymentMethod'][locale.languageCode]; String get moreVerification => localizedValues['more-verify'][locale.languageCode]; @@ -304,22 +303,32 @@ class TranslationBase { String get next => localizedValues['next'][locale.languageCode]; - String get noNeedToWaitInLine => localizedValues['noNeedToWaitInLine'][locale.languageCode]; - String get useQRAppoAttend => localizedValues['useQRAppoAttend'][locale.languageCode]; - String get passQRAppoAttend => localizedValues['passQRAppoAttend'][locale.languageCode]; - String get sitWaitingQR => localizedValues['sitWaitingQR'][locale.languageCode]; - String get attendRegisterCode => localizedValues['attendRegisterCode'][locale.languageCode]; - String get scanQRHospital => localizedValues['scanQRHospital'][locale.languageCode]; + String get noNeedToWaitInLine => + localizedValues['noNeedToWaitInLine'][locale.languageCode]; + String get useQRAppoAttend => + localizedValues['useQRAppoAttend'][locale.languageCode]; + String get passQRAppoAttend => + localizedValues['passQRAppoAttend'][locale.languageCode]; + String get sitWaitingQR => + localizedValues['sitWaitingQR'][locale.languageCode]; + String get attendRegisterCode => + localizedValues['attendRegisterCode'][locale.languageCode]; + String get scanQRHospital => + localizedValues['scanQRHospital'][locale.languageCode]; String get sendEmail => localizedValues['sendEmail'][locale.languageCode]; String get close => localizedValues['close'][locale.languageCode]; String get booked => localizedValues['booked'][locale.languageCode]; String get confirmed => localizedValues['confirmed'][locale.languageCode]; String get arrived => localizedValues['arrived'][locale.languageCode]; - String get payNowBookSuccess => localizedValues['payNowBookSuccess'][locale.languageCode]; - String get payNowBookSuccesstext1 => localizedValues['payNowBookSuccesstext1'][locale.languageCode]; - String get payNowBookSuccesstext2 => localizedValues['payNowBookSuccesstext2'][locale.languageCode]; + String get payNowBookSuccess => + localizedValues['payNowBookSuccess'][locale.languageCode]; + String get payNowBookSuccesstext1 => + localizedValues['payNowBookSuccesstext1'][locale.languageCode]; + String get payNowBookSuccesstext2 => + localizedValues['payNowBookSuccesstext2'][locale.languageCode]; String get payLater => localizedValues['payLater'][locale.languageCode]; - String get askDocNotAllowed => localizedValues['askDocNotAllowed'][locale.languageCode]; + String get askDocNotAllowed => + localizedValues['askDocNotAllowed'][locale.languageCode]; String get firstName => localizedValues['first-name'][locale.languageCode]; String get middleName => localizedValues['middle-name'][locale.languageCode]; @@ -352,12 +361,12 @@ class TranslationBase { localizedValues['family-title'][locale.languageCode]; String get oxygenation => localizedValues['oxygenation'][locale.languageCode]; - String get respirationRate => localizedValues['respirationRate'][locale.languageCode]; + String get respirationRate => + localizedValues['respirationRate'][locale.languageCode]; String get bodyMeasurements => - localizedValues ['bodyMeasurements'][locale.languageCode]; - String get height => - localizedValues ['height'][locale.languageCode]; + localizedValues['bodyMeasurements'][locale.languageCode]; + String get height => localizedValues['height'][locale.languageCode]; String get temperature => localizedValues['temperature'][locale.languageCode]; @@ -402,8 +411,11 @@ class TranslationBase { String get seeDetails => localizedValues['seeDetails'][locale.languageCode]; String get insuranceCards => localizedValues['insuranceCards'][locale.languageCode]; - String get requestType => - localizedValues['requestType'][locale.languageCode]; + String get requestType => localizedValues['requestType'][locale.languageCode]; + String get addFamilyMember => + localizedValues['add-new-member'][locale.languageCode]; + String get removeFamilyMember => + localizedValues['remove-family-member'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 3ebd8038..d8fb27b3 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -346,7 +346,13 @@ class _AppDrawerState extends State { } } - Future getFamilyFiles() { - return familyFileProvider.getSharedRecordByStatus(); + Future getFamilyFiles() async { + if (await sharedPref.getObject(FAMILY_FILE) != null) { + // print(await sharedPref.getObject(FAMILY_FILE)); + return Future.value(GetAllSharedRecordsByStatusResponse.fromJson( + await sharedPref.getObject(FAMILY_FILE))); + } else { + return familyFileProvider.getSharedRecordByStatus(); + } } } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 89fb88d4..c4a1e8b9 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -1,8 +1,10 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/routes.dart'; +import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart'; import 'package:diplomaticquarterapp/widgets/robo-search/robosearch.dart'; +import 'package:diplomaticquarterapp/widgets/robo-search/search.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'floating_button_search.dart'; @@ -33,42 +35,43 @@ class AppScaffold extends StatelessWidget { AppGlobal.context = context; return Scaffold( - backgroundColor: Theme.of(context).scaffoldBackgroundColor, - appBar: isShowAppBar - ? AppBar( - elevation: 0, - backgroundColor: Theme.of(context).appBarTheme.color, - textTheme: TextTheme( - headline6: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), - title: Text(appBarTitle.toUpperCase()), - leading: Builder( - builder: (BuildContext context) { - return ArrowBack(); - }, - ), - centerTitle: true, - actions: [ - IconButton( - icon: Icon(FontAwesomeIcons.home), - color: Colors.white, - onPressed: () { - Navigator.of(context).pushNamed(HOME); + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + appBar: isShowAppBar + ? AppBar( + elevation: 0, + backgroundColor: Theme.of(context).appBarTheme.color, + textTheme: TextTheme( + headline6: TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ), + title: Text(appBarTitle.toUpperCase()), + leading: Builder( + builder: (BuildContext context) { + return ArrowBack(); }, ), - ], - ) - : null, - body: baseViewModel != null - ? NetworkBaseView( - child: buildBodyWidget(), - baseViewModel: baseViewModel, - ) - : buildBodyWidget(), - bottomSheet: bottomSheet, - floatingActionButton: FloatingSearchButton(), - ); + centerTitle: true, + actions: [ + IconButton( + icon: Icon(FontAwesomeIcons.home), + color: Colors.white, + onPressed: () { + Navigator.of(context).popUntil(ModalRoute.withName('/')); + }, + ), + ], + ) + : null, + body: baseViewModel != null + ? NetworkBaseView( + child: buildBodyWidget(), + baseViewModel: baseViewModel, + ) + : buildBodyWidget(), + bottomSheet: bottomSheet, + bottomNavigationBar: BottomBarSearch() + //floatingActionButton: FloatingSearchButton(), + ); } buildAppLoaderWidget(bool isLoading) { diff --git a/lib/widgets/others/bottom_bar.dart b/lib/widgets/others/bottom_bar.dart new file mode 100644 index 00000000..9c1b402b --- /dev/null +++ b/lib/widgets/others/bottom_bar.dart @@ -0,0 +1,334 @@ +import 'dart:convert'; + +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/models/Appointments/DoctorProfile.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/BookingOptions.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/DoctorProfile.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/medical/medical_profile_page.dart'; +import 'package:diplomaticquarterapp/pages/medical/my_admissions_page.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.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:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart'; +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:flutter_tts/flutter_tts.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:speech_to_text/speech_recognition_error.dart'; +import 'package:speech_to_text/speech_recognition_result.dart'; +import 'package:speech_to_text/speech_to_text.dart'; +import 'package:diplomaticquarterapp/widgets/robo-search/robosearch.dart'; +import 'dart:math'; +import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; + +class BottomBarSearch extends StatefulWidget { + @override + _SearchBot createState() => _SearchBot(); +} + +class _SearchBot extends State { + SearchProvider searchProvider = new SearchProvider(); + RobotProvider eventProvider = RobotProvider(); + bool isLoading = false; + bool isError = false; + final SpeechToText speech = SpeechToText(); + String error = ''; + String _currentLocaleId = ""; + String lastError; + double level = 0.0; + + double minSoundLevel = 50000; + double maxSoundLevel = -50000; + String reconizedWord = ''; + FlutterTts flutterTts = FlutterTts(); + var selectedLang; + bool isSearching = false; + + String lastStatus; + + bool _isInit = true; + TextEditingController searchController = TextEditingController(); + @override + void initState() { + requestPermissions(); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return BottomAppBar( + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Expanded( + child: SizedBox( + height: 64, + child: Material( + type: MaterialType.transparency, + child: TextField( + keyboardType: TextInputType.multiline, + maxLines: null, + controller: searchController, + decoration: InputDecoration( + hintText: 'How May I Help You?', + suffixIcon: IconButton( + icon: Icon(Icons.mic), + onPressed: () async { + setState(() { + searchController.text = ''; + }); + // await flutterTts.speak("Hello!"); + //Future.delayed(const Duration(seconds: 1), () { + initSpeechState() + .then((value) => startVoiceSearch()); + //}); + }, + )), + ), + ), + ), + ), + ]), + ); + } + + startVoiceSearch() async { + speech.listen( + onResult: resultListener, + listenFor: Duration(seconds: 10), + localeId: _currentLocaleId, + onSoundLevelChange: soundLevelListener, + cancelOnError: true, + partialResults: true, + onDevice: true, + listenMode: ListenMode.confirmation); + } + + void resultListener(SpeechRecognitionResult result) { + // lastWords = "${result.recognizedWords} - ${result.finalResult}"; + + if (result.finalResult == true) { + // setState(() { + reconizedWord = result.recognizedWords; + //}); + setState(() { + searchController.text = reconizedWord; + }); + Future.delayed(const Duration(seconds: 1), () { + _speak(reconizedWord); + }); + } + //}); + } + + Future _speak(reconizedWord) async { + await flutterTts.speak(reconizedWord); + + getPages(reconizedWord); + } + + void soundLevelListener(double level) { + minSoundLevel = min(minSoundLevel, level); + maxSoundLevel = max(maxSoundLevel, level); + // print("sound level $level: $minSoundLevel - $maxSoundLevel "); + //setState(() { + this.level = level; + // }); + } + + void requestPermissions() async { + Map statuses = await [ + Permission.microphone, + ].request(); + } + + Future initSpeechState() async { + await speech.initialize(onError: errorListener, onStatus: statusListener); + + _currentLocaleId = + TranslationBase.of(AppGlobal.context).locale.languageCode == 'en' + ? 'en-GB' + : 'ar-SA'; // systemLocale.localeId; + flutterTts.setLanguage(_currentLocaleId); + + // if (!mounted) return; + } + + void errorListener(SpeechRecognitionError error) { + //setState(() { + // reconizedWord = "${error.errorMsg} - ${error.permanent}"; + //}); + } + + void statusListener(String status) { + //setState(() { + reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + + //}); + } + + getPages(text) { + var request = { + 'VoiceMessage': text, + 'Lang': TranslationBase.of(AppGlobal.context).locale.languageCode == 'en' + ? 'En' + : 'Ar' + }; + + searchProvider + .getBotPages(request) + .then((value) => {getCommands(value['Understand'])}); + //getDoctorsList(12, 17, 40036, context); + } + + getCommands(result) async { + //RoboSearch.closeAlertDialog(context); + print(result); + + //getDoctorsList(12, 17, 40036, context); + + switch (result["CommandNumber"]) { + case 100: + if (result['ProjectId'] != null && + result['ClinicId'] != null && + result['DoctorId'] != null) { + getDoctorsList( + result['ProjectId'], + result['ClinicId'], + context, + doctorId: result['DoctorId'], + ); + } else if (result['ProjectId'] != null && result['ClinicId'] != null) { + getDoctorsList( + result['ProjectId'], + result['ClinicId'], + context, + ); + } + break; + // case '101': + // Navigator.push( + // AppGlobal.context, + // MaterialPageRoute( + // builder: (context) => Search( + // type: 0, + // ))); + // break; + // case '102': + // Navigator.push( + // AppGlobal.context, + // MaterialPageRoute( + // builder: (context) => Search( + // type: 1, + // ))); + // break; + // case '103': + // eventProvider.setValue({"clinic_id": understand}); + // break; + + // case '104': + // eventProvider.setValue({"project_id": understand}); + // break; + // case '105': + // eventProvider.setValue({"doctor_id": understand}); + // break; + default: + { + if (result['ProjectId'] != null && result['ClinicId'] != null) { + getDoctorsList( + result['ProjectId'], + result['ClinicId'], + context, + ); + } + } + break; + } + if (_currentLocaleId == 'en-GB' && result['ReturnMessage'] != null) { + await flutterTts.speak(result['ReturnMessage']); + } else if (result['ReturnMessage_Ar'] != null) { + await flutterTts.speak(result['ReturnMessage_Ar']); + } + //searchProvider.setLisener(result); + } + + getDoctorProfile(projectId, clinicId, doctorId, context, doctorData) { + List docProfileList = []; + DoctorsListService service = new DoctorsListService(); + + service + .getDoctorsProfile(doctorId, clinicId, projectId, context) + .then((res) { + if (res['MessageStatus'] == 1) { + if (res['DoctorProfileList'].length != 0) { + res['DoctorProfileList'].forEach((v) { + docProfileList.add(new DoctorProfileList.fromJson(v)); + }); + } + + navigateToDoctorProfile(context, doctorData[0], docProfileList[0], + isAppo: true); + } + }); + } + + getDoctorsList(projectId, clinicId, context, {doctorId}) { + List doctorsList = []; + DoctorsListService service = new DoctorsListService(); + service + .getDoctorsList(clinicId, projectId, context, doctorId: doctorId) + .then((res) { + if (res['MessageStatus'] == 1) { + setState(() { + if (res['DoctorList'].length != 0) { + doctorsList.clear(); + res['DoctorList'].forEach((v) { + doctorsList.add(new DoctorList.fromJson(v)); + }); + if (doctorId == null) { + navigateToSearchResults(context, doctorsList); + } else { + getDoctorProfile( + projectId, clinicId, doctorId, context, doctorsList); + } + } + }); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }).catchError((err) { + print(err); + }); + } + + Future navigateToDoctorProfile(context, docObject, docProfile, + {isAppo}) async { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DoctorProfile( + doctor: docObject, + docProfileList: docProfile, + isOpenAppt: isAppo, + ))); + } + + Future navigateToSearchResults(context, docList) async { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SearchResults(doctorsList: docList))); + } +} diff --git a/lib/widgets/others/floating_button_search.dart b/lib/widgets/others/floating_button_search.dart index 92b0b45f..34b1240e 100644 --- a/lib/widgets/others/floating_button_search.dart +++ b/lib/widgets/others/floating_button_search.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/widgets/robo-search/robosearch.dart'; +import 'package:diplomaticquarterapp/widgets/robo-search/search.dart'; import 'package:flutter/material.dart'; class FloatingSearchButton extends StatelessWidget { @@ -9,7 +10,7 @@ class FloatingSearchButton extends StatelessWidget { child: FloatingActionButton( child: Icon(Icons.mic), onPressed: () { - roboSearch(context); + SearchBot(); }, )); } diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 709a8f0e..376c2a4f 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -307,4 +307,8 @@ class SMSOTP { ); }); } + + static void hideSMSBox(context) { + Navigator.pop(context); + } } diff --git a/lib/widgets/robo-search/robosearch.dart b/lib/widgets/robo-search/robosearch.dart index c94f534b..ca28193b 100644 --- a/lib/widgets/robo-search/robosearch.dart +++ b/lib/widgets/robo-search/robosearch.dart @@ -23,7 +23,7 @@ class RoboSearch { color: Colors.white, height: SizeConfig.realScreenHeight * 0.5, width: SizeConfig.realScreenWidth * 0.8, - child: SearchBot()); + child: Container()); }), ); diff --git a/lib/widgets/robo-search/search.dart b/lib/widgets/robo-search/search.dart index 25f29ba0..b6426b6d 100644 --- a/lib/widgets/robo-search/search.dart +++ b/lib/widgets/robo-search/search.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/BookingOptions.dart'; @@ -22,13 +23,12 @@ import 'package:diplomaticquarterapp/widgets/robo-search/robosearch.dart'; import 'dart:math'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; -class SearchBot extends StatefulWidget { - @override - _SearchBot createState() => _SearchBot(); -} +class SearchBot with ChangeNotifier { + SearchBot() { + requestPermissions(); + initSpeechState(); + } -class _SearchBot extends State { - // DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); SearchProvider searchProvider = new SearchProvider(); RobotProvider eventProvider = RobotProvider(); bool isLoading = false; @@ -50,42 +50,44 @@ class _SearchBot extends State { bool _isInit = true; - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - requestPermissions(); - initSpeechState(); - } - _isInit = false; - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - Image.asset('assets/images/siri-ianzhao.gif'), - AppText( - reconizedWord, - fontSize: 28, - ), - SizedBox( - child: FlatButton( - child: Text('Start'), - onPressed: () { - setState(() { - reconizedWord = 'Lisening...'; - }); - startVoiceSearch(); - }, - ), - height: 40, - width: 80) - ], - ); - } - - startVoiceSearch() { + // @override + // void didChangeDependencies() { + // super.didChangeDependencies(); + // if (_isInit) { + + // } else { + // startVoiceSearch(); + // } + + // _isInit = false; + // } + + //@override + // Widget build(BuildContext context) { + // return Column( + // children: [ + // Image.asset('assets/images/siri-ianzhao.gif'), + // AppText( + // reconizedWord, + // fontSize: 28, + // ), + // // SizedBox( + // // child: FlatButton( + // // child: Text('Start'), + // // onPressed: () { + // // setState(() { + // // reconizedWord = 'Lisening...'; + // // }); + + // // }, + // // ), + // // height: 40, + // // width: 80) + // ], + // ); + // } + + startVoiceSearch() async { speech.listen( onResult: resultListener, listenFor: Duration(seconds: 10), @@ -101,9 +103,9 @@ class _SearchBot extends State { // lastWords = "${result.recognizedWords} - ${result.finalResult}"; if (result.finalResult == true) { - setState(() { - reconizedWord = result.recognizedWords; - }); + // setState(() { + reconizedWord = result.recognizedWords; + //}); Future.delayed(const Duration(seconds: 1), () { _speak(reconizedWord); }); @@ -121,9 +123,9 @@ class _SearchBot extends State { minSoundLevel = min(minSoundLevel, level); maxSoundLevel = max(maxSoundLevel, level); // print("sound level $level: $minSoundLevel - $maxSoundLevel "); - setState(() { - this.level = level; - }); + //setState(() { + this.level = level; + // }); } void requestPermissions() async { @@ -135,44 +137,51 @@ class _SearchBot extends State { Future initSpeechState() async { await speech.initialize(onError: errorListener, onStatus: statusListener); - _currentLocaleId = TranslationBase.of(context).locale.languageCode == 'en' - ? 'en-GB' - : 'ar-SA'; // systemLocale.localeId; + _currentLocaleId = + TranslationBase.of(AppGlobal.context).locale.languageCode == 'en' + ? 'en-GB' + : 'ar-SA'; // systemLocale.localeId; flutterTts.setLanguage(_currentLocaleId); - if (!mounted) return; + + await flutterTts.speak("Hello! How May I help you?"); + flutterTts.setCompletionHandler(() { + startVoiceSearch(); + }); + + // if (!mounted) return; } void errorListener(SpeechRecognitionError error) { - setState(() { - // reconizedWord = "${error.errorMsg} - ${error.permanent}"; - }); + //setState(() { + // reconizedWord = "${error.errorMsg} - ${error.permanent}"; + //}); } void statusListener(String status) { - setState(() { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; - }); + //setState(() { + reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + //}); } getPages(text) { var request = { 'VoiceMessage': text, - 'Lang': - TranslationBase.of(context).locale.languageCode == 'en' ? 'En' : 'Ar' + 'Lang': TranslationBase.of(AppGlobal.context).locale.languageCode == 'en' + ? 'En' + : 'Ar' }; - searchProvider - .getBotPages(request) - .then((value) => {getCommands(value['Response'], value['Understand'])}); + searchProvider.getBotPages(request).then((value) => {}); + //getCommands(value['Response'], value['Understand']) } getCommands(result, understand) async { - RoboSearch.closeAlertDialog(context); - + //RoboSearch.closeAlertDialog(context); + print(result); switch (result["CommandNumber"]) { case '100': Navigator.push( - context, + AppGlobal.context, FadePage( page: BookingOptions( isAppbar: true, @@ -180,7 +189,7 @@ class _SearchBot extends State { break; case '101': Navigator.push( - context, + AppGlobal.context, MaterialPageRoute( builder: (context) => Search( type: 0, @@ -188,18 +197,26 @@ class _SearchBot extends State { break; case '102': Navigator.push( - context, + AppGlobal.context, MaterialPageRoute( builder: (context) => Search( type: 1, ))); break; case '103': - eventProvider.setValue(understand); + eventProvider.setValue({"clinic_id": understand}); + break; + + case '104': + eventProvider.setValue({"project_id": understand}); + break; + case '105': + eventProvider.setValue({"doctor_id": understand}); break; default: { - eventProvider.setValue({"Id": "17"}); + eventProvider.setValue({"doctor_id": '40036'}); + //eventProvider.setValue(); // if (result['CommandNumber'] == '0') { // searchProvider.setData(understand); // }