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.
HMG_Patient_App/lib/pages/medical/prescriptions/PrescriptionOrderOverveiw.dart

241 lines
13 KiB
Dart

import 'package:hmg_patient_app/core/enum/viewstate.dart';
import 'package:hmg_patient_app/core/model/prescriptions/Prescriptions.dart';
import 'package:hmg_patient_app/core/model/prescriptions/prescription_report.dart';
import 'package:hmg_patient_app/core/model/prescriptions/prescription_report_enh.dart';
import 'package:hmg_patient_app/core/service/AlHabibMedicalService/customer_addresses_service.dart';
import 'package:hmg_patient_app/core/viewModels/medical/PrescriptionDeliveryViewModel.dart';
import 'package:hmg_patient_app/pages/base/base_view.dart';
import 'package:hmg_patient_app/theme/colors.dart';
import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/uitl/utils_new.dart';
import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart';
import 'package:hmg_patient_app/widgets/dialogs/ConfirmWithMessageDialog.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:hmg_patient_app/widgets/show_zoom_image_dialog.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class PrescriptionOrderOverview extends StatelessWidget {
final Prescriptions prescriptions;
final List<PrescriptionReport>? prescriptionReportList;
final List<PrescriptionReportEnh>? prescriptionReportEnhList;
final AddressInfo? selectedAddress;
final double? latitude;
final double? longitude;
PrescriptionOrderOverview({Key? key, required this.prescriptions, this.prescriptionReportList, this.prescriptionReportEnhList, this.selectedAddress, this.latitude, this.longitude});
@override
Widget build(BuildContext context) {
return BaseView<PrescriptionDeliveryViewModel>(
builder: (_, model, widget) => AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).orderOverview,
baseViewModel: model,
showNewAppBar: true,
showNewAppBarTitle: true,
backgroundColor: CustomColors.appBackgroudGrey2Color,
body: Container(
height: double.infinity,
child: Column(
children: [
Expanded(
child: Column(
children: [
if (!prescriptions.isInOutPatient!)
Container(
margin: EdgeInsets.all(12),
decoration: cardRadius(12),
clipBehavior: Clip.antiAlias,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
children: [
...List.generate(
prescriptionReportList!.length,
(index) => Container(
margin: EdgeInsets.all(0.0),
decoration: cardRadius(0),
child: Row(
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(5)),
child: Image.network(
prescriptionReportList![index].imageSRCUrl!,
fit: BoxFit.cover,
width: 60,
height: 70,
),
),
SizedBox(
width: 10,
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text(
prescriptionReportList![index].itemDescription!.isNotEmpty
? prescriptionReportList![index].itemDescription!
: prescriptionReportList![index].itemDescriptionN!,
style: TextStyle(fontFamily: prescriptionReportList![index].itemDescription!.isNotEmpty ? 'Poppins' : 'Cairo'))),
)),
],
),
))
],
),
),
)
else
Container(
margin: EdgeInsets.all(12),
decoration: cardRadius(12),
clipBehavior: Clip.antiAlias,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
...List.generate(
prescriptionReportEnhList!.length,
(index) => Container(
margin: EdgeInsets.all(0.0),
// decoration: cardRadius(0),
child: Row(
children: <Widget>[
// InkWell(
// onTap: () {
// showZoomImageDialog(context, prescriptionReportEnhList[index].imageSRCUrl);
// },
// child: Stack(
// alignment: Alignment.center,
// children: [
// Container(
// margin: EdgeInsets.only(bottom: 10.0),
// decoration: BoxDecoration(
// border: Border.all(width: 1.0, color: Color(0xffEBEBEB)),
// borderRadius: BorderRadius.all(Radius.circular(30.0)),
// ),
// child: ClipRRect(
// borderRadius: BorderRadius.all(Radius.circular(30)),
// child: Image.network(
// prescriptionReportEnhList[index].imageSRCUrl,
// fit: BoxFit.cover,
// width: 48,
// height: 48,
// ),
// ),
// ),
// Container(
// margin: EdgeInsets.only(bottom: 10.0),
// child: Icon(
// Icons.search,
// size: 18,
// color: Colors.white,
// ),
// padding: EdgeInsets.all(3),
// decoration: containerRadius(Colors.black.withOpacity(0.3), 200),
// )
// ],
// ),
// ),
// SizedBox(width: 14),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
(prescriptionReportList![index].itemDescription!.isNotEmpty
? prescriptionReportList![index].itemDescription!
: prescriptionReportList![index].itemDescriptionN! ?? ''),
style: TextStyle(
fontFamily: prescriptionReportList![index].itemDescription!.isNotEmpty ? 'Poppins' : 'Cairo',
letterSpacing: -0.64,
color: Color(0xff2E303A),
fontSize: 16.0,
fontWeight: FontWeight.w600)),
],
),
),
),
],
),
),
)
],
),
),
),
],
),
),
Container(
// decoration: cardRadius(0),
margin: EdgeInsets.zero,
child: Container(
width: double.infinity,
margin: EdgeInsets.all(12),
child: DefaultButton(
TranslationBase.of(context).submit.toUpperCase(),
() async {
showDialog(
context: context,
builder: (cxt) => ConfirmWithMessageDialog(
message: TranslationBase.of(context).confirmPrescription,
okTitle: TranslationBase.of(context).ok,
onTap: () async {
GifLoaderDialogUtils.showMyDialog(context);
await model
.insertDeliveryOrder(
lineItemNo: 1,
longitude: longitude,
latitude: latitude,
appointmentNo: prescriptions.appointmentNo,
dischargeID: prescriptions.dischargeNo,
projectID: prescriptions.projectID,
createdBy: model.user!.patientID)
.then((value) {
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal)
showErrorDialog(context, model.error);
else {
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context, true);
}
}).catchError((e) {
GifLoaderDialogUtils.hideDialog(context);
});
},
),
);
},
)),
)
],
),
),
),
);
}
void showErrorDialog(BuildContext context, String error) {
showDialog(
context: context,
builder: (cxt) => ConfirmWithMessageDialog(
message: TranslationBase.of(context).youAlreadyHaveOrder,
okTitle: TranslationBase.of(context).orderOverview,
onTap: () {
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context, true);
},
),
);
}
}