From fb62ce2f19b1252284683401541066ec95375283 Mon Sep 17 00:00:00 2001 From: devamirsaleemahmad Date: Sun, 26 Nov 2023 10:16:51 +0300 Subject: [PATCH] Calender Fix Ios 17+ --- lib/pages/BookAppointment/BookSuccess.dart | 2 +- lib/pages/BookAppointment/QRCode.dart | 2 +- .../BookAppointment/book_reminder_page.dart | 6 ++-- .../widgets/reminder_dialog.dart | 32 ++++++++++--------- .../appointment_services/GetDoctorsList.dart | 2 -- lib/uitl/CalendarUtils.dart | 4 +-- pubspec.yaml | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/pages/BookAppointment/BookSuccess.dart b/lib/pages/BookAppointment/BookSuccess.dart index 021d4bf2..4e5d36b9 100644 --- a/lib/pages/BookAppointment/BookSuccess.dart +++ b/lib/pages/BookAppointment/BookSuccess.dart @@ -94,7 +94,7 @@ class _BookSuccessState extends State { widget.docObject.projectName!, null, null, - widget.docObject.nationalityFlagURL!, + widget.docObject.nationalityFlagURL ?? "", widget.docObject.doctorRate, null, widget.docObject.noOfPatientsRate, diff --git a/lib/pages/BookAppointment/QRCode.dart b/lib/pages/BookAppointment/QRCode.dart index 1844a3d6..ffe8e268 100644 --- a/lib/pages/BookAppointment/QRCode.dart +++ b/lib/pages/BookAppointment/QRCode.dart @@ -107,7 +107,7 @@ class _QRCodeState extends State { DoctorHeader( headerModel: HeaderModel( widget.appointment!.doctorTitle! + " " + widget.appointment!.doctorNameObj!, - widget.appointment!.doctorID!, + widget.appointment!.doctorID ?? 0, widget.appointment!.doctorImageURL!, widget.appointment!.doctorSpeciality!, "", diff --git a/lib/pages/BookAppointment/book_reminder_page.dart b/lib/pages/BookAppointment/book_reminder_page.dart index 6615f092..56c48589 100644 --- a/lib/pages/BookAppointment/book_reminder_page.dart +++ b/lib/pages/BookAppointment/book_reminder_page.dart @@ -1,5 +1,6 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/main.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart'; import 'package:diplomaticquarterapp/models/header_model.dart'; @@ -188,8 +189,6 @@ class _BookReminderPageState extends State { backgroundColor: CustomColors.green, elevation: 0, onPressed: () async { - print(widget.patientShareResponse); - print(widget.patientShareResponse.appointmentNo); showReminderDialog( context, widget.dateTime!, @@ -201,7 +200,8 @@ class _BookReminderPageState extends State { AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); navigateToBookSuccess(context); }, - title: "" + title: null, + description: null ); projectViewModel.analytics.appointment.appointment_reminder(true); }, diff --git a/lib/pages/BookAppointment/widgets/reminder_dialog.dart b/lib/pages/BookAppointment/widgets/reminder_dialog.dart index 91c04833..37f343ad 100644 --- a/lib/pages/BookAppointment/widgets/reminder_dialog.dart +++ b/lib/pages/BookAppointment/widgets/reminder_dialog.dart @@ -24,27 +24,25 @@ showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, S if (Platform.isAndroid) { if (await PermissionService.isCalendarPermissionEnabled()) { _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, - onSuccess: onSuccess, title: title ?? "", description: description ?? "", onMultiDateSuccess: onMultiDateSuccess ?? (int) {}); + onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess ?? (int) {}); } else { Utils.showPermissionConsentDialog(context, TranslationBase.of(context).calendarPermission, () async { if (await Permission.calendarFullAccess.request().isGranted) { _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, - onSuccess: onSuccess, title: title ?? "", description: description ?? "", onMultiDateSuccess: onMultiDateSuccess ?? (int) {}); + onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess ?? (int) {}); } }); } } else { if (await Permission.calendarFullAccess.request().isGranted) { _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, - onSuccess: onSuccess, title: title ?? "", description: description ?? "", onMultiDateSuccess: onMultiDateSuccess ?? (int) {}); + onSuccess: onSuccess, title: title, description: description, onMultiDateSuccess: onMultiDateSuccess ?? (int) {}); } } } -final CalendarPlugin _myPlugin = CalendarPlugin(); - Future _showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, - {required Function onSuccess, required String title, required String description, required Function(int) onMultiDateSuccess}) async { + {required Function onSuccess, String? title, String? description, required Function(int) onMultiDateSuccess}) async { return showDialog( context: context, barrierDismissible: true, // user must tap button! @@ -77,17 +75,21 @@ Future _showReminderDialog(BuildContext context, DateTime dateTime, String text = "2 hours"; } - if (onMultiDateSuccess == null) { + if (onMultiDateSuccess.call(i) == null) { CalendarUtils calendarUtils = await CalendarUtils.getInstance(); - calendarUtils - .createOrUpdateEvent( - title: title ?? TranslationBase.of(context).reminderTitle + " " + doctorName, - description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted, - scheduleDateTime: dateTime, - eventId: eventId) - .then((value) {}); + try { + await calendarUtils.createOrUpdateEvent( + title: title ?? TranslationBase + .of(context) + .reminderTitle + " " + doctorName, + description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted, + scheduleDateTime: dateTime, + eventId: eventId); - onSuccess(); + onSuccess(); + }catch(e){ + print(e); + } } else { onMultiDateSuccess(i); } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 15e9e0a0..fa87e489 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -393,10 +393,8 @@ class DoctorsListService extends BaseService { await baseAppClient.post(INSERT_SPECIFIC_APPOINTMENT, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { - logger.d(error); throw error; }, body: request); - logger.d(localRes); return Future.value(localRes); } catch (e) { logger.d(e); diff --git a/lib/uitl/CalendarUtils.dart b/lib/uitl/CalendarUtils.dart index add65f64..1b34d18b 100644 --- a/lib/uitl/CalendarUtils.dart +++ b/lib/uitl/CalendarUtils.dart @@ -59,7 +59,7 @@ class CalendarUtils { }); } - Future createOrUpdateEvent({String? title, String? description, DateTime? scheduleDateTime, String? eventId}) async { + Future createOrUpdateEvent({required String title, required String description, DateTime? scheduleDateTime, String? eventId}) async { RecurrenceRule recurrenceRule = RecurrenceRule( RecurrenceFrequency.Daily, // daysOfWeek: daysOfWeek, @@ -74,7 +74,7 @@ class CalendarUtils { TZDateTime scheduleDateTimeUTZ = TZDateTime.from(scheduleDateTime!, _currentLocation); - // print("eventId: " + eventId); + //print("eventId: " + eventId); // print("writableCalendars-name: " + writableCalendars.name); // print("writableCalendars-Id: " + writableCalendars.id); // print("writableCalendarsToString: " + writableCalendars.toString()); diff --git a/pubspec.yaml b/pubspec.yaml index 5f16ef12..c00d6d1a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -121,7 +121,7 @@ dependencies: flutter_datetime_picker_plus: ^2.1.0 carousel_pro_nullsafety: ^2.0.0 flutter_local_notifications: any - device_calendar: ^4.2.0 + device_calendar: ^4.3.2 geolocator: ^9.0.2 geocoding: ^2.0.1 jiffy: ^6.2.1