From ebf293736da075c4196ff508ef838cb4a88e51f8 Mon Sep 17 00:00:00 2001 From: "Mirza.Shafique" Date: Tue, 31 Aug 2021 15:32:35 +0300 Subject: [PATCH 1/3] Booking appointment Marge --- lib/pages/BookAppointment/DoctorProfile.dart | 8 +- .../BookAppointment/widgets/DoctorView.dart | 2 +- lib/pages/MyAppointments/SchedulePage.dart | 88 ++++++------------- 3 files changed, 36 insertions(+), 62 deletions(-) diff --git a/lib/pages/BookAppointment/DoctorProfile.dart b/lib/pages/BookAppointment/DoctorProfile.dart index 5fca126c..88cf53e6 100644 --- a/lib/pages/BookAppointment/DoctorProfile.dart +++ b/lib/pages/BookAppointment/DoctorProfile.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorRateDetails.dart' import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/header_model.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/doctor_post_pre_images_page.dart'; +import 'package:diplomaticquarterapp/pages/MyAppointments/SchedulePage.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; @@ -115,7 +116,12 @@ class _DoctorProfileState extends State with TickerProviderStateM widget.doctor.noOfPatientsRate, "", ), - onTap: () {}, + showConfirmMessageDialog: false, + onTap: () { + if (widget.isOpenAppt) { + Navigator.push(context, FadePage(page: SchedulePage(widget.doctor))); + } + }, onRatingAndReviewTap: () { getDoctorRatingsDetails(); }, diff --git a/lib/pages/BookAppointment/widgets/DoctorView.dart b/lib/pages/BookAppointment/widgets/DoctorView.dart index 7f95b236..769231cd 100644 --- a/lib/pages/BookAppointment/widgets/DoctorView.dart +++ b/lib/pages/BookAppointment/widgets/DoctorView.dart @@ -24,7 +24,7 @@ class DoctorView extends StatelessWidget { Widget build(BuildContext context) { return InkWell( onTap: () { - if (isShowFlag) getDoctorsProfile(context, doctor); + if (isShowFlag) getDoctorsProfile(context, doctor,isAppo: true); }, child: Container( decoration: BoxDecoration( diff --git a/lib/pages/MyAppointments/SchedulePage.dart b/lib/pages/MyAppointments/SchedulePage.dart index e83e8408..f3ef3d2a 100644 --- a/lib/pages/MyAppointments/SchedulePage.dart +++ b/lib/pages/MyAppointments/SchedulePage.dart @@ -16,6 +16,7 @@ class SchedulePage extends StatefulWidget { final DoctorList doctorList; SchedulePage(this.doctorList); + @override _SchedulePageState createState() => _SchedulePageState(); } @@ -27,11 +28,7 @@ class _SchedulePageState extends State { int selectedindex = 0; bool isLoading = true; List doctorScheduleResponse = []; - final List introWidgetsList = [ - Text('Hello'), - Text('Hi'), - Text('hey') - ]; + final List introWidgetsList = [Text('Hello'), Text('Hi'), Text('hey')]; @override void initState() { @@ -70,29 +67,13 @@ class _SchedulePageState extends State { child: ListView.builder( itemCount: model.getDoctorScheduleList.length, itemBuilder: (context, index) => ClipRRect( - borderRadius: const BorderRadius.all( - Radius.circular(20.0)), + borderRadius: const BorderRadius.all(Radius.circular(20.0)), child: Container( - padding: EdgeInsets.only( - left: 10, - right: 10, - top: 20, - bottom: 20), - margin: EdgeInsets.only( - left: 20, - right: 20, - top: 7, - bottom: 7), - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.green, - offset: Offset(-10, 0)), - ], - borderRadius: - const BorderRadius.all( - Radius.circular(10.0)), - color: Colors.white), + padding: EdgeInsets.only(left: 10, right: 10, top: 20, bottom: 20), + margin: EdgeInsets.only(left: 20, right: 20, top: 7, bottom: 7), + decoration: BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.green, offset: Offset(-10, 0)), + ], borderRadius: const BorderRadius.all(Radius.circular(10.0)), color: Colors.white), child: Row( children: [ Expanded( @@ -100,26 +81,16 @@ class _SchedulePageState extends State { Column( children: [ Texts( - model - .getDoctorScheduleList[ - index] - .dayName, - color: - HexColor('#0bb690'), + model.getDoctorScheduleList[index].dayName, + color: HexColor('#0bb690'), ), Texts( - DateUtil - .getDayMonthYearDateFormatted( - DateUtil - .convertStringToDate( - model - .getDoctorScheduleList[ - index] - .date, + DateUtil.getDayMonthYearDateFormatted( + DateUtil.convertStringToDate( + model.getDoctorScheduleList[index].date, ), ), - color: - HexColor('#0bb690'), + color: HexColor('#0bb690'), ) ], ) @@ -127,10 +98,7 @@ class _SchedulePageState extends State { ), Expanded( child: Texts( - model - .getDoctorScheduleList[ - index] - .workingHours, + model.getDoctorScheduleList[index].workingHours, color: HexColor('#0bb690'), ), ) @@ -147,17 +115,17 @@ class _SchedulePageState extends State { )))); } - //getSchedule(DoctorList doctor, BuildContext context) { - //GifLoaderDialogUtils.showMyDialog(context); - //service = new DoctorsListService(); - // service.getSchedule(doctor).then((value) { - // doctorScheduleResponse.clear(); - // setState(() { - // value['List_DoctorWorkingHoursTable'].forEach((item) => { - // doctorScheduleResponse.add(DoctorScheduleResponse.fromJson(item)) - // }); - // GifLoaderDialogUtils.hideDialog(context); - // }); - // }); - // } +//getSchedule(DoctorList doctor, BuildContext context) { +//GifLoaderDialogUtils.showMyDialog(context); +//service = new DoctorsListService(); +// service.getSchedule(doctor).then((value) { +// doctorScheduleResponse.clear(); +// setState(() { +// value['List_DoctorWorkingHoursTable'].forEach((item) => { +// doctorScheduleResponse.add(DoctorScheduleResponse.fromJson(item)) +// }); +// GifLoaderDialogUtils.hideDialog(context); +// }); +// }); +// } } From e1e3741abf7d9514185f45df11f30b0b3bbc1bcf Mon Sep 17 00:00:00 2001 From: "Mirza.Shafique" Date: Wed, 1 Sep 2021 16:28:56 +0300 Subject: [PATCH 2/3] Event Reminder --- lib/config/config.dart | 4 +- lib/pages/BookAppointment/DoctorProfile.dart | 14 +++- .../BookAppointment/book_reminder_page.dart | 69 ++++------------ .../widgets/reminder_dialog.dart | 81 +++++++++++++++++++ .../widgets/AppointmentActions.dart | 75 ++++++++++------- lib/uitl/CalendarUtils.dart | 11 ++- 6 files changed, 163 insertions(+), 91 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 7152cbbe..45c31e14 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -13,8 +13,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; diff --git a/lib/pages/BookAppointment/DoctorProfile.dart b/lib/pages/BookAppointment/DoctorProfile.dart index 88cf53e6..ac423343 100644 --- a/lib/pages/BookAppointment/DoctorProfile.dart +++ b/lib/pages/BookAppointment/DoctorProfile.dart @@ -488,9 +488,15 @@ class _DoctorProfileState extends State with TickerProviderStateM Future navigateToBookConfirm(context) async { Navigator.push( - context, - FadePage( - page: BookConfirm( - doctor: widget.doctor, isLiveCareAppointment: widget.isLiveCareAppointment, selectedDate: DocAvailableAppointments.selectedDate, selectedTime: DocAvailableAppointments.selectedTime))); + context, + FadePage( + page: BookConfirm( + doctor: widget.doctor, + isLiveCareAppointment: widget.isLiveCareAppointment, + selectedDate: DocAvailableAppointments.selectedDate, + selectedTime: DocAvailableAppointments.selectedTime, + ), + ), + ); } } diff --git a/lib/pages/BookAppointment/book_reminder_page.dart b/lib/pages/BookAppointment/book_reminder_page.dart index fc5c96e8..2e649ab8 100644 --- a/lib/pages/BookAppointment/book_reminder_page.dart +++ b/lib/pages/BookAppointment/book_reminder_page.dart @@ -52,13 +52,13 @@ class _BookReminderPageState extends State { isSuccessShow = false; }); }); + } @override Widget build(BuildContext context) { // print("selectedTime "+selectedTime??""); - print("appoDateFormatted " + widget.appoDateFormatted ?? ""); - print("appoTimeFormatted " + widget.appoTimeFormatted ?? ""); + print("appointmentNo1 " + widget.patientShareResponse.appointmentNo.toString() ?? ""); return AppScaffold( appBarTitle: widget.docObject.doctorTitle + " " + widget.docObject.name, isShowDecPage: false, @@ -194,15 +194,19 @@ class _BookReminderPageState extends State { disabledTextColor: Colors.white, disabledColor: CustomColors.green, onPressed: () async { - if (await Permission.contacts.request().isGranted) { - _showReminderDialog(context); - } else { - requestPermissions().then((results) { - if (results[Permission.calendar].isGranted) { - _showReminderDialog(context); - } - }); - } + print(widget.patientShareResponse.appointmentNo); + showReminderDialog( + context, + widget.dateTime, + widget.docObject.name, + widget.patientShareResponse.appointmentNo.toString(), + widget.appoDateFormatted, + widget.appoTimeFormatted, + onSuccess: () { + AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); + navigateToBookSuccess(context); + }, + ); }, child: Text(TranslationBase.of(context).yes, style: TextStyle(fontSize: 16.0, letterSpacing: -0.48)), ), @@ -223,49 +227,6 @@ class _BookReminderPageState extends State { BookSuccess(docObject: widget.docObject, patientShareResponse: widget.patientShareResponse, appoDateFormatted: widget.appoDateFormatted, appoTimeFormatted: widget.appoTimeFormatted))); } - Future _showReminderDialog(BuildContext context) async { - return showDialog( - context: context, - barrierDismissible: true, // user must tap button! - builder: (BuildContext context) { - return Dialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here - child: ReminderDialog( - onClick: (int i) async { - if (i == 0) { - // Before 30 mints - widget.dateTime = Jiffy(widget.dateTime).subtract(minutes: 30); - // dateTime.add(new Duration(minutes: -30)); - } else if (i == 1) { - // Before 1 hour - // dateTime.add(new Duration(minutes: -60)); - widget.dateTime = Jiffy(widget.dateTime).subtract(hours: 1); - } else if (i == 2) { - // Before 1 hour and 30 mints - // dateTime.add(new Duration(minutes: -90)); - widget.dateTime = Jiffy(widget.dateTime).subtract(hours: 1, minutes: 30); - } else if (i == 3) { - // Before 2 hours - // dateTime.add(new Duration(minutes: -120)); - widget.dateTime = Jiffy(widget.dateTime).subtract(hours: 2); - } - CalendarUtils calendarUtils = await CalendarUtils.getInstance(); - calendarUtils - .createOrUpdateEvent( - title: TranslationBase.of(context).reminderTitle + " " + widget.docObject.name, - description: "At " + widget.appoDateFormatted + " " + widget.appoTimeFormatted, - scheduleDateTime: widget.dateTime) - .then((value) { - AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); - navigateToBookSuccess(context); - }); - }, - ), - ); - }, - ); - } - Future> requestPermissions() async { var permissionResults = [Permission.calendar].request(); return permissionResults; diff --git a/lib/pages/BookAppointment/widgets/reminder_dialog.dart b/lib/pages/BookAppointment/widgets/reminder_dialog.dart index 5aec2d74..f0ba3091 100644 --- a/lib/pages/BookAppointment/widgets/reminder_dialog.dart +++ b/lib/pages/BookAppointment/widgets/reminder_dialog.dart @@ -1,6 +1,87 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:flutter/material.dart'; +import 'package:jiffy/jiffy.dart'; +import 'package:manage_calendar_events/manage_calendar_events.dart'; +import 'package:permission_handler/permission_handler.dart'; + +Future> requestPermissions() async { + var permissionResults = [Permission.calendar].request(); + return permissionResults; +} + +showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, {Function onSuccess}) async { + if (await Permission.calendar.request().isGranted) { + _showReminderDialog( + context, + dateTime, + doctorName, + eventId, + appoDateFormatted, + appoTimeFormatted, + onSuccess: onSuccess, + ); + } else { + requestPermissions().then((results) { + if (results[Permission.calendar].isGranted) { + _showReminderDialog( + context, + dateTime, + doctorName, + eventId, + appoDateFormatted, + appoTimeFormatted, + onSuccess: onSuccess, + ); + } + }); + } +} + +final CalendarPlugin _myPlugin = CalendarPlugin(); + +Future _showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, {Function onSuccess}) async { + return showDialog( + context: context, + barrierDismissible: true, // user must tap button! + builder: (BuildContext context) { + return Dialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here + child: ReminderDialog( + onClick: (int i) async { + if (i == 0) { + // Before 30 mints + dateTime = Jiffy(dateTime).subtract(minutes: 30); + // dateTime.add(new Duration(minutes: -30)); + } else if (i == 1) { + // Before 1 hour + // dateTime.add(new Duration(minutes: -60)); + dateTime = Jiffy(dateTime).subtract(hours: 1); + } else if (i == 2) { + // Before 1 hour and 30 mints + // dateTime.add(new Duration(minutes: -90)); + dateTime = Jiffy(dateTime).subtract(hours: 1, minutes: 30); + } else if (i == 3) { + // Before 2 hours + // dateTime.add(new Duration(minutes: -120)); + dateTime = Jiffy(dateTime).subtract(hours: 2); + } + CalendarUtils calendarUtils = await CalendarUtils.getInstance(); + calendarUtils + .createOrUpdateEvent( + title: TranslationBase.of(context).reminderTitle + " " + doctorName, description: "At " + appoDateFormatted + " " + appoTimeFormatted, scheduleDateTime: dateTime, eventId: eventId) + .then((value) {}); + + onSuccess(); + }, + ), + ); + }, + ); +} class ReminderDialog extends StatefulWidget { Function onClick; diff --git a/lib/pages/MyAppointments/widgets/AppointmentActions.dart b/lib/pages/MyAppointments/widgets/AppointmentActions.dart index 9fcff311..6fd63f56 100644 --- a/lib/pages/MyAppointments/widgets/AppointmentActions.dart +++ b/lib/pages/MyAppointments/widgets/AppointmentActions.dart @@ -6,7 +6,8 @@ import 'package:diplomaticquarterapp/core/viewModels/feedback/feedback_view_mode import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/appoDetailsButtons.dart'; -import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/reminder_dialog.dart'; + import 'package:diplomaticquarterapp/pages/MyAppointments/models/AppointmentType.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/models/ArrivedButtons.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/models/AskDocRequestTypeModel.dart'; @@ -17,6 +18,7 @@ import 'package:diplomaticquarterapp/pages/MyAppointments/models/ConfirmedButton import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/PrescriptionReport.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/askDocDialog.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog.dart'; + import 'package:diplomaticquarterapp/pages/feedback/feedback_home_page.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/labs/laboratory_result_page.dart'; @@ -24,7 +26,9 @@ import 'package:diplomaticquarterapp/pages/medical/radiology/radiology_details_p import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_screen.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart'; @@ -153,7 +157,6 @@ class _AppointmentActionsState extends State { } _handleButtonClicks(AppoDetailsButton) { - switch (AppoDetailsButton.caller) { case "openReschedule": widget.tabController.animateTo((widget.tabController.index + 1) % 2); @@ -182,7 +185,18 @@ class _AppointmentActionsState extends State { break; case "addReminder": - showReminderDialog(widget.appo); + // showReminderDialog(widget.appo); + showReminderDialog( + context, + DateUtil.convertStringToDate(widget.appo.appointmentDate), + widget.appo.doctorNameObj, + "", + DateUtil.formatDateToDate(DateUtil.convertStringToDate(widget.appo.appointmentDate)), + DateUtil.formatDateToTime(DateUtil.convertStringToDate(widget.appo.appointmentDate)), + onSuccess: () { + AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); + }, + ); break; case "goToTodoList": @@ -502,32 +516,35 @@ class _AppointmentActionsState extends State { } } - showReminderDialog(AppoitmentAllHistoryResultList appo) { - showGeneralDialog( - barrierColor: Colors.black.withOpacity(0.5), - transitionBuilder: (context, a1, a2, widget) { - final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0; - return Transform( - transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), - child: Opacity( - opacity: a1.value, - child: ReminderDialog( - eventId: appo.appointmentNo.toString(), - title: "Doctor Appointment", - description: "You have an appointment with " + appo.doctorTitle + " " + appo.doctorNameObj, - startDate: appo.appointmentDate, - endDate: appo.appointmentDate, - location: appo.projectName, - ), - ), - ); - }, - transitionDuration: Duration(milliseconds: 500), - barrierDismissible: true, - barrierLabel: '', - context: context, - pageBuilder: (context, animation1, animation2) {}); - } + // showReminderDialog(AppoitmentAllHistoryResultList appo) { + // + // + // //old reminder dialog having location + // showGeneralDialog( + // barrierColor: Colors.black.withOpacity(0.5), + // transitionBuilder: (context, a1, a2, widget) { + // final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0; + // return Transform( + // transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), + // child: Opacity( + // opacity: a1.value, + // child: ReminderDialog( + // eventId: appo.appointmentNo.toString(), + // title: "Doctor Appointment", + // description: "You have an appointment with " + appo.doctorTitle + " " + appo.doctorNameObj, + // startDate: appo.appointmentDate, + // endDate: appo.appointmentDate, + // location: appo.projectName, + // ), + // ), + // ); + // }, + // transitionDuration: Duration(milliseconds: 500), + // barrierDismissible: true, + // barrierLabel: '', + // context: context, + // pageBuilder: (context, animation1, animation2) {}); + // } askYourDoc() { GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/uitl/CalendarUtils.dart b/lib/uitl/CalendarUtils.dart index b1489d2b..0ab8be19 100644 --- a/lib/uitl/CalendarUtils.dart +++ b/lib/uitl/CalendarUtils.dart @@ -46,14 +46,19 @@ class CalendarUtils { }); } - Future createOrUpdateEvent({ String title, String description, DateTime scheduleDateTime}) async { + Future createOrUpdateEvent({ String title, String description, DateTime scheduleDateTime,String eventId}) async { RecurrenceRule recurrenceRule = RecurrenceRule( RecurrenceFrequency.Daily, // daysOfWeek: daysOfWeek, endDate: scheduleDateTime, ); + print("eventId "+eventId); Event event = Event(writableCalendars.id, recurrenceRule: recurrenceRule, start: scheduleDateTime, end: scheduleDateTime.add(Duration(minutes: 30)), title: title, description: description); - deviceCalendarPlugin.createOrUpdateEvent(event); + deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e){ + print("catchError "+e.toString()); + }).whenComplete(() { + print("whenComplete "+eventId); + }); } deleteEvent(Calendar _calendar, Event _event) async { @@ -67,6 +72,8 @@ class CalendarUtils { return await deviceCalendarPlugin.retrieveEvents(calendarId, retrieveEventsParams); } + + Future createCalendar( String calendarName, { Color calendarColor, From 3f0d8626e7f35ed38ec5651aad919d7514da5260 Mon Sep 17 00:00:00 2001 From: "Mirza.Shafique" Date: Wed, 1 Sep 2021 16:35:04 +0300 Subject: [PATCH 3/3] Marge issue --- lib/pages/BookAppointment/DoctorProfile.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/BookAppointment/DoctorProfile.dart b/lib/pages/BookAppointment/DoctorProfile.dart index c58f79c6..7d44dbac 100644 --- a/lib/pages/BookAppointment/DoctorProfile.dart +++ b/lib/pages/BookAppointment/DoctorProfile.dart @@ -118,7 +118,7 @@ class _DoctorProfileState extends State with TickerProviderStateM showConfirmMessageDialog: false, onTap: () { if (widget.isOpenAppt) { - Navigator.push(context, FadePage(page: SchedulePage(widget.doctor))); + // Navigator.push(context, FadePage(page: SchedulePage(doctorList: widget.doctor,appo: widget.,))); } }, onRatingAndReviewTap: () {