You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
313 lines
17 KiB
Dart
313 lines
17 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
import 'package:hmg_patient_app_new/features/prescriptions/models/resp_models/patient_prescriptions_response_model.dart';
|
|
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart';
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
|
import 'package:hmg_patient_app_new/widgets/shimmer/movies_shimmer_widget.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class PrescriptionDetailPage extends StatefulWidget {
|
|
PrescriptionDetailPage({super.key, required this.prescriptionsResponseModel});
|
|
|
|
PatientPrescriptionsResponseModel prescriptionsResponseModel;
|
|
|
|
@override
|
|
State<PrescriptionDetailPage> createState() => _PrescriptionDetailPageState();
|
|
}
|
|
|
|
class _PrescriptionDetailPageState extends State<PrescriptionDetailPage> {
|
|
late PrescriptionsViewModel prescriptionsViewModel;
|
|
|
|
@override
|
|
void initState() {
|
|
scheduleMicrotask(() {
|
|
prescriptionsViewModel.getPrescriptionDetails(widget.prescriptionsResponseModel);
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
prescriptionsViewModel = Provider.of<PrescriptionsViewModel>(context, listen: false);
|
|
return Scaffold(
|
|
backgroundColor: AppColors.bgScaffoldColor,
|
|
appBar: AppBar(
|
|
title: LocaleKeys.prescriptions.tr(context: context).toText18(),
|
|
backgroundColor: AppColors.bgScaffoldColor,
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Consumer<PrescriptionsViewModel>(builder: (context, prescriptionVM, child) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
LocaleKeys.prescriptions.tr(context: context).toText24(isBold: true).paddingSymmetrical(24.h, 0.h),
|
|
SizedBox(height: 24.h),
|
|
Container(
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
color: AppColors.whiteColor,
|
|
borderRadius: 20.h,
|
|
hasShadow: true,
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.all(16.h),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Image.network(
|
|
widget.prescriptionsResponseModel.doctorImageURL!,
|
|
width: 24.h,
|
|
height: 24.h,
|
|
fit: BoxFit.fill,
|
|
).circle(100),
|
|
SizedBox(width: 8.h),
|
|
Expanded(child: widget.prescriptionsResponseModel.doctorName!.toText16(isBold: true)),
|
|
],
|
|
),
|
|
SizedBox(height: 16.h),
|
|
Wrap(
|
|
direction: Axis.horizontal,
|
|
spacing: 6.h,
|
|
runSpacing: 6.h,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
icon: AppAssets.doctor_calendar_icon,
|
|
iconColor: AppColors.textColor,
|
|
iconSize: 13.h,
|
|
text: DateUtil.formatDateToDate(DateUtil.convertStringToDate(widget.prescriptionsResponseModel.appointmentDate), false),
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
text: widget.prescriptionsResponseModel.clinicDescription!,
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
icon: AppAssets.rating_icon,
|
|
iconColor: AppColors.ratingColorYellow,
|
|
iconSize: 13.h,
|
|
text: "Rating: ${widget.prescriptionsResponseModel.decimalDoctorRate}",
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
text: widget.prescriptionsResponseModel.name!,
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
).paddingSymmetrical(24.h, 0.h),
|
|
SizedBox(height: 16.h),
|
|
ListView.builder(
|
|
shrinkWrap: true,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemCount: prescriptionVM.isPrescriptionsDetailsLoading ? 5 : prescriptionVM.prescriptionDetailsList.length,
|
|
itemBuilder: (context, index) {
|
|
return prescriptionVM.isPrescriptionsDetailsLoading
|
|
? const MoviesShimmerWidget()
|
|
: AnimationConfiguration.staggeredList(
|
|
position: index,
|
|
duration: const Duration(milliseconds: 500),
|
|
child: SlideAnimation(
|
|
verticalOffset: 100.0,
|
|
child: FadeInAnimation(
|
|
child: AnimatedContainer(
|
|
duration: Duration(milliseconds: 300),
|
|
curve: Curves.easeInOut,
|
|
margin: EdgeInsets.symmetric(vertical: 8.h),
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 20.h, hasShadow: true),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(height: 16.h),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Image.network(
|
|
prescriptionVM.prescriptionDetailsList[index].imageThumbUrl!,
|
|
width: 60.h,
|
|
height: 60.h,
|
|
fit: BoxFit.fill,
|
|
).circle(100),
|
|
SizedBox(width: 8.h),
|
|
Expanded(
|
|
child: prescriptionVM.prescriptionDetailsList[index].itemDescription!.toText16(isBold: true, maxlines: 2),
|
|
),
|
|
],
|
|
).paddingSymmetrical(16.h, 0.h),
|
|
SizedBox(height: 16.h),
|
|
Wrap(
|
|
direction: Axis.horizontal,
|
|
spacing: 6.h,
|
|
runSpacing: 6.h,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
text: "${LocaleKeys.route.tr(context: context)}: ${prescriptionVM.prescriptionDetailsList[index].route}",
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
text: "${LocaleKeys.frequency.tr(context: context)}: ${prescriptionVM.prescriptionDetailsList[index].frequency}",
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
text: "${LocaleKeys.dailyDoses.tr(context: context)}: ${prescriptionVM.prescriptionDetailsList[index].doseDailyQuantity}",
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
CustomButton(
|
|
text: "${LocaleKeys.days.tr(context: context)}: ${prescriptionVM.prescriptionDetailsList[index].days}",
|
|
onPressed: () {},
|
|
backgroundColor: AppColors.greyColor,
|
|
borderColor: AppColors.greyColor,
|
|
textColor: AppColors.blackColor,
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 8,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 30.h,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
).paddingSymmetrical(16.h, 0.h),
|
|
SizedBox(height: 8.h),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Utils.buildSvgWithAssets(icon: AppAssets.prescription_remarks_icon, width: 18.h, height: 18.h),
|
|
SizedBox(width: 9.h),
|
|
Expanded(child: "${LocaleKeys.remarks.tr(context: context)}: ${prescriptionVM.prescriptionDetailsList[index].remarks!}".toText10(isBold: true)),
|
|
],
|
|
).paddingSymmetrical(16.h, 0.h),
|
|
SizedBox(height: 16.h),
|
|
Divider(color: AppColors.borderOnlyColor.withValues(alpha: 0.05), height: 1.h),
|
|
SizedBox(height: 16.h),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
).paddingSymmetrical(24.h, 0.h),
|
|
],
|
|
);
|
|
}),
|
|
),
|
|
);
|
|
}
|
|
}
|