active medication

fatima
Fatimah.Alshammari 2 months ago
parent dbe67834b8
commit e8319a0d3f

@ -0,0 +1,682 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import '../../core/app_assets.dart';
import '../../core/utils/utils.dart';
import '../../generated/locale_keys.g.dart';
import '../../theme/colors.dart';
import '../../widgets/appbar/app_bar_widget.dart';
import 'package:intl/intl.dart';
import '../../widgets/buttons/custom_button.dart';
import '../../widgets/chip/app_custom_chip_widget.dart'; // for date formatting
class ActiveMedicationPage extends StatefulWidget {
@override
State<ActiveMedicationPage> createState() => _ActiveMedicationPageState();
}
class _ActiveMedicationPageState extends State<ActiveMedicationPage> {
late DateTime currentDate;
late DateTime selectedDate;
// Info for each day (customizable)
final Map<int, Map<String, dynamic>> dayInfo = {
0: {"text": "Medications", "icon": Icons.medication_outlined, "description": "Affected"},
1: {"text": "Doctor Appointment", "icon": Icons.local_hospital_outlined, "description": "Twice"},
2: {"text": "Rest Day", "icon": Icons.self_improvement_outlined, "description": "Daily"},
3: {"text": "Gym Session", "icon": Icons.fitness_center_outlined, "description": "Affected"},
4: {"text": "Meeting", "icon": Icons.meeting_room_outlined, "description": "Twice"},
5: {"text": "Shopping", "icon": Icons.shopping_bag_outlined, "description": "Daily"},
6: {"text": "Family Time", "icon": Icons.family_restroom_outlined, "description": "Affected"},
};
@override
void initState() {
super.initState();
currentDate = DateTime.now();
selectedDate = currentDate;
}
// Generate today + next 6 days
List<DateTime> getUpcomingDays() {
return List.generate(7, (index) => currentDate.add(Duration(days: index)));
}
@override
Widget build(BuildContext context) {
List<DateTime> days = getUpcomingDays();
int dayIndex = selectedDate.difference(currentDate).inDays;
String dateText =
"${selectedDate.day}${getSuffix(selectedDate.day)} ${DateFormat.MMMM().format(selectedDate)} ";
String infoMed = dayInfo[dayIndex]?["text"] ?? "No Info";
IconData infoImg= dayInfo[dayIndex]?["icon"] ?? Icons.info_outline;
String medDetails = dayInfo[dayIndex]?["description"] ?? "No Info";
return Scaffold(
backgroundColor: AppColors.scaffoldBgColor,
appBar: CustomAppBar(
onBackPressed: () {
Navigator.of(context).pop();
},
onLanguageChanged: (lang) {},
hideLogoAndLang: true,
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 65,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: days.length,
itemBuilder: (context, index) {
DateTime day = days[index];
String label = DateFormat('E').format(day); // Mon, Tue
return Padding(
padding: const EdgeInsets.only(right: 12),
child: buildDayCard(label, day),
);
},
),
),
const SizedBox(height: 20),
// Show full date text
Text(
dateText,
style: TextStyle(
color: AppColors.textColor,
fontSize: 16,
fontWeight: FontWeight.w500),
),
const Text(
"Medications",
style: TextStyle(
color: AppColors.primaryRedBorderColor,fontSize: 12, fontWeight: FontWeight.w500),
),
const SizedBox(height: 16),
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24,
hasShadow: true,),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(1),
child: Container(
width: 59,
height: 59,
decoration: BoxDecoration(
border: Border.all(
color: AppColors.spacerLineColor,// Border color
width: 1.0, ),
borderRadius: BorderRadius.circular(30),// Border width
),
child:
Icon(infoImg, size: 26),
// Utils.buildSvgWithAssets(icon: AppAssets.home_calendar_icon,width: 30.h, height: 30.h)
),
),
const SizedBox(width: 12),
Text(
infoMed,
style: TextStyle(
fontSize: 16,
height: 1.2,
fontWeight: FontWeight.w700,
color: Colors.black87),
),
],
),
const SizedBox(height: 12),
Wrap(
direction: Axis.horizontal,
spacing: 4.h,
runSpacing: 4.h,
children: [
AppCustomChipWidget(
labelText: "Route: $medDetails",
),
AppCustomChipWidget(
labelText: "Frequency: $medDetails",
),
AppCustomChipWidget(
labelText: "Daily Does $medDetails",
),
AppCustomChipWidget(
labelText: "Duration: $medDetails ",
),
],
),
const SizedBox(height: 12),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.info_outline, color: Colors.grey,),
const SizedBox(width: 8),
Expanded(
child: Text(
"Remark: some remarks about the prescription will be here",
style: TextStyle(
fontSize: 10,
color: AppColors.greyTextColor,
fontWeight: FontWeight.w500,
),
overflow: TextOverflow.visible,
),
)
],
),
],
).paddingAll(16),
const Divider(
indent: 0,
endIndent: 0,
thickness: 1,
color: AppColors.greyColor,
),
// Reminder Row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppColors.greyColor,
borderRadius: BorderRadius.circular(10),// Border width
),
child: Icon(Icons.notifications_sharp, color: AppColors.greyTextColor)),
const SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Set Reminder",
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14,
color: AppColors.textColor),
),
const Text(
"Notify me before the consumption time",
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 12,
color: AppColors.textColorLight),
),
],
),
],
),
// Switch(
// value: isActiveReminder,
// onChanged: (_) {},
// activeColor: Colors.green,
// ),
],
).paddingOnly(left:16, right: 16),
const Divider(
indent: 0,
endIndent: 0,
thickness: 1,
color: AppColors.greyColor,
),
// Buttons
Row(
children: [
Expanded(
child: CustomButton(
text: LocaleKeys.checkAvailability.tr(),
fontSize: 14,
onPressed: () async {
},
backgroundColor: AppColors.secondaryLightRedColor,
borderColor: AppColors.secondaryLightRedColor,
textColor: AppColors.errorColor,
),
),
const SizedBox(width: 12),
Expanded(
child: CustomButton(
text: LocaleKeys.readInstructions.tr(),
fontSize: 14,
onPressed: () async {
},
backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedColor,
textColor: AppColors.whiteColor,
),
),
],
).paddingAll(16),
],
),
)
// Expanded(
// child: ListView(
// children: [
// Container(
// decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24,
// hasShadow: true,),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Row(
// children: [
// ClipRRect(
// borderRadius: BorderRadius.circular(1),
// child: Container(
// width: 59,
// height: 59,
// decoration: BoxDecoration(
// border: Border.all(
// color: AppColors.spacerLineColor,// Border color
// width: 1.0, ),
// borderRadius: BorderRadius.circular(30),// Border width
// ),
// child:
// Utils.buildSvgWithAssets(icon: AppAssets.home_calendar_icon,width: 30.h, height: 30.h)
// ),
// ),
// const SizedBox(width: 12),
// const Expanded(
// child: Text(
// "Diclofenac Diethylamine 1% Topical Gel",
// style: TextStyle(
// fontSize: 16,
// height: 1.2,
// fontWeight: FontWeight.w700,
// color: Colors.black87),
// ),
// ),
// ],
// ),
// const SizedBox(height: 12),
// Wrap(
// direction: Axis.horizontal,
// spacing: 4.h,
// runSpacing: 4.h,
// children: [
// AppCustomChipWidget(
// labelText: "Route: Affected Area ",
// ),
// AppCustomChipWidget(
// labelText: "Route: Affected Area ",
// ),
// AppCustomChipWidget(
// labelText: "Daily Does 2",
// ),
// AppCustomChipWidget(
// labelText: "Route: Affected Area ",
// ),
// ],
// ),
// const SizedBox(height: 12),
// Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Icon(Icons.info_outline, color: Colors.grey,),
// const SizedBox(width: 8),
// Expanded(
// child: Text(
// "Remark: some remarks about the prescription will be here",
// style: TextStyle(
// fontSize: 10,
// color: AppColors.greyTextColor,
// fontWeight: FontWeight.w500,
// ),
// overflow: TextOverflow.visible,
// ),
// )
// ],
// ),
// ],
// ).paddingAll(16),
// const Divider(
// indent: 0,
// endIndent: 0,
// thickness: 1,
// color: AppColors.greyColor,
// ),
// // Reminder Row
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Row(
// children: [
// Container(
// width: 40,
// height: 40,
// decoration: BoxDecoration(
// color: AppColors.greyColor,
// borderRadius: BorderRadius.circular(10),// Border width
// ),
// child: Icon(Icons.notifications_sharp, color: AppColors.greyTextColor)),
// const SizedBox(width: 8),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// const Text(
// "Set Reminder",
// style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14,
// color: AppColors.textColor),
// ),
// const Text(
// "Notify me before the consumption time",
// style: TextStyle(fontWeight: FontWeight.w500, fontSize: 12,
// color: AppColors.textColorLight),
// ),
// ],
// ),
// ],
// ),
// // Switch(
// // value: isActiveReminder,
// // onChanged: (_) {},
// // activeColor: Colors.green,
// // ),
// ],
// ).paddingOnly(left:16, right: 16),
// const Divider(
// indent: 0,
// endIndent: 0,
// thickness: 1,
// color: AppColors.greyColor,
// ),
//
// // Buttons
// Row(
// children: [
// Expanded(
// child: CustomButton(
// text: LocaleKeys.checkAvailability.tr(),
// fontSize: 14,
// onPressed: () async {
// },
// backgroundColor: AppColors.secondaryLightRedColor,
// borderColor: AppColors.secondaryLightRedColor,
// textColor: AppColors.errorColor,
// ),
// ),
// const SizedBox(width: 12),
// Expanded(
// child: CustomButton(
// text: LocaleKeys.readInstructions.tr(),
// fontSize: 14,
// onPressed: () async {
// },
// backgroundColor: AppColors.primaryRedColor,
// borderColor: AppColors.primaryRedColor,
// textColor: AppColors.whiteColor,
// ),
// ),
// ],
// ).paddingAll(16),
// ],
// ),
// )
// // MedicationCard(),
// // SizedBox(height: 16),
// // MedicationCard(isActiveReminder: true),
// ],
// ),
// ),
]
),
),
);
}
Widget buildDayCard(String label, DateTime date) {
bool isSelected = selectedDate.day == date.day &&
selectedDate.month == date.month &&
selectedDate.year == date.year;
return GestureDetector(
onTap: () {
setState(() {
selectedDate = date;
});
},
child: Container(
width: 57,
height: 65,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: isSelected ? AppColors.secondaryLightRedBorderColor: AppColors.transparent,
border: Border.all(
color: isSelected ? AppColors.primaryRedBorderColor : AppColors.spacerLineColor,
width: 1.0,
),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
date.day == currentDate.day ? "Today" : label,
style: TextStyle(
color: isSelected ? AppColors.primaryRedBorderColor : AppColors.greyTextColor,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 5),
Text(
date.day.toString(),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isSelected ? AppColors.primaryRedBorderColor : AppColors.textColor,
),
),
],
),
),
),
);
}
String getSuffix(int day) {
if (day == 1 || day == 21 || day == 31) return "st";
if (day == 2 || day == 22) return "nd";
if (day == 3 || day == 23) return "rd";
return "th";
}
}
class MedicationCard extends StatelessWidget {
final bool isActiveReminder;
const MedicationCard({super.key, this.isActiveReminder = false});
Color get primaryRed => const Color(0xFFE84B3A);
@override
Widget build(BuildContext context) {
return
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24,
hasShadow: true,),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(1),
child: Container(
width: 59,
height: 59,
decoration: BoxDecoration(
border: Border.all(
color: AppColors.spacerLineColor,// Border color
width: 1.0, ),
borderRadius: BorderRadius.circular(30),// Border width
),
child:
Utils.buildSvgWithAssets(icon: AppAssets.home_calendar_icon,width: 30.h, height: 30.h)
),
),
const SizedBox(width: 12),
const Expanded(
child: Text(
"Diclofenac Diethylamine 1% Topical Gel",
style: TextStyle(
fontSize: 16,
height: 1.2,
fontWeight: FontWeight.w700,
color: Colors.black87),
),
),
],
),
const SizedBox(height: 12),
Wrap(
direction: Axis.horizontal,
spacing: 4.h,
runSpacing: 4.h,
children: [
AppCustomChipWidget(
labelText: "Route: Affected Area ",
),
AppCustomChipWidget(
labelText: "Route: Affected Area ",
),
AppCustomChipWidget(
labelText: "Daily Does 2",
),
AppCustomChipWidget(
labelText: "Route: Affected Area ",
),
],
),
const SizedBox(height: 12),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.info_outline, color: Colors.grey,),
const SizedBox(width: 8),
Expanded(
child: Text(
"Remark: some remarks about the prescription will be here",
style: TextStyle(
fontSize: 10,
color: AppColors.greyTextColor,
fontWeight: FontWeight.w500,
),
overflow: TextOverflow.visible,
),
)
],
),
],
).paddingAll(16),
const Divider(
indent: 0,
endIndent: 0,
thickness: 1,
color: AppColors.greyColor,
),
// Reminder Row
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppColors.greyColor,
borderRadius: BorderRadius.circular(10),// Border width
),
child: Icon(Icons.notifications_sharp, color: AppColors.greyTextColor)),
const SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Set Reminder",
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 14,
color: AppColors.textColor),
),
const Text(
"Notify me before the consumption time",
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 12,
color: AppColors.textColorLight),
),
],
),
],
),
Switch(
value: isActiveReminder,
onChanged: (_) {},
activeColor: Colors.green,
),
],
).paddingOnly(left:16, right: 16),
const Divider(
indent: 0,
endIndent: 0,
thickness: 1,
color: AppColors.greyColor,
),
// Buttons
Row(
children: [
Expanded(
child: CustomButton(
text: LocaleKeys.checkAvailability.tr(),
fontSize: 14,
onPressed: () async {
},
backgroundColor: AppColors.secondaryLightRedColor,
borderColor: AppColors.secondaryLightRedColor,
textColor: AppColors.errorColor,
),
),
const SizedBox(width: 12),
Expanded(
child: CustomButton(
text: LocaleKeys.readInstructions.tr(),
fontSize: 14,
onPressed: () async {
},
backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedColor,
textColor: AppColors.whiteColor,
),
),
],
).paddingAll(16),
],
),
);
}
}

@ -44,6 +44,8 @@ import 'package:hmg_patient_app_new/widgets/routes/spring_page_route_builder.dar
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';
import 'package:provider/provider.dart';
import '../active_medication/active_medication_page.dart';
class LandingPage extends StatefulWidget {
const LandingPage({super.key});
@ -379,7 +381,14 @@ class _LandingPageState extends State<LandingPage> {
"Services".toText16(isBold: true),
Row(
children: [
"View all services".toText12(color: AppColors.primaryRedColor),
"View all services".toText12(color: AppColors.primaryRedColor).onPress(() {
Navigator.of(context)
.push(
CustomPageRoute(
page: ActiveMedicationPage(),
),
);
}),
SizedBox(width: 2.h),
Icon(Icons.arrow_forward_ios, color: AppColors.primaryRedColor, size: 10.h),
],

Loading…
Cancel
Save