active medication design revamped

merge-update-with-lab-changes
haroon amjad 5 years ago
parent bf4709fef6
commit ad3463bbfc

@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/medical/active_medications/reminder_p
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.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/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
@ -20,123 +21,184 @@ class ActiveMedicationsPage extends StatelessWidget {
isShowAppBar: true, isShowAppBar: true,
showNewAppBar: true, showNewAppBar: true,
showNewAppBarTitle: true, showNewAppBarTitle: true,
isShowDecPage: false, isShowDecPage: true,
baseViewModel: model, baseViewModel: model,
appBarTitle: TranslationBase.of(context).activeMedications, appBarTitle: TranslationBase.of(context).activeMedications,
body: Container( body: Container(
child: ListView.builder( child: ListView.builder(
itemCount: model.activePrescriptionReport.length, itemCount: model.activePrescriptionReport.length,
itemBuilder: (context, index) => Container( itemBuilder: (context, index) => Container(
padding: EdgeInsets.all(10), width: double.infinity,
margin: EdgeInsets.all(10), child: Card(
decoration: BoxDecoration( margin: EdgeInsets.only(left: 16, right: 16, top: index == 0 ? 16 : 4, bottom: 4),
borderRadius: BorderRadius.circular(8), color: Colors.white), shape: cardRadius(12),
child: Row( 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,
),
),
mHeight(10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Image.memory( Row(
Utils.dataFromBase64String(model children: [
.activePrescriptionReport[index].productImageBase64), Container(
child: Card(
child: Image.memory(
Utils.dataFromBase64String(model.activePrescriptionReport[index].productImageBase64),
fit: BoxFit.cover,
height: SizeConfig.imageSizeMultiplier * 19, height: SizeConfig.imageSizeMultiplier * 19,
width: SizeConfig.imageSizeMultiplier * 18, width: SizeConfig.imageSizeMultiplier * 18,
fit: BoxFit.cover,
), ),
Expanded( margin: EdgeInsets.zero,
child: Column( clipBehavior: Clip.antiAlias,
shape: cardRadius(2000),
),
clipBehavior: Clip.antiAlias,
decoration: containerColorRadiusBorderWidth(Colors.white, 200, Colors.grey[200], 1),
),
mWidth(12),
Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Texts( Row(
model.activePrescriptionReport[index].itemDescription, children: [
bold: true, Text(
TranslationBase.of(context).expiryDateTitle + ": ",
style: TextStyle(
color: Colors.grey,
fontSize: 12,
letterSpacing: -0.4,
fontWeight: FontWeight.w600,
), ),
SizedBox(
height: 5,
), ),
Texts( Text(
TranslationBase.of(context).expDate + DateUtil.getDayMonthYearDateFormatted(model.activePrescriptionReport[index].orderDate),
' :' + style: TextStyle(
DateUtil.getDayMonthYearDateFormatted(model fontSize: 13,
.activePrescriptionReport[index].orderDate), letterSpacing: -0.48,
fontWeight: FontWeight.w600,
), ),
SizedBox(
height: 5,
), ),
Texts( ],
TranslationBase.of(context).route +
' :' +
model.activePrescriptionReport[index].route,
), ),
SizedBox( Row(
height: 5, children: [
Text(
TranslationBase.of(context).frequency + ": ",
style: TextStyle(
color: Colors.grey,
fontSize: 12,
letterSpacing: -0.4,
fontWeight: FontWeight.w600,
), ),
Texts( ),
TranslationBase.of(context).frequency + Text(
' :' +
model.activePrescriptionReport[index].frequency, model.activePrescriptionReport[index].frequency,
style: TextStyle(
fontSize: 13,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
), ),
SizedBox(
height: 5,
),
Texts(
TranslationBase.of(context).dailyQuantity +
' :${model.activePrescriptionReport[index].doseDailyQuantity}',
), ),
], ],
), ),
Row(
children: [
Text(
TranslationBase.of(context).route + ": ",
style: TextStyle(
color: Colors.grey,
fontSize: 12,
letterSpacing: -0.4,
fontWeight: FontWeight.w600,
), ),
Container( ),
child: Column( Text(
crossAxisAlignment: CrossAxisAlignment.center, model.activePrescriptionReport[index].route,
mainAxisAlignment: MainAxisAlignment.spaceBetween, style: TextStyle(
fontSize: 13,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
),
),
],
),
Row(
children: [ children: [
Icon( Text(
Icons.notifications, TranslationBase.of(context).dailyDoses + ": ",
color: Colors.red, style: TextStyle(
size: 28, color: Colors.grey,
fontSize: 12,
letterSpacing: -0.4,
fontWeight: FontWeight.w600,
), ),
SizedBox(
height: 25,
), ),
InkWell( Text(
model.activePrescriptionReport[index].doseDailyQuantity.toString(),
style: TextStyle(
fontSize: 13,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
),
),
],
),
mHeight(12),
],
),
],
),
Container(
child: InkWell(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: ReminderPage( page: ReminderPage(
frequency: model frequency: model.activePrescriptionReport[index].frequencyNumber,
.activePrescriptionReport[index] days: model.activePrescriptionReport[index].days,
.frequencyNumber, itemDescription: model.activePrescriptionReport[index].itemDescription,
days: model
.activePrescriptionReport[index].days,
itemDescription: model
.activePrescriptionReport[index]
.itemDescription,
), ),
), ),
); );
}, },
child: Row( child: Column(
children: [ children: [
Icon( Icon(
Icons.notifications_active, Icons.notifications_outlined,
color: Colors.red, color: Colors.red,
size: 28, size: 28,
), ),
Texts( Texts(
TranslationBase.of(context).addReminder, TranslationBase.of(context).addReminder,
color: Colors.red, color: Colors.red,
fontSize: 11.0,
) )
], ],
), ),
) ),
),
], ],
), ),
)
], ],
), ),
), ),
), ),
), ),
), ),
),
),
); );
} }
} }

@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart'; import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -22,15 +23,7 @@ class ReminderPage extends StatefulWidget {
final String itemDescription; final String itemDescription;
List<DateTime> _scheduleList = List(); List<DateTime> _scheduleList = List();
List<DayOfWeek> daysOfWeek = [ List<DayOfWeek> daysOfWeek = [DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday];
DayOfWeek.Monday,
DayOfWeek.Tuesday,
DayOfWeek.Wednesday,
DayOfWeek.Thursday,
DayOfWeek.Friday,
DayOfWeek.Saturday,
DayOfWeek.Sunday
];
DateTime startDay; DateTime startDay;
DateTime endDay; DateTime endDay;
@ -41,8 +34,7 @@ class ReminderPage extends StatefulWidget {
int hour = (24 ~/ frequency).round(); int hour = (24 ~/ frequency).round();
int durations = 24 ~/ hour; int durations = 24 ~/ hour;
for (int count = 0; count < durations; count++) { for (int count = 0; count < durations; count++) {
_scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, _scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, (hour * count)));
DateTime.now().day, (hour * count)));
} }
} }
@ -59,6 +51,9 @@ class _ReminderPageState extends State<ReminderPage> {
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
isShowAppBar: true, isShowAppBar: true,
showNewAppBar: true,
showNewAppBarTitle: true,
isShowDecPage: false,
appBarTitle: TranslationBase.of(context).reminder, appBarTitle: TranslationBase.of(context).reminder,
body: SingleChildScrollView( body: SingleChildScrollView(
child: Container( child: Container(
@ -68,7 +63,7 @@ class _ReminderPageState extends State<ReminderPage> {
children: [ children: [
Container( Container(
width: double.maxFinite, width: double.maxFinite,
child: Texts(TranslationBase.of(context).reminderDes), child: Texts(TranslationBase.of(context).reminderDes, textAlign: TextAlign.start),
), ),
Divider(), Divider(),
SizedBox( SizedBox(
@ -80,25 +75,17 @@ class _ReminderPageState extends State<ReminderPage> {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
DatePicker.showDatePicker(context, DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year, DateTime.now().month - 1, 1), maxTime: DateTime.now(), onConfirm: (date) {
showTitleActions: true,
minTime: DateTime(
DateTime.now().year, DateTime.now().month - 1, 1),
maxTime: DateTime.now(), onConfirm: (date) {
setState(() { setState(() {
widget.startDay = date; widget.startDay = date;
}); });
}, }, currentTime: widget.startDay, locale: projectViewModel.localeType);
currentTime: widget.startDay,
locale: projectViewModel.localeType);
}, },
child: Container( child: Container(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
width: double.infinity, width: double.infinity,
height: 65, height: 65,
decoration: BoxDecoration( decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -120,25 +107,17 @@ class _ReminderPageState extends State<ReminderPage> {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
DatePicker.showDatePicker(context, DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year, DateTime.now().month - 1, 1), maxTime: DateTime.now(), onConfirm: (date) {
showTitleActions: true,
minTime: DateTime(
DateTime.now().year, DateTime.now().month - 1, 1),
maxTime: DateTime.now(), onConfirm: (date) {
setState(() { setState(() {
widget.endDay = date; widget.endDay = date;
}); });
}, }, currentTime: widget.endDay, locale: projectViewModel.localeType);
currentTime: widget.endDay,
locale: projectViewModel.localeType);
}, },
child: Container( child: Container(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
width: double.infinity, width: double.infinity,
height: 65, height: 65,
decoration: BoxDecoration( decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -163,10 +142,7 @@ class _ReminderPageState extends State<ReminderPage> {
child: Container( child: Container(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
width: double.infinity, 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( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -196,28 +172,21 @@ class _ReminderPageState extends State<ReminderPage> {
), ),
InkWell( InkWell(
onTap: () { onTap: () {
DatePicker.showTimePicker(context, DatePicker.showTimePicker(context, showTitleActions: true, onConfirm: (date) {
showTitleActions: true, onConfirm: (date) {
setState(() { setState(() {
widget._scheduleList[index] = date; widget._scheduleList[index] = date;
}); });
}, }, currentTime: widget._scheduleList[index], locale: projectViewModel.localeType);
currentTime: widget._scheduleList[index],
locale: projectViewModel.localeType);
}, },
child: Container( child: Container(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
width: double.infinity, width: double.infinity,
height: 65, height: 65,
decoration: BoxDecoration( decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [ children: [
Texts(getDateTime( Texts(getDateTime(widget._scheduleList[index])),
widget._scheduleList[index])),
Icon( Icon(
Icons.access_time, Icons.access_time,
color: Colors.black, color: Colors.black,
@ -238,29 +207,29 @@ class _ReminderPageState extends State<ReminderPage> {
), ),
bottomSheet: Container( bottomSheet: Container(
width: double.infinity, width: double.infinity,
height: MediaQuery.of(context).size.height * 0.2, color: Theme.of(context).scaffoldBackgroundColor,
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: Column( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min,
children: [ children: [
SecondaryButton( Expanded(
label: TranslationBase.of(context).ok, child: DefaultButton(
color: Colors.grey[800], TranslationBase.of(context).ok.toUpperCase(),
textColor: Colors.white, () {
onTap: () {
schedule(); schedule();
}, },
color: Color(0xff359846),
), ),
SizedBox(
height: 15,
), ),
SecondaryButton( SizedBox(width: 10),
label: TranslationBase.of(context).cancel, Expanded(
color: Colors.red[800], child: DefaultButton(
textColor: Colors.white, TranslationBase.of(context).cancel,
onTap: () { () {
Navigator.pop(context); Navigator.pop(context);
}, },
color: Color(0xffC5272D),
),
), ),
], ],
), ),
@ -270,16 +239,11 @@ class _ReminderPageState extends State<ReminderPage> {
} }
schedule() async { schedule() async {
List<DateTime> scheduleDateTime = List<DateTime> scheduleDateTime = calculateDaysInterval(widget.startDay, widget.endDay);
calculateDaysInterval(widget.startDay, widget.endDay);
CalendarUtils calendarUtils = await CalendarUtils.getInstance(); CalendarUtils calendarUtils = await CalendarUtils.getInstance();
calendarUtils.createOrUpdateEvents( calendarUtils.createOrUpdateEvents(scheduleList: widget._scheduleList, description: widget.itemDescription, title: widget.itemDescription, scheduleDateTime: scheduleDateTime);
scheduleList: widget._scheduleList,
description: widget.itemDescription,
title: widget.itemDescription,
scheduleDateTime: scheduleDateTime);
Navigator.pop(context); Navigator.pop(context);
} }
@ -288,8 +252,7 @@ class _ReminderPageState extends State<ReminderPage> {
List<DateTime> days = []; List<DateTime> days = [];
for (int i = 0; i <= endDate.difference(startDate).inDays; i++) { for (int i = 0; i <= endDate.difference(startDate).inDays; i++) {
widget._scheduleList.forEach((element) { widget._scheduleList.forEach((element) {
days.add(startDate.add( days.add(startDate.add(Duration(days: i, hours: element.hour, minutes: element.minute)));
Duration(days: i, hours: element.hour, minutes: element.minute)));
}); });
} }
return days; return days;

Loading…
Cancel
Save