active medication design revamped

merge-requests/400/head
haroon amjad 3 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/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,
)
],
),
),
),
],
),
],
),
),
),
),
),

@ -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<DateTime> _scheduleList = List();
List<DayOfWeek> daysOfWeek = [
DayOfWeek.Monday,
DayOfWeek.Tuesday,
DayOfWeek.Wednesday,
DayOfWeek.Thursday,
DayOfWeek.Friday,
DayOfWeek.Saturday,
DayOfWeek.Sunday
];
List<DayOfWeek> 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<ReminderPage> {
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<ReminderPage> {
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<ReminderPage> {
),
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<ReminderPage> {
),
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<ReminderPage> {
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<ReminderPage> {
),
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<ReminderPage> {
),
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<ReminderPage> {
}
schedule() async {
List<DateTime> scheduleDateTime =
calculateDaysInterval(widget.startDay, widget.endDay);
List<DateTime> 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<ReminderPage> {
List<DateTime> 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;

Loading…
Cancel
Save