From ad3463bbfc5edb9eb8585f698c8409bb386af1cd Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 28 Sep 2021 15:19:13 +0300 Subject: [PATCH] active medication design revamped --- .../ActiveMedicationsPage.dart | 262 +++++++++++------- .../active_medications/reminder_page.dart | 121 +++----- 2 files changed, 204 insertions(+), 179 deletions(-) diff --git a/lib/pages/medical/active_medications/ActiveMedicationsPage.dart b/lib/pages/medical/active_medications/ActiveMedicationsPage.dart index f27da2ef..1fd7a3e4 100644 --- a/lib/pages/medical/active_medications/ActiveMedicationsPage.dart +++ b/lib/pages/medical/active_medications/ActiveMedicationsPage.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/medical/active_medications/reminder_p import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -20,118 +21,179 @@ class ActiveMedicationsPage extends StatelessWidget { isShowAppBar: true, showNewAppBar: true, showNewAppBarTitle: true, - isShowDecPage: false, + isShowDecPage: true, baseViewModel: model, appBarTitle: TranslationBase.of(context).activeMedications, body: Container( child: ListView.builder( itemCount: model.activePrescriptionReport.length, itemBuilder: (context, index) => Container( - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), color: Colors.white), - child: Row( - children: [ - Image.memory( - Utils.dataFromBase64String(model - .activePrescriptionReport[index].productImageBase64), - height: SizeConfig.imageSizeMultiplier * 19, - width: SizeConfig.imageSizeMultiplier * 18, - fit: BoxFit.cover, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - model.activePrescriptionReport[index].itemDescription, - bold: true, - ), - SizedBox( - height: 5, - ), - Texts( - TranslationBase.of(context).expDate + - ' :' + - DateUtil.getDayMonthYearDateFormatted(model - .activePrescriptionReport[index].orderDate), - ), - SizedBox( - height: 5, - ), - Texts( - TranslationBase.of(context).route + - ' :' + - model.activePrescriptionReport[index].route, - ), - SizedBox( - height: 5, - ), - Texts( - TranslationBase.of(context).frequency + - ' :' + - model.activePrescriptionReport[index].frequency, - ), - SizedBox( - height: 5, - ), - Texts( - TranslationBase.of(context).dailyQuantity + - ' :${model.activePrescriptionReport[index].doseDailyQuantity}', + width: double.infinity, + child: Card( + margin: EdgeInsets.only(left: 16, right: 16, top: index == 0 ? 16 : 4, bottom: 4), + shape: cardRadius(12), + child: Padding( + padding: const EdgeInsets.only(top: 12, bottom: 20, left: 20, right: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + model.activePrescriptionReport[index].itemDescription, + style: TextStyle( + fontSize: 16, + letterSpacing: -0.64, + fontWeight: FontWeight.w600, ), - ], - ), - ), - Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Icon( - Icons.notifications, - color: Colors.red, - size: 28, - ), - SizedBox( - height: 25, - ), - InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: ReminderPage( - frequency: model - .activePrescriptionReport[index] - .frequencyNumber, - days: model - .activePrescriptionReport[index].days, - itemDescription: model - .activePrescriptionReport[index] - .itemDescription, + ), + mHeight(10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + child: Card( + child: Image.memory( + Utils.dataFromBase64String(model.activePrescriptionReport[index].productImageBase64), + fit: BoxFit.cover, + height: SizeConfig.imageSizeMultiplier * 19, + width: SizeConfig.imageSizeMultiplier * 18, + ), + margin: EdgeInsets.zero, + clipBehavior: Clip.antiAlias, + shape: cardRadius(2000), ), + clipBehavior: Clip.antiAlias, + decoration: containerColorRadiusBorderWidth(Colors.white, 200, Colors.grey[200], 1), ), - ); - }, - child: Row( - children: [ - Icon( - Icons.notifications_active, - color: Colors.red, - size: 28, + mWidth(12), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + TranslationBase.of(context).expiryDateTitle + ": ", + style: TextStyle( + color: Colors.grey, + fontSize: 12, + letterSpacing: -0.4, + fontWeight: FontWeight.w600, + ), + ), + Text( + DateUtil.getDayMonthYearDateFormatted(model.activePrescriptionReport[index].orderDate), + style: TextStyle( + fontSize: 13, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + Row( + children: [ + Text( + TranslationBase.of(context).frequency + ": ", + style: TextStyle( + color: Colors.grey, + fontSize: 12, + letterSpacing: -0.4, + fontWeight: FontWeight.w600, + ), + ), + Text( + model.activePrescriptionReport[index].frequency, + style: TextStyle( + fontSize: 13, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + Row( + children: [ + Text( + TranslationBase.of(context).route + ": ", + style: TextStyle( + color: Colors.grey, + fontSize: 12, + letterSpacing: -0.4, + fontWeight: FontWeight.w600, + ), + ), + Text( + model.activePrescriptionReport[index].route, + style: TextStyle( + fontSize: 13, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + Row( + children: [ + Text( + TranslationBase.of(context).dailyDoses + ": ", + style: TextStyle( + color: Colors.grey, + fontSize: 12, + letterSpacing: -0.4, + fontWeight: FontWeight.w600, + ), + ), + Text( + model.activePrescriptionReport[index].doseDailyQuantity.toString(), + style: TextStyle( + fontSize: 13, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + mHeight(12), + ], ), - Texts( - TranslationBase.of(context).addReminder, - color: Colors.red, - ) ], ), - ) - ], - ), - ) - ], + Container( + child: InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: ReminderPage( + frequency: model.activePrescriptionReport[index].frequencyNumber, + days: model.activePrescriptionReport[index].days, + itemDescription: model.activePrescriptionReport[index].itemDescription, + ), + ), + ); + }, + child: Column( + children: [ + Icon( + Icons.notifications_outlined, + color: Colors.red, + size: 28, + ), + Texts( + TranslationBase.of(context).addReminder, + color: Colors.red, + fontSize: 11.0, + ) + ], + ), + ), + ), + ], + ), + ], + ), + ), ), ), ), diff --git a/lib/pages/medical/active_medications/reminder_page.dart b/lib/pages/medical/active_medications/reminder_page.dart index 7980d941..ec5b5eba 100644 --- a/lib/pages/medical/active_medications/reminder_page.dart +++ b/lib/pages/medical/active_medications/reminder_page.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -22,15 +23,7 @@ class ReminderPage extends StatefulWidget { final String itemDescription; List _scheduleList = List(); - List daysOfWeek = [ - DayOfWeek.Monday, - DayOfWeek.Tuesday, - DayOfWeek.Wednesday, - DayOfWeek.Thursday, - DayOfWeek.Friday, - DayOfWeek.Saturday, - DayOfWeek.Sunday - ]; + List daysOfWeek = [DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday]; DateTime startDay; DateTime endDay; @@ -41,8 +34,7 @@ class ReminderPage extends StatefulWidget { int hour = (24 ~/ frequency).round(); int durations = 24 ~/ hour; for (int count = 0; count < durations; count++) { - _scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day, (hour * count))); + _scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, (hour * count))); } } @@ -59,6 +51,9 @@ class _ReminderPageState extends State { builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + isShowDecPage: false, appBarTitle: TranslationBase.of(context).reminder, body: SingleChildScrollView( child: Container( @@ -68,7 +63,7 @@ class _ReminderPageState extends State { children: [ Container( width: double.maxFinite, - child: Texts(TranslationBase.of(context).reminderDes), + child: Texts(TranslationBase.of(context).reminderDes, textAlign: TextAlign.start), ), Divider(), SizedBox( @@ -80,25 +75,17 @@ class _ReminderPageState extends State { ), InkWell( onTap: () { - DatePicker.showDatePicker(context, - showTitleActions: true, - minTime: DateTime( - DateTime.now().year, DateTime.now().month - 1, 1), - maxTime: DateTime.now(), onConfirm: (date) { + DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year, DateTime.now().month - 1, 1), maxTime: DateTime.now(), onConfirm: (date) { setState(() { widget.startDay = date; }); - }, - currentTime: widget.startDay, - locale: projectViewModel.localeType); + }, currentTime: widget.startDay, locale: projectViewModel.localeType); }, child: Container( padding: EdgeInsets.all(12), width: double.infinity, height: 65, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -120,25 +107,17 @@ class _ReminderPageState extends State { ), InkWell( onTap: () { - DatePicker.showDatePicker(context, - showTitleActions: true, - minTime: DateTime( - DateTime.now().year, DateTime.now().month - 1, 1), - maxTime: DateTime.now(), onConfirm: (date) { + DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year, DateTime.now().month - 1, 1), maxTime: DateTime.now(), onConfirm: (date) { setState(() { widget.endDay = date; }); - }, - currentTime: widget.endDay, - locale: projectViewModel.localeType); + }, currentTime: widget.endDay, locale: projectViewModel.localeType); }, child: Container( padding: EdgeInsets.all(12), width: double.infinity, height: 65, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -163,10 +142,7 @@ class _ReminderPageState extends State { child: Container( padding: EdgeInsets.all(12), width: double.infinity, - height: 65, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -196,28 +172,21 @@ class _ReminderPageState extends State { ), InkWell( onTap: () { - DatePicker.showTimePicker(context, - showTitleActions: true, onConfirm: (date) { + DatePicker.showTimePicker(context, showTitleActions: true, onConfirm: (date) { setState(() { widget._scheduleList[index] = date; }); - }, - currentTime: widget._scheduleList[index], - locale: projectViewModel.localeType); + }, currentTime: widget._scheduleList[index], locale: projectViewModel.localeType); }, child: Container( padding: EdgeInsets.all(12), width: double.infinity, height: 65, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(getDateTime( - widget._scheduleList[index])), + Texts(getDateTime(widget._scheduleList[index])), Icon( Icons.access_time, color: Colors.black, @@ -238,29 +207,29 @@ class _ReminderPageState extends State { ), bottomSheet: Container( width: double.infinity, - height: MediaQuery.of(context).size.height * 0.2, + color: Theme.of(context).scaffoldBackgroundColor, padding: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: Row( + mainAxisSize: MainAxisSize.min, children: [ - SecondaryButton( - label: TranslationBase.of(context).ok, - color: Colors.grey[800], - textColor: Colors.white, - onTap: () { - schedule(); - }, - ), - SizedBox( - height: 15, + Expanded( + child: DefaultButton( + TranslationBase.of(context).ok.toUpperCase(), + () { + schedule(); + }, + color: Color(0xff359846), + ), ), - SecondaryButton( - label: TranslationBase.of(context).cancel, - color: Colors.red[800], - textColor: Colors.white, - onTap: () { - Navigator.pop(context); - }, + SizedBox(width: 10), + Expanded( + child: DefaultButton( + TranslationBase.of(context).cancel, + () { + Navigator.pop(context); + }, + color: Color(0xffC5272D), + ), ), ], ), @@ -270,16 +239,11 @@ class _ReminderPageState extends State { } schedule() async { - List scheduleDateTime = - calculateDaysInterval(widget.startDay, widget.endDay); + List scheduleDateTime = calculateDaysInterval(widget.startDay, widget.endDay); CalendarUtils calendarUtils = await CalendarUtils.getInstance(); - calendarUtils.createOrUpdateEvents( - scheduleList: widget._scheduleList, - description: widget.itemDescription, - title: widget.itemDescription, - scheduleDateTime: scheduleDateTime); + calendarUtils.createOrUpdateEvents(scheduleList: widget._scheduleList, description: widget.itemDescription, title: widget.itemDescription, scheduleDateTime: scheduleDateTime); Navigator.pop(context); } @@ -288,8 +252,7 @@ class _ReminderPageState extends State { List days = []; for (int i = 0; i <= endDate.difference(startDate).inDays; i++) { widget._scheduleList.forEach((element) { - days.add(startDate.add( - Duration(days: i, hours: element.hour, minutes: element.minute))); + days.add(startDate.add(Duration(days: i, hours: element.hour, minutes: element.minute))); }); } return days;