From 61a406085b04182ef939b1598998184dfbef1536 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 15 Nov 2021 10:52:01 +0300 Subject: [PATCH 1/3] lakum fixes --- .../pharmacyModule/lacum-viewmodel.dart | 6 +-- .../pharmacies/screens/lakum-main-page.dart | 29 +++++------ .../screens/payment-method-select-page.dart | 52 +++++++------------ .../widgets/lacum-banner-widget.dart | 16 +++--- lib/pages/pharmacy/order/Order.dart | 42 ++++++--------- .../pharmacyAddresses/AddAddress.dart | 2 +- 6 files changed, 63 insertions(+), 84 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/lacum-viewmodel.dart b/lib/core/viewModels/pharmacyModule/lacum-viewmodel.dart index c03e8e87..1bd0d542 100644 --- a/lib/core/viewModels/pharmacyModule/lacum-viewmodel.dart +++ b/lib/core/viewModels/pharmacyModule/lacum-viewmodel.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'dart:convert' as convert; +import 'dart:convert'; import 'dart:typed_data'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; @@ -92,8 +92,8 @@ class LacumViewModel extends BaseViewModel { Uint8List convertBase64ToBarCodeImage() { try { - final _byteImage = convert.base64Decode( - lacumGroupInformation.lakumInquiryInformationObjVersion.barCode); + final _byteImage = base64Decode( + lacumGroupInformation.lakumInquiryInformationObjVersion.barCode.split(',').last); return _byteImage; } catch (e) { print(e); diff --git a/lib/pages/pharmacies/screens/lakum-main-page.dart b/lib/pages/pharmacies/screens/lakum-main-page.dart index c4415852..dcee8398 100644 --- a/lib/pages/pharmacies/screens/lakum-main-page.dart +++ b/lib/pages/pharmacies/screens/lakum-main-page.dart @@ -69,16 +69,15 @@ class LakumMainPage extends StatelessWidget { ], ), SizedBox( - width: 8, + height: 12, ), - LacumPointsWidget(mediaQuery, 2, TranslationBase.of(context).gained, model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount, - model.lacumGroupInformation.lakumInquiryInformationObjVersion.gainedPoints, model.lacumGroupInformation.lakumInquiryInformationObjVersion.gainedPointsAmountPerYear), + LakumHomeButtons(mediaQuery, model), SizedBox( - height: 20, + height: 12, ), Container( - height: 125, - margin: EdgeInsets.symmetric(horizontal: 16), + height: 100, + margin: EdgeInsets.symmetric(horizontal: 16, vertical: 12.0), child: ListView( scrollDirection: Axis.horizontal, children: [ @@ -109,15 +108,15 @@ class LakumMainPage extends StatelessWidget { ], ), ), - LacumPointsWidget( - mediaQuery, - 3, - TranslationBase.of(context).consumed, - model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount != null - ? int.parse(model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount) - : 0, - model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPoints, - model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmountPerYear), + // LacumPointsWidget( + // mediaQuery, + // 3, + // TranslationBase.of(context).consumed, + // model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount != null + // ? int.parse(model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount) + // : 0, + // model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPoints, + // model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmountPerYear), SizedBox( width: 8, ), diff --git a/lib/pages/pharmacies/screens/payment-method-select-page.dart b/lib/pages/pharmacies/screens/payment-method-select-page.dart index 978afae3..53b0357e 100644 --- a/lib/pages/pharmacies/screens/payment-method-select-page.dart +++ b/lib/pages/pharmacies/screens/payment-method-select-page.dart @@ -16,13 +16,10 @@ class PaymentMethodSelectPage extends StatefulWidget { final bool isUpdating; final Function changeMainState; - const PaymentMethodSelectPage( - {Key key, this.model, this.isUpdating = false, this.changeMainState}) - : super(key: key); + const PaymentMethodSelectPage({Key key, this.model, this.isUpdating = false, this.changeMainState}) : super(key: key); @override - _PaymentMethodSelectPageState createState() => - _PaymentMethodSelectPageState(); + _PaymentMethodSelectPageState createState() => _PaymentMethodSelectPageState(); } class _PaymentMethodSelectPageState extends State { @@ -85,16 +82,17 @@ class _PaymentMethodSelectPageState extends State { selectedPaymentOption = PaymentOption.mastercard; }) }), - PaymentMethodCard( - cardWidth, - selectedPaymentOption, - PaymentOption.installments, - () => { - setState(() { - selectedPaymentOption = - PaymentOption.installments; - }) - }), + widget.model.cartResponse.totalAmount > 1000 + ? PaymentMethodCard( + cardWidth, + selectedPaymentOption, + PaymentOption.installments, + () => { + setState(() { + selectedPaymentOption = PaymentOption.installments; + }) + }) + : Container(), if (Platform.isIOS) PaymentMethodCard( cardWidth, @@ -118,8 +116,7 @@ class _PaymentMethodSelectPageState extends State { TranslationBase.of(context).next, selectedPaymentOption != null ? () { - widget.model.paymentCheckoutData.paymentOption = - selectedPaymentOption; + widget.model.paymentCheckoutData.paymentOption = selectedPaymentOption; if (widget.isUpdating) { widget.changeMainState(); Navigator.pop(context); @@ -150,14 +147,12 @@ class PaymentMethodCard extends StatelessWidget { final PaymentOption paymentOption; final Function selectMethod; - PaymentMethodCard(this.cardWidth, this.selectedPaymentOption, - this.paymentOption, this.selectMethod); + PaymentMethodCard(this.cardWidth, this.selectedPaymentOption, this.paymentOption, this.selectMethod); @override Widget build(BuildContext context) { bool isSelected = false; - if (selectedPaymentOption != null && - selectedPaymentOption == paymentOption) { + if (selectedPaymentOption != null && selectedPaymentOption == paymentOption) { isSelected = true; } @@ -171,9 +166,7 @@ class PaymentMethodCard extends StatelessWidget { color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), - side: isSelected - ? BorderSide(color: Colors.green, width: 2.0) - : BorderSide(color: Colors.transparent, width: 0.0), + side: isSelected ? BorderSide(color: Colors.green, width: 2.0) : BorderSide(color: Colors.transparent, width: 0.0), ), child: Padding( padding: const EdgeInsets.all(12.0), @@ -182,13 +175,7 @@ class PaymentMethodCard extends StatelessWidget { Container( width: 24, height: 24, - decoration: containerColorRadiusBorderWidth( - isSelected - ? CustomColors.accentColor - : Colors.transparent, - 100, - Colors.grey, - 0.5), + decoration: containerColorRadiusBorderWidth(isSelected ? CustomColors.accentColor : Colors.transparent, 100, Colors.grey, 0.5), ), mWidth(12), Container( @@ -200,8 +187,7 @@ class PaymentMethodCard extends StatelessWidget { if (isSelected) Container( decoration: containerRadius(CustomColors.green, 200), - padding: - EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), + padding: EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), child: Text( TranslationBase.of(context).paymentSelected, style: TextStyle( diff --git a/lib/pages/pharmacies/widgets/lacum-banner-widget.dart b/lib/pages/pharmacies/widgets/lacum-banner-widget.dart index 7d10b886..60ca4693 100644 --- a/lib/pages/pharmacies/widgets/lacum-banner-widget.dart +++ b/lib/pages/pharmacies/widgets/lacum-banner-widget.dart @@ -229,13 +229,15 @@ class _LakumBannerWidgetState extends State { width: widget.mediaQuery.size.width * 1.0, height: widget.mediaQuery.size.width * 1.0, ), - Container( - margin: EdgeInsets.fromLTRB(12, 70, 12, 4), - child: widget.model.convertBase64ToBarCodeImage() != - null - ? Image.memory( - widget.model.convertBase64ToBarCodeImage()) - : Container(), + Center( + child: Container( + margin: EdgeInsets.fromLTRB(12, 70, 12, 4), + child: widget.model.convertBase64ToBarCodeImage() != + null + ? Image.memory( + widget.model.convertBase64ToBarCodeImage()) + : Container(), + ), ), ], ), diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index d1afd5a8..e859752a 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -217,12 +217,10 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), Container( margin: EdgeInsets.all(8.0), - child: SvgPicture.asset( - projectViewModel.isArabic - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', - height: 20, - width: 20, + child: Icon( + Icons.arrow_forward, + size: 18, + color: Colors.grey[500], ), ), ], @@ -503,12 +501,10 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), Container( margin: EdgeInsets.all(8.0), - child: SvgPicture.asset( - projectViewModel.isArabic - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', - height: 20, - width: 20, + child: Icon( + Icons.arrow_forward, + size: 18, + color: Colors.grey[500], ), ), ], @@ -969,12 +965,10 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), Container( margin: EdgeInsets.all(8.0), - child: SvgPicture.asset( - projectViewModel.isArabic - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', - height: 20, - width: 20, + child: Icon( + Icons.arrow_forward, + size: 18, + color: Colors.grey[500], ), ), ], @@ -1139,7 +1133,7 @@ class _OrderPageState extends State with SingleTickerProviderStateMix cancelledOrderList.clear(); for (int i = 0; i < model.orders.length; i++) { if (model.orders[i].orderStatusId == 40 || - model.orders[i].orderStatus == 996 || + model.orders[i].orderStatusId == 996 || model.orders[i].orderStatusId == 200) { cancelledOrderList.add(model.orders[i]); } @@ -1243,12 +1237,10 @@ class _OrderPageState extends State with SingleTickerProviderStateMix ), Container( margin: EdgeInsets.all(8.0), - child: SvgPicture.asset( - projectViewModel.isArabic - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', - height: 20, - width: 20, + child: Icon( + Icons.arrow_forward, + size: 18, + color: Colors.grey[500], ), ), ], diff --git a/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart b/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart index 514ea1a5..5e55d537 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart @@ -62,7 +62,7 @@ class _AddAddressPageState extends State { return BaseView( builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).changeAddress, - isShowAppBar: true, + isShowAppBar: false, isPharmacy: true, backgroundColor: Colors.white, body: Container( From 68294690a1aa7df3e01f90091b2a737dbd9c52f6 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 15 Nov 2021 16:20:43 +0300 Subject: [PATCH 2/3] prescription reminders added --- lib/config/localized_values.dart | 2 + lib/core/service/client/base_app_client.dart | 8 +- .../prescription_details_page.dart | 198 +++++++++++------- lib/uitl/translations_delegate_base.dart | 3 +- 4 files changed, 130 insertions(+), 81 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 56113044..b52db706 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -171,6 +171,7 @@ const Map localizedValues = { "minute": {"en": "Minutes", "ar": "دقيقة"}, "hour": {"en": "Hour", "ar": "ساعة"}, "reminderSuccess": {"en": "The reminder has been added successfully", "ar": "تمت إضافة التذكير بنجاح"}, + "reminderCancelSuccess": {"en": "The reminder has been cancelled successfully", "ar": "تم إلغاء التذكير بنجاح"}, "patientShareToDo": {"en": "Amount before tax: ", "ar": "المبلغ قبل الضريبة:"}, "patientTaxToDo": {"en": "Tax amount: ", "ar": "قيمة الضريبة:"}, "patientShareTotalToDo": {"en": "Total amount Due: ", "ar": "المبلغ الإجمالي المستحق:"}, @@ -449,6 +450,7 @@ const Map localizedValues = { "Frequency": {"en": "Frequency", "ar": "المعدل"}, "DailyQuantity": {"en": "Daily Quantity :", "ar": "جرعات يومية"}, "AddReminder": {"en": "Add Reminder", "ar": "إضافة تذكير"}, + "CancelReminder": {"en": "Cancel Reminder", "ar": "إلغاء تذكير"}, "reminderDes": { "en": "Please select treatment start day and time to be notified when it\'s time to take the medicine", "ar": "يرجى تحديد يوم بدء العلاج والوقت ليتم ارسال تنبيه عندما يحين الوقت لتناول الدواء" diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 1f6ca580..9603605c 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -122,10 +122,10 @@ class BaseAppClient { } } - // body['IdentificationNo'] = 1009199553; - // body['MobileNo'] = "966545156035"; - // body['PatientID'] = 1018977; //3844083 - // body['TokenID'] = "@dm!n"; + body['IdentificationNo'] = 1009199553; + body['MobileNo'] = "966545156035"; + body['PatientID'] = 1018977; //3844083 + body['TokenID'] = "@dm!n"; body.removeWhere((key, value) => key == null || value == null); diff --git a/lib/pages/medical/prescriptions/prescription_details_page.dart b/lib/pages/medical/prescriptions/prescription_details_page.dart index d20fbe87..6460e87c 100644 --- a/lib/pages/medical/prescriptions/prescription_details_page.dart +++ b/lib/pages/medical/prescriptions/prescription_details_page.dart @@ -1,15 +1,17 @@ +import 'dart:collection'; + +import 'package:device_calendar/device_calendar.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; 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/CalendarUtils.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/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; @@ -23,12 +25,25 @@ import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; import 'package:provider/provider.dart'; -class PrescriptionDetailsPage extends StatelessWidget { +class PrescriptionDetailsPage extends StatefulWidget { final PrescriptionReport prescriptionReport; final Prescriptions prescriptions; PrescriptionDetailsPage({Key key, this.prescriptionReport, this.prescriptions}); + @override + _PrescriptionDetailsPageState createState() => _PrescriptionDetailsPageState(); +} + +class _PrescriptionDetailsPageState extends State { + bool hasReminder = false; + + @override + void initState() { + checkIfHasReminder(); + super.initState(); + } + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -42,18 +57,18 @@ class PrescriptionDetailsPage extends StatelessWidget { children: [ DoctorHeader( headerModel: HeaderModel( - prescriptions.doctorName, - prescriptions.doctorID, - prescriptions.doctorImageURL, - prescriptions.speciality, + widget.prescriptions.doctorName, + widget.prescriptions.doctorID, + widget.prescriptions.doctorImageURL, + widget.prescriptions.speciality, "", - prescriptions.name, - DateUtil.convertStringToDate(prescriptions.appointmentDate), - DateUtil.formatDateToTime(DateUtil.convertStringToDate(prescriptions.appointmentDate)), - prescriptions.nationalityFlagURL, - prescriptions.doctorRate, - prescriptions.actualDoctorRate, - prescriptions.noOfPatientsRate, + widget.prescriptions.name, + DateUtil.convertStringToDate(widget.prescriptions.appointmentDate), + DateUtil.formatDateToTime(DateUtil.convertStringToDate(widget.prescriptions.appointmentDate)), + widget.prescriptions.nationalityFlagURL, + widget.prescriptions.doctorRate, + widget.prescriptions.actualDoctorRate, + widget.prescriptions.noOfPatientsRate, "", ), isNeedToShowButton: false, @@ -104,7 +119,7 @@ class PrescriptionDetailsPage extends StatelessWidget { children: [ Container( child: Image.network( - prescriptionReport.imageSRCUrl, + widget.prescriptionReport.imageSRCUrl, fit: BoxFit.cover, width: 48, height: 49, @@ -125,13 +140,15 @@ class PrescriptionDetailsPage extends StatelessWidget { ], ), onTap: () { - showZoomImageDialog(context, prescriptionReport.imageSRCUrl); + showZoomImageDialog(context, widget.prescriptionReport.imageSRCUrl); }, ), SizedBox(width: 12), Expanded( child: Text( - (prescriptionReport.itemDescription.isNotEmpty ? prescriptionReport.itemDescription : prescriptionReport.itemDescriptionN ?? '').toLowerCase().capitalizeFirstofEach, + (widget.prescriptionReport.itemDescription.isNotEmpty ? widget.prescriptionReport.itemDescription : widget.prescriptionReport.itemDescriptionN ?? '') + .toLowerCase() + .capitalizeFirstofEach, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), ), ) @@ -149,10 +166,10 @@ class PrescriptionDetailsPage extends StatelessWidget { ), TableRow( children: [ - Utils.tableColumnValue(prescriptionReport?.routeN ?? '', isLast: true, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(prescriptionReport?.frequencyN ?? '', isLast: true, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(prescriptionReport?.doseDailyQuantity.toString() ?? '', isLast: true, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(prescriptionReport?.days.toString() ?? '', isLast: true, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(widget.prescriptionReport?.routeN ?? '', isLast: true, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(widget.prescriptionReport?.frequencyN ?? '', isLast: true, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(widget.prescriptionReport?.doseDailyQuantity.toString() ?? '', isLast: true, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(widget.prescriptionReport?.days.toString() ?? '', isLast: true, mProjectViewModel: projectViewModel), ], ), ]), @@ -161,7 +178,7 @@ class PrescriptionDetailsPage extends StatelessWidget { style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48), ), Text( - prescriptionReport.remarks, + widget.prescriptionReport.remarks, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), ), ], @@ -184,8 +201,8 @@ class PrescriptionDetailsPage extends StatelessWidget { context, FadePage( page: PharmacyForPrescriptionsPage( - itemID: prescriptionReport.itemID, - prescriptionReport: prescriptionReport, + itemID: widget.prescriptionReport.itemID, + prescriptionReport: widget.prescriptionReport, ), ), ); @@ -197,31 +214,35 @@ class PrescriptionDetailsPage extends StatelessWidget { SizedBox(width: 10), Expanded( child: DefaultButton( - TranslationBase.of(context).addReminder, + hasReminder ? TranslationBase.of(context).cancelReminder : 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); - }, - onMultiDateSuccess: (int selectedIndex) { - setCalender(context, prescriptionReport.itemID.toString(), selectedIndex); - }, - ); - return; + if (hasReminder) { + cancelReminders(); + } else { + DateTime startDate = DateTime.now(); + DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + widget.prescriptionReport.days); + showReminderDialog( + context, + endDate, + "", + widget.prescriptionReport.itemID.toString(), + "", + "", + title: "${widget.prescriptionReport.itemDescriptionN} Prescription Reminder", + description: "${widget.prescriptionReport.itemDescriptionN} ${widget.prescriptionReport.frequencyN} ${widget.prescriptionReport.routeN} ", + onSuccess: () { + AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); + }, + onMultiDateSuccess: (int selectedIndex) { + setCalender(context, widget.prescriptionReport.itemID.toString(), selectedIndex); + }, + ); + return; + } }, iconData: Icons.notifications_active, color: Color(0xffD02127), + fontSize: 13.0, //textColor: Color(0xff2B353E), ), ), @@ -233,16 +254,58 @@ class PrescriptionDetailsPage extends StatelessWidget { ); } + checkIfHasReminder() async { + CalendarUtils calendarUtils = await CalendarUtils.getInstance(); + + DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30); + DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120); + + RetrieveEventsParams params = new RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate); + + await calendarUtils.retrieveEvents(calendarUtils.calendars[0].id, params).then((value) { + Result> events = value; + events.data.forEach((element) { + if (element.title.contains(widget.prescriptionReport.itemDescriptionN)) + setState(() { + hasReminder = true; + }); + }); + }); + print("Has Reminder: " + hasReminder.toString()); + } + + cancelReminders() async { + CalendarUtils calendarUtils = await CalendarUtils.getInstance(); + + DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30); + DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120); + + RetrieveEventsParams params = new RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate); + + await calendarUtils.retrieveEvents(calendarUtils.calendars[0].id, params).then((value) { + Result> events = value; + events.data.forEach((element) { + if (element.title.contains(widget.prescriptionReport.itemDescriptionN)) calendarUtils.deleteEvent(calendarUtils.calendars[0], element); + }); + }); + AppToast.showSuccessToast(message: TranslationBase.of(context).reminderCancelSuccess); + setState(() { + hasReminder = false; + }); + } + setCalender(BuildContext context, String eventId, int reminderIndex) async { CalendarUtils calendarUtils = await CalendarUtils.getInstance(); - DateTime startDate = DateUtil.convertStringToDate(prescriptionReport.startDate); + DateTime startDate = DateUtil.convertStringToDate(widget.prescriptionReport.startDate); DateTime actualDate = DateTime(startDate.year, startDate.month, startDate.day, 8, 0); //Time will start at 8:00 AM from starting date - if (prescriptionReport?.frequencyNumber == null) prescriptionReport.frequencyNumber = 2; //Some time frequency number is null so by default will be 2 + if (widget.prescriptionReport?.frequencyNumber == null) widget.prescriptionReport.frequencyNumber = 1; //Some time frequency number is null so by default will be 2 + + GifLoaderDialogUtils.showMyDialog(context); - for (int i = 0; i < prescriptionReport.days; i++) { + for (int i = 0; i < widget.prescriptionReport.days; i++) { //event for number of days. - for (int j = 0; j < prescriptionReport.frequencyNumber ?? 2; j++) { + for (int j = 0; j < widget.prescriptionReport.frequencyNumber ?? 1; j++) { // event for number of times per day. if (j != 0) { @@ -269,38 +332,21 @@ class PrescriptionDetailsPage extends StatelessWidget { } calendarUtils .createOrUpdateEvent( - title: "${prescriptionReport.itemDescriptionN} Prescription Reminder", - description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ", + title: "${widget.prescriptionReport.itemDescriptionN} Prescription Reminder", + description: "${widget.prescriptionReport.itemDescriptionN} ${widget.prescriptionReport.frequencyN} ${widget.prescriptionReport.routeN} ", scheduleDateTime: actualDate, eventId: eventId + (i.toString() + j.toString()), //event id with varitions ) - .then( - (value) {}, - ); + .then((value) {}); + actualDate = DateTime(actualDate.year, actualDate.month, actualDate.day, 8, 0); } - actualDate.add(new Duration(days: i + 1)); + actualDate = Jiffy(actualDate).add(days: 1); + print(actualDate); } AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); + GifLoaderDialogUtils.hideDialog(context); + setState(() { + hasReminder = true; + }); } - - //schedual local notifications - // 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); - // } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index fb13232b..b04cbd93 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2789,8 +2789,9 @@ class TranslationBase { String get gr => localizedValues["gr"][locale.languageCode]; String get gramsPerMeal => localizedValues["gramsPerMeal"][locale.languageCode]; + String get cancelReminder => localizedValues["CancelReminder"][locale.languageCode]; - + String get reminderCancelSuccess => localizedValues["reminderCancelSuccess"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { From ab7162f16401a13271d34ca851e1a46bcf6e401b Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 15 Nov 2021 16:21:36 +0300 Subject: [PATCH 3/3] Base app client updates --- lib/core/service/client/base_app_client.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 9603605c..1f6ca580 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -122,10 +122,10 @@ class BaseAppClient { } } - body['IdentificationNo'] = 1009199553; - body['MobileNo'] = "966545156035"; - body['PatientID'] = 1018977; //3844083 - body['TokenID'] = "@dm!n"; + // body['IdentificationNo'] = 1009199553; + // body['MobileNo'] = "966545156035"; + // body['PatientID'] = 1018977; //3844083 + // body['TokenID'] = "@dm!n"; body.removeWhere((key, value) => key == null || value == null);