|
|
|
@ -24,27 +24,25 @@ showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, S
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
if (await PermissionService.isCalendarPermissionEnabled()) {
|
|
|
|
if (await PermissionService.isCalendarPermissionEnabled()) {
|
|
|
|
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
|
|
|
|
_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 {
|
|
|
|
} else {
|
|
|
|
Utils.showPermissionConsentDialog(context, TranslationBase.of(context).calendarPermission, () async {
|
|
|
|
Utils.showPermissionConsentDialog(context, TranslationBase.of(context).calendarPermission, () async {
|
|
|
|
if (await Permission.calendarFullAccess.request().isGranted) {
|
|
|
|
if (await Permission.calendarFullAccess.request().isGranted) {
|
|
|
|
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
|
|
|
|
_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 {
|
|
|
|
} else {
|
|
|
|
if (await Permission.calendarFullAccess.request().isGranted) {
|
|
|
|
if (await Permission.calendarFullAccess.request().isGranted) {
|
|
|
|
_showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted,
|
|
|
|
_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<void> _showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted,
|
|
|
|
Future<void> _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<void>(
|
|
|
|
return showDialog<void>(
|
|
|
|
context: context,
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: true, // user must tap button!
|
|
|
|
barrierDismissible: true, // user must tap button!
|
|
|
|
@ -77,17 +75,21 @@ Future<void> _showReminderDialog(BuildContext context, DateTime dateTime, String
|
|
|
|
text = "2 hours";
|
|
|
|
text = "2 hours";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (onMultiDateSuccess == null) {
|
|
|
|
if (onMultiDateSuccess.call(i) == null) {
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
calendarUtils
|
|
|
|
try {
|
|
|
|
.createOrUpdateEvent(
|
|
|
|
await calendarUtils.createOrUpdateEvent(
|
|
|
|
title: title ?? TranslationBase.of(context).reminderTitle + " " + doctorName,
|
|
|
|
title: title ?? TranslationBase
|
|
|
|
description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted,
|
|
|
|
.of(context)
|
|
|
|
scheduleDateTime: dateTime,
|
|
|
|
.reminderTitle + " " + doctorName,
|
|
|
|
eventId: eventId)
|
|
|
|
description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted,
|
|
|
|
.then((value) {});
|
|
|
|
scheduleDateTime: dateTime,
|
|
|
|
|
|
|
|
eventId: eventId);
|
|
|
|
|
|
|
|
|
|
|
|
onSuccess();
|
|
|
|
onSuccess();
|
|
|
|
|
|
|
|
}catch(e){
|
|
|
|
|
|
|
|
print(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
onMultiDateSuccess(i);
|
|
|
|
onMultiDateSuccess(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|