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.
241 lines
12 KiB
Dart
241 lines
12 KiB
Dart
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart';
|
|
import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart';
|
|
import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_enh.dart';
|
|
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/medical/PrescriptionDeliveryViewModel.dart';
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:diplomaticquarterapp/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, 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);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|