From df32ae0142954638ac4443da3dd64933b95eb06e Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 5 Oct 2021 11:33:34 +0300 Subject: [PATCH] lab order clinic/hospital name, prescription reminder ui, prescription availibility --- .../widgets/reminder_dialog.dart | 66 ++++------ lib/pages/medical/labs/labs_home_page.dart | 2 +- .../pharmacy_for_prescriptions_page.dart | 120 +++++++++--------- .../prescription_details_page.dart | 22 +++- .../prescription_items_page.dart | 1 + lib/uitl/CalendarUtils.dart | 12 +- 6 files changed, 109 insertions(+), 114 deletions(-) diff --git a/lib/pages/BookAppointment/widgets/reminder_dialog.dart b/lib/pages/BookAppointment/widgets/reminder_dialog.dart index 760f672a..1e580712 100644 --- a/lib/pages/BookAppointment/widgets/reminder_dialog.dart +++ b/lib/pages/BookAppointment/widgets/reminder_dialog.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; import 'package:manage_calendar_events/manage_calendar_events.dart'; @@ -12,29 +13,14 @@ Future> requestPermissions() async { return permissionResults; } -showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, {Function onSuccess}) async { +showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, + {Function onSuccess, String title, String description}) async { if (await Permission.calendar.request().isGranted) { - _showReminderDialog( - context, - dateTime, - doctorName, - eventId, - appoDateFormatted, - appoTimeFormatted, - onSuccess: onSuccess, - ); + _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, onSuccess: onSuccess, title: title, description: description); } else { requestPermissions().then((results) { if (results[Permission.calendar].isGranted) { - _showReminderDialog( - context, - dateTime, - doctorName, - eventId, - appoDateFormatted, - appoTimeFormatted, - onSuccess: onSuccess, - ); + _showReminderDialog(context, dateTime, doctorName, eventId, appoDateFormatted, appoTimeFormatted, onSuccess: onSuccess, title: title, description: description); } }); } @@ -42,13 +28,15 @@ showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, S final CalendarPlugin _myPlugin = CalendarPlugin(); -Future _showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, {Function onSuccess}) async { +Future _showReminderDialog(BuildContext context, DateTime dateTime, String doctorName, String eventId, String appoDateFormatted, String appoTimeFormatted, + {Function onSuccess, String title, String description}) async { return showDialog( context: context, barrierDismissible: true, // user must tap button! builder: (BuildContext context) { return Dialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0.0)), + insetPadding: EdgeInsets.all(21), child: ReminderDialog( onClick: (int i) async { if (i == 0) { @@ -71,7 +59,10 @@ Future _showReminderDialog(BuildContext context, DateTime dateTime, String CalendarUtils calendarUtils = await CalendarUtils.getInstance(); calendarUtils .createOrUpdateEvent( - title: TranslationBase.of(context).reminderTitle + " " + doctorName, description: "At " + appoDateFormatted + " " + appoTimeFormatted, scheduleDateTime: dateTime, eventId: eventId) + title: title ?? TranslationBase.of(context).reminderTitle + " " + doctorName, + description: description ?? "At " + appoDateFormatted + " " + appoTimeFormatted, + scheduleDateTime: dateTime, + eventId: eventId) .then((value) {}); onSuccess(); @@ -97,7 +88,7 @@ class _ReminderDialogState extends State { @override Widget build(BuildContext context) { return Container( - width: MediaQuery.of(context).size.width / 0.8, + //width: MediaQuery.of(context).size.width / 0.8, padding: const EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -106,13 +97,16 @@ class _ReminderDialogState extends State { children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Icon( Icons.notifications_active, + color: Color(0xff2B353E), size: 50, ), IconButton( icon: Icon(Icons.clear), + color: Color(0xff2B353E), onPressed: () { Navigator.of(context).pop(); }, @@ -124,6 +118,7 @@ class _ReminderDialogState extends State { "When would you like to set a reminder for this appointment?", style: TextStyle( fontSize: 16, + color: Color(0xff2B353E), fontWeight: FontWeight.w600, letterSpacing: -0.48, ), @@ -133,6 +128,7 @@ class _ReminderDialogState extends State { "Please select from below options:", style: TextStyle( fontSize: 12, + color: Color(0xff2B353E), fontWeight: FontWeight.w600, letterSpacing: -0.48, ), @@ -190,28 +186,14 @@ class _ReminderDialogState extends State { ), ), mHeight(12), - InkWell( - onTap: () { + DefaultButton( + TranslationBase.of(context).save, + () { widget.onClick(i); Navigator.pop(context); }, - child: Container( - width: double.infinity, - height: 45, - decoration: containerRadius(CustomColors.green, 12), - child: Center( - child: Text( - "Save", - style: TextStyle( - fontSize: 16, - letterSpacing: -0.48, - color: Colors.white, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - ) + color: CustomColors.green, + ), ], ), ); diff --git a/lib/pages/medical/labs/labs_home_page.dart b/lib/pages/medical/labs/labs_home_page.dart index e2f32d5d..26738778 100644 --- a/lib/pages/medical/labs/labs_home_page.dart +++ b/lib/pages/medical/labs/labs_home_page.dart @@ -82,7 +82,7 @@ class LabsHomePage extends StatelessWidget { name: TranslationBase.of(context).dr + " " + labOrder.doctorName, billNo: labOrder.invoiceNo, profileUrl: labOrder.doctorImageURL, - subName: _isSortByClinic ? labOrder.projectName : labOrder.clinicDescription, + subName: _isSortByClinic ? (labOrder.projectName ?? labOrder.clinicDescription) : (labOrder.clinicDescription ?? labOrder.projectName), isLiveCareAppointment: labOrder.isLiveCareAppointment, date: labOrder.orderDate, isSortByClinic: _isSortByClinic, diff --git a/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart index c24a0945..cdc7be72 100644 --- a/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart +++ b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart @@ -63,77 +63,77 @@ class PharmacyForPrescriptionsPage extends StatelessWidget { ), ), model.pharmacyPrescriptionsList.isNotEmpty == true - ? ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (context, index) => Container( - width: double.infinity, - margin: EdgeInsets.only(top: 10, left: 10, right: 10), - padding: EdgeInsets.all(8.0), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - border: Border.all(color: Colors.grey[200], width: 0.5), - ), - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5)), - child: Image.network( - model.pharmacyPrescriptionsList[index].projectImageURL, - fit: BoxFit.cover, - width: 60, - height: 70, - ), + ? Expanded( + child: ListView.builder( + scrollDirection: Axis.vertical, + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) => Container( + width: double.infinity, + margin: EdgeInsets.only(top: 10, left: 10, right: 10), + padding: EdgeInsets.all(8.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10.0), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts(model.pharmacyPrescriptionsList[index].locationDescription), - SizedBox( - height: 5, - ), - Texts(model.pharmacyPrescriptionsList[index].cityName), - ], + border: Border.all(color: Colors.grey[200], width: 0.5), + ), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5)), + child: Image.network( + model.pharmacyPrescriptionsList[index].projectImageURL, + fit: BoxFit.cover, + width: 60, + height: 70, ), ), - ), - InkWell( - onTap: () { - MapsLauncher.launchCoordinates( - double.parse(model.pharmacyPrescriptionsList[index].latitude), - double.parse(model.pharmacyPrescriptionsList[index].longitude)); - }, - child: Icon( - Icons.pin_drop, - size: 18, - color: Colors.red[900], + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts(model.pharmacyPrescriptionsList[index].locationDescription), + SizedBox( + height: 5, + ), + Texts(model.pharmacyPrescriptionsList[index].cityName), + ], + ), + ), ), - ), - SizedBox( - width: 15, - ), - InkWell( - onTap: Feedback.wrapForTap(() { - launch("tel://${model.pharmacyPrescriptionsList[index].phoneNumber}"); - }, context), - child: Container( + InkWell( + onTap: () { + MapsLauncher.launchCoordinates(double.parse(model.pharmacyPrescriptionsList[index].latitude), double.parse(model.pharmacyPrescriptionsList[index].longitude)); + }, child: Icon( - Icons.call, + Icons.pin_drop, size: 18, color: Colors.red[900], ), ), - ) - ], + SizedBox( + width: 15, + ), + InkWell( + onTap: Feedback.wrapForTap(() { + launch("tel://${model.pharmacyPrescriptionsList[index].phoneNumber}"); + }, context), + child: Container( + child: Icon( + Icons.call, + size: 18, + color: Colors.red[900], + ), + ), + ) + ], + ), ), + itemCount: model.pharmacyPrescriptionsList.length, ), - itemCount: model.pharmacyPrescriptionsList.length, ) : Padding( padding: const EdgeInsets.only(top: 65.0), diff --git a/lib/pages/medical/prescriptions/prescription_details_page.dart b/lib/pages/medical/prescriptions/prescription_details_page.dart index d86ea637..cf5afd77 100644 --- a/lib/pages/medical/prescriptions/prescription_details_page.dart +++ b/lib/pages/medical/prescriptions/prescription_details_page.dart @@ -3,8 +3,10 @@ import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_repor import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; 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/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; @@ -100,9 +102,7 @@ class PrescriptionDetailsPage extends StatelessWidget { ], ), SizedBox(height: 12), - Table( - border: TableBorder(horizontalInside: BorderSide(width: 1, color: Colors.black, style: BorderStyle.solid)), - children: [ + Table(border: TableBorder(horizontalInside: BorderSide(width: 1, color: Colors.black, style: BorderStyle.solid)), children: [ TableRow( children: [ Utils.tableColumnTitle(TranslationBase.of(context).route, showDivider: false), @@ -166,7 +166,21 @@ class PrescriptionDetailsPage extends StatelessWidget { DateTime startDate = DateTime.now(); DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + prescriptionReport.days); - print(prescriptionReport); + 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) { diff --git a/lib/pages/medical/prescriptions/prescription_items_page.dart b/lib/pages/medical/prescriptions/prescription_items_page.dart index 4819db21..8695a88f 100644 --- a/lib/pages/medical/prescriptions/prescription_items_page.dart +++ b/lib/pages/medical/prescriptions/prescription_items_page.dart @@ -43,6 +43,7 @@ class PrescriptionItemsPage extends StatelessWidget { children: [ Expanded( child: SingleChildScrollView( + physics: BouncingScrollPhysics(), child: Column( children: [ DoctorHeader( diff --git a/lib/uitl/CalendarUtils.dart b/lib/uitl/CalendarUtils.dart index 0ab8be19..ee602391 100644 --- a/lib/uitl/CalendarUtils.dart +++ b/lib/uitl/CalendarUtils.dart @@ -46,18 +46,18 @@ class CalendarUtils { }); } - Future createOrUpdateEvent({ String title, String description, DateTime scheduleDateTime,String eventId}) async { + Future createOrUpdateEvent({String title, String description, DateTime scheduleDateTime, String eventId}) async { RecurrenceRule recurrenceRule = RecurrenceRule( RecurrenceFrequency.Daily, // daysOfWeek: daysOfWeek, endDate: scheduleDateTime, ); - print("eventId "+eventId); + print("eventId " + eventId); Event event = Event(writableCalendars.id, recurrenceRule: recurrenceRule, start: scheduleDateTime, end: scheduleDateTime.add(Duration(minutes: 30)), title: title, description: description); - deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e){ - print("catchError "+e.toString()); + deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e) { + print("catchError " + e.toString()); }).whenComplete(() { - print("whenComplete "+eventId); + print("whenComplete " + eventId); }); } @@ -72,8 +72,6 @@ class CalendarUtils { return await deviceCalendarPlugin.retrieveEvents(calendarId, retrieveEventsParams); } - - Future createCalendar( String calendarName, { Color calendarColor,