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.
diplomatic-quarter/lib/pages/MyAppointments/widgets/PrescriptionReport.dart

160 lines
5.6 KiB
Dart

4 years ago
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';
4 years ago
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
4 years ago
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<PrescriptionReportEnh> prescriptionReportEnhList;
dynamic listPres;
AppoitmentAllHistoryResultList appo;
4 years ago
PrescriptionReportPage(
{@required this.prescriptionReportEnhList,
@required this.listPres,
@required this.appo});
4 years ago
@override
_PrescriptionReportState createState() => _PrescriptionReportState();
}
class _PrescriptionReportState extends State<PrescriptionReportPage> {
@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: <Widget>[
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,
4 years ago
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: <Widget>[
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();
4 years ago
GifLoaderDialogUtils.showMyDialog(context);
service
.sendPrescriptionEmail(widget.appo.appointmentDate, widget.appo.setupID,
widget.listPres, context)
.then((res) {
GifLoaderDialogUtils.hideDialog(context);
4 years ago
AppToast.showSuccessToast(message: 'A copy has been sent to the e-mail');
}).catchError((err) {
4 years ago
GifLoaderDialogUtils.hideDialog(context);
4 years ago
print(err);
AppToast.showErrorToast(message: err);
4 years ago
});
4 years ago
}
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,
),
),
);
}
}