Calender Event Fixes

dev_v3.13.6_BLE_Faiz
Aamir.Muhammad 1 year ago
parent 2e25940b62
commit 0ef716f536

@ -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,7 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
if (calendarUtils.calendars != null) {
print(calendarUtils.calendars);
if (Platform.isAndroid) {
Future.forEach(
calendarUtils.calendars,
(Calendar calender) => {
@ -268,6 +270,22 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
});
}),
});
} 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;
});
});
}),
});
}
}
}
@ -278,6 +296,7 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
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) => {
@ -289,7 +308,19 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
});
}),
});
} 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);
});
}),
});
}
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderCancelSuccess);
setState(() {
hasReminder = false;

Loading…
Cancel
Save