import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_enh.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescription_details_page.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.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'; import 'package:flutter/material.dart'; class PrescriptionReportPage extends StatefulWidget { List prescriptionReportEnhList; dynamic listPres; AppoitmentAllHistoryResultList appo; PrescriptionReportPage( {@required this.prescriptionReportEnhList, @required this.listPres, @required this.appo}); @override _PrescriptionReportState createState() => _PrescriptionReportState(); } class _PrescriptionReportState extends State { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return AppScaffold( isShowAppBar: true, appBarTitle: 'Items', body: Container( height: MediaQuery.of(context).size.height * 0.8, child: ListView.builder( itemBuilder: (context, index) => InkWell( onTap: () { navigateToPrescriptionDetails( widget.prescriptionReportEnhList[index]); }, child: Container( width: double.infinity, margin: EdgeInsets.only(top: 10, left: 10, right: 10), padding: EdgeInsets.all(8.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( Radius.circular(10.0), ), border: Border.all(color: Colors.grey[200], width: 0.5), ), child: Row( children: [ ClipRRect( borderRadius: BorderRadius.all(Radius.circular(5)), child: Image.network( widget.prescriptionReportEnhList[index].imageSRCUrl, fit: BoxFit.cover, width: 60, height: 70, ), ), Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Texts(widget .prescriptionReportEnhList[index].itemDescription)), )), Icon( Icons.arrow_forward, size: 18, color: Colors.grey[500], ) ], ), ), ), itemCount: widget.prescriptionReportEnhList.length, ), ), bottomSheet: Container( width: double.infinity, height: MediaQuery.of(context).size.height * 0.2, color: Colors.grey[100], child: Column( children: [ Divider(), Container( width: MediaQuery.of(context).size.width * 0.8, child: Button( label: 'Send Copy', onTap: () { sendPrescriptionReportEmail(); }, ), ), Container( width: MediaQuery.of(context).size.width * 0.8, child: Button( label: 'Resend order & deliver', backgroundColor: Colors.green[200], )) ], ), ), ); } sendPrescriptionReportEmail() { DoctorsListService service = new DoctorsListService(); GifLoaderDialogUtils.showMyDialog(context); service .sendPrescriptionEmail(widget.appo.appointmentDate, widget.appo.setupID, widget.listPres, context) .then((res) { GifLoaderDialogUtils.hideDialog(context); AppToast.showSuccessToast(message: 'A copy has been sent to the e-mail'); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); AppToast.showErrorToast(message: err); }); } navigateToPrescriptionDetails(PrescriptionReportEnh prescriptionReportEnh) { final PrescriptionReport prescriptionReport = new PrescriptionReport(); prescriptionReport.imageSRCUrl = prescriptionReportEnh.imageSRCUrl; prescriptionReport.itemDescription = prescriptionReportEnh.itemDescription; prescriptionReport.itemID = prescriptionReportEnh.itemID; prescriptionReport.routeN = prescriptionReportEnh.route; prescriptionReport.route = prescriptionReportEnh.route; prescriptionReport.frequency = prescriptionReportEnh.frequency; prescriptionReport.frequencyN = prescriptionReportEnh.frequency; prescriptionReport.doseDailyQuantity = prescriptionReportEnh.doseDailyQuantity; prescriptionReport.days = prescriptionReportEnh.days; Navigator.push( context, FadePage( page: PrescriptionDetailsPage( prescriptionReport: prescriptionReport, ), ), ); } }