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,118 +21,179 @@ 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(
children: [ padding: const EdgeInsets.only(top: 12, bottom: 20, left: 20, right: 20),
Image.memory( child: Column(
Utils.dataFromBase64String(model crossAxisAlignment: CrossAxisAlignment.start,
.activePrescriptionReport[index].productImageBase64), children: [
height: SizeConfig.imageSizeMultiplier * 19, Text(
width: SizeConfig.imageSizeMultiplier * 18, model.activePrescriptionReport[index].itemDescription,
fit: BoxFit.cover, style: TextStyle(
), fontSize: 16,
Expanded( letterSpacing: -0.64,
child: Column( fontWeight: FontWeight.w600,
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}',
), ),
], ),
), mHeight(10),
), Row(
Container( mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.center, Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
children: [ Container(
Icon( child: Card(
Icons.notifications, child: Image.memory(
color: Colors.red, Utils.dataFromBase64String(model.activePrescriptionReport[index].productImageBase64),
size: 28, fit: BoxFit.cover,
), height: SizeConfig.imageSizeMultiplier * 19,
SizedBox( width: SizeConfig.imageSizeMultiplier * 18,
height: 25, ),
), margin: EdgeInsets.zero,
InkWell( clipBehavior: Clip.antiAlias,
onTap: () { shape: cardRadius(2000),
Navigator.push(
context,
FadePage(
page: ReminderPage(
frequency: model
.activePrescriptionReport[index]
.frequencyNumber,
days: model
.activePrescriptionReport[index].days,
itemDescription: model
.activePrescriptionReport[index]
.itemDescription,
), ),
clipBehavior: Clip.antiAlias,
decoration: containerColorRadiusBorderWidth(Colors.white, 200, Colors.grey[200], 1),
), ),
); mWidth(12),
}, Column(
child: Row( crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Icon( Row(
Icons.notifications_active, children: [
color: Colors.red, Text(
size: 28, 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,
)
],
),
),
),
],
),
],
),
),
), ),
), ),
), ),

@ -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