import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescription_details_page.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/cupertino.dart'; import 'package:flutter/material.dart'; class PrescriptionItemsPage extends StatelessWidget { final Prescriptions prescriptions; PrescriptionItemsPage({Key key, this.prescriptions}); @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getPrescriptionReport(dischargeNo: prescriptions.dischargeNo), builder: (_, model, widget) => AppScaffold( isShowAppBar: true, appBarTitle: 'Items', baseViewModel: model, body: Container( height: MediaQuery.of(context).size.height * 0.8, child: ListView.builder( itemBuilder: (context, index) => InkWell( onTap: () => Navigator.push( context, FadePage( page: PrescriptionDetailsPage( prescriptionReport: model.prescriptionReportList[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( model.prescriptionReportList[index].imageSRCUrl, fit: BoxFit.cover, width: 60, height: 70, ), ), Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Texts(model .prescriptionReportList[index].itemDescription)), )), Icon( Icons.arrow_forward_ios, size: 18, color: Colors.grey[500], ) ], ), ), ), itemCount: model.prescriptionReportList.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: () => model.sendPrescriptionEmail( appointmentDate: prescriptions.appointmentDate, patientID: prescriptions.patientID, clinicName: prescriptions.companyName, doctorName: prescriptions.doctorName, projectID: prescriptions.projectID), loading: model.state == ViewState.BusyLocal, ), ), Container( width: MediaQuery.of(context).size.width * 0.8, child: Button( label: 'Resend order & deliver', backgroundColor: Colors.green[200], )) ], ), ), ), ); } }