|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import 'dart:collection';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:device_calendar/device_calendar.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart';
|
|
|
|
|
@ -254,6 +255,48 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
|
|
|
|
|
if (calendarUtils.calendars != null) {
|
|
|
|
|
print(calendarUtils.calendars);
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
|
Future.forEach(
|
|
|
|
|
calendarUtils.calendars,
|
|
|
|
|
(Calendar calender) => {
|
|
|
|
|
calendarUtils.retrieveEvents(calender.id!, params).then((value) {
|
|
|
|
|
Result<UnmodifiableListView<Event>> events = value;
|
|
|
|
|
events.data!.forEach((element) {
|
|
|
|
|
print(widget.prescriptionReport!.itemDescriptionN!);
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!))
|
|
|
|
|
setState(() {
|
|
|
|
|
hasReminder = true;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
Future.forEach(
|
|
|
|
|
calendarUtils.calendars,
|
|
|
|
|
(List<Calendar> calender) => {
|
|
|
|
|
calendarUtils.retrieveEvents(calender[0].id!, params).then((value) {
|
|
|
|
|
Result<UnmodifiableListView<Event>> events = value;
|
|
|
|
|
events.data!.forEach((element) {
|
|
|
|
|
print(widget.prescriptionReport!.itemDescriptionN!);
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!))
|
|
|
|
|
setState(() {
|
|
|
|
|
hasReminder = true;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cancelReminders() async {
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
DateTime startEventsDate = Jiffy.parseFromDateTime(DateTime.now()).subtract(days: 30).dateTime;
|
|
|
|
|
DateTime endEventsDate = Jiffy.parseFromDateTime(DateTime.now()).add(days: 120).dateTime;
|
|
|
|
|
RetrieveEventsParams params = RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate);
|
|
|
|
|
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
|
Future.forEach(
|
|
|
|
|
calendarUtils.calendars,
|
|
|
|
|
(Calendar calender) => {
|
|
|
|
|
@ -261,35 +304,23 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
Result<UnmodifiableListView<Event>> events = value;
|
|
|
|
|
events.data!.forEach((element) {
|
|
|
|
|
print(widget.prescriptionReport!.itemDescriptionN!);
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!))
|
|
|
|
|
setState(() {
|
|
|
|
|
hasReminder = true;
|
|
|
|
|
});
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!)) calendarUtils.deleteEvent(calender, element);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
Future.forEach(
|
|
|
|
|
calendarUtils.calendars,
|
|
|
|
|
(List<Calendar> calender) => {
|
|
|
|
|
calendarUtils.retrieveEvents(calender[0].id!, params).then((value) {
|
|
|
|
|
Result<UnmodifiableListView<Event>> events = value;
|
|
|
|
|
events.data!.forEach((element) {
|
|
|
|
|
print(widget.prescriptionReport!.itemDescriptionN!);
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!)) calendarUtils.deleteEvent(calender, element);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cancelReminders() async {
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
DateTime startEventsDate = Jiffy.parseFromDateTime(DateTime.now()).subtract(days: 30).dateTime;
|
|
|
|
|
DateTime endEventsDate = Jiffy.parseFromDateTime(DateTime.now()).add(days: 120).dateTime;
|
|
|
|
|
RetrieveEventsParams params = RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate);
|
|
|
|
|
|
|
|
|
|
Future.forEach(
|
|
|
|
|
calendarUtils.calendars,
|
|
|
|
|
(Calendar calender) => {
|
|
|
|
|
calendarUtils.retrieveEvents(calender.id!, params).then((value) {
|
|
|
|
|
Result<UnmodifiableListView<Event>> events = value;
|
|
|
|
|
events.data!.forEach((element) {
|
|
|
|
|
print(widget.prescriptionReport!.itemDescriptionN!);
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!)) calendarUtils.deleteEvent(calender, element);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderCancelSuccess);
|
|
|
|
|
setState(() {
|
|
|
|
|
hasReminder = false;
|
|
|
|
|
|