|
|
|
|
@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/header_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/reminder_dialog.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog_prescription.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/LocalNotification.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
@ -32,7 +33,6 @@ class PrescriptionDetailsPage extends StatelessWidget {
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
showNewAppBar: true,
|
|
|
|
|
backgroundColor: Color(0xffF8F8F8),
|
|
|
|
|
showNewAppBarTitle: true,
|
|
|
|
|
appBarTitle: TranslationBase.of(context).prescriptions,
|
|
|
|
|
body: Column(
|
|
|
|
|
@ -197,49 +197,24 @@ class PrescriptionDetailsPage extends StatelessWidget {
|
|
|
|
|
child: DefaultButton(
|
|
|
|
|
TranslationBase.of(context).addReminder,
|
|
|
|
|
() {
|
|
|
|
|
DateTime startDate = DateTime.now();
|
|
|
|
|
DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + prescriptionReport.days);
|
|
|
|
|
|
|
|
|
|
showReminderDialog(
|
|
|
|
|
context,
|
|
|
|
|
endDate,
|
|
|
|
|
"",
|
|
|
|
|
prescriptionReport.itemID.toString(),
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
|
|
|
|
|
onSuccess: () {
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
showGeneralDialog(
|
|
|
|
|
barrierColor: Colors.black.withOpacity(0.5),
|
|
|
|
|
transitionBuilder: (context, a1, a2, widget) {
|
|
|
|
|
final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0;
|
|
|
|
|
return Transform(
|
|
|
|
|
transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0),
|
|
|
|
|
child: Opacity(
|
|
|
|
|
opacity: a1.value,
|
|
|
|
|
child: PrescriptionReminderDialog(
|
|
|
|
|
eventId: prescriptionReport.itemID.toString(),
|
|
|
|
|
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
|
|
|
|
|
startDate: startDate,
|
|
|
|
|
endDate: endDate,
|
|
|
|
|
location: prescriptionReport.remarks,
|
|
|
|
|
days: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
transitionDuration: Duration(milliseconds: 500),
|
|
|
|
|
barrierDismissible: true,
|
|
|
|
|
barrierLabel: '',
|
|
|
|
|
context: context,
|
|
|
|
|
pageBuilder: (context, animation1, animation2) {});
|
|
|
|
|
setTheNotificatoin(context);
|
|
|
|
|
// DateTime startDate = DateTime.now();
|
|
|
|
|
// DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + prescriptionReport.days);
|
|
|
|
|
//
|
|
|
|
|
// showReminderDialog(
|
|
|
|
|
// context,
|
|
|
|
|
// endDate,
|
|
|
|
|
// "",
|
|
|
|
|
// prescriptionReport.itemID.toString(),
|
|
|
|
|
// "",
|
|
|
|
|
// "",
|
|
|
|
|
// title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
// description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
|
|
|
|
|
// onSuccess: () {
|
|
|
|
|
// AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
// },
|
|
|
|
|
// );
|
|
|
|
|
// return;
|
|
|
|
|
},
|
|
|
|
|
iconData: Icons.notifications_active,
|
|
|
|
|
color: Color(0xffD02127),
|
|
|
|
|
@ -253,4 +228,25 @@ class PrescriptionDetailsPage extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTheNotificatoin(BuildContext context) {
|
|
|
|
|
DateTime startDate = DateUtil.convertStringToDate(prescriptionReport.startDate);
|
|
|
|
|
DateTime actualDate = DateTime(startDate.year, startDate.month, startDate.day, 8, 0);
|
|
|
|
|
if(prescriptionReport?.frequencyNumber==null)
|
|
|
|
|
prescriptionReport.frequencyNumber=2;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < prescriptionReport.days; i++) {
|
|
|
|
|
for (int j = 0; j < prescriptionReport.frequencyNumber??2; j++) {
|
|
|
|
|
if (j != 0) {
|
|
|
|
|
actualDate.add(new Duration(hours: 8));
|
|
|
|
|
}
|
|
|
|
|
LocalNotification.getInstance().scheduleNotification(
|
|
|
|
|
scheduledNotificationDateTime: actualDate,
|
|
|
|
|
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ");
|
|
|
|
|
}
|
|
|
|
|
actualDate.add(new Duration(days: i + 1));
|
|
|
|
|
}
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|