Prescription reminder fixes

dev_v3.13.6_BLE_Faiz
haroon amjad 1 year ago
parent 2b560840aa
commit e9404f1656

@ -25,6 +25,7 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:manage_calendar_events/manage_calendar_events.dart' as ios;
import 'package:provider/provider.dart';
class PrescriptionDetailsPage extends StatefulWidget {
@ -246,6 +247,7 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
}
checkIfHasReminder() async {
final ios.CalendarPlugin _myPlugin = ios.CalendarPlugin();
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
print("If Has Reminder");
DateTime startEventsDate = Jiffy.parseFromDateTime(DateTime.now()).subtract(days: 30).dateTime;
@ -262,7 +264,6 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
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;
@ -271,27 +272,29 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
}),
});
} else {
List<ios.Calendar>? iosCall = await _myPlugin.getCalendars();
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;
});
});
}),
});
iosCall!,
(ios.Calendar cal) async => {
print(cal),
calendarUtils.retrieveEvents(cal.id!, params).then((value) {
Result<UnmodifiableListView<Event>> events = value;
events.data!.forEach((element) {
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!))
setState(() {
hasReminder = true;
});
});
}),
},
);
}
}
}
cancelReminders() async {
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
final ios.CalendarPlugin _myPlugin = ios.CalendarPlugin();
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);
@ -303,28 +306,35 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
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);
});
}),
});
} else {
List<ios.Calendar>? iosCal = await _myPlugin.getCalendars();
Future.forEach(
calendarUtils.calendars,
(List<Calendar> calender) => {
calendarUtils.retrieveEvents(calender[0].id!, params).then((value) {
iosCal!,
(ios.Calendar cale) async => {
calendarUtils.retrieveEvents(cale.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[0], element);
print(element.title);
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!))
calendarUtils.deleteEvent(
Calendar(
id: cale.id,
name: cale.name,
accountName: cale.accountName,
),
element);
});
}),
});
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderCancelSuccess);
setState(() {
hasReminder = false;
});
}
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderCancelSuccess);
setState(() {
hasReminder = false;
});
}
setCalender(BuildContext context, String eventId, int reminderIndex) async {

@ -103,7 +103,7 @@ dependencies:
flutter_svg: ^2.0.8
#Calendar Events
manage_calendar_events: ^2.0.2
manage_calendar_events: ^2.0.3
#InAppBrowser
flutter_inappwebview: ^5.8.0

Loading…
Cancel
Save