import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class PrescriptionsHistoryDetailsPage extends StatelessWidget { final PrescriptionsOrder prescriptionsOrder; PrescriptionsHistoryDetailsPage({Key key, this.prescriptionsOrder}); @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder), builder: (_, model, widget) { int status = prescriptionsOrder.status; String _statusDisp = projectViewModel.isArabic ? prescriptionsOrder.descriptionN : prescriptionsOrder.description; Color _color; if (status == 1) { //pending _color = Color(0xffCC9B14); } else if (status == 2) { //processing _color = Color(0xff2E303A); } else if (status == 3) { //completed _color = Color(0xff359846); } else if (status == 4) { //cancel // Rejected _color = Color(0xffD02127); } return AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).orderDetails, baseViewModel: model, showNewAppBar: true, backgroundColor: Color(0xffF8F8F8), showNewAppBarTitle: true, body: Column( children: [ Expanded( child: ListView( physics: BouncingScrollPhysics(), padding: EdgeInsets.all(21), children: [ Container( decoration: BoxDecoration( color: _color, borderRadius: BorderRadius.all( Radius.circular(10.0), ), boxShadow: [ BoxShadow( color: Color(0xff000000).withOpacity(.05), blurRadius: 27, offset: Offset(0, -3), ), ], ), child: Container( margin: EdgeInsets.only(left: 6), padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12), decoration: BoxDecoration( color: Colors.white, border: Border.all(color: Colors.white, width: 1), borderRadius: BorderRadius.only( bottomRight: Radius.circular(10.0), topRight: Radius.circular(10.0), ), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( _statusDisp, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: _color, letterSpacing: -0.4, height: 16 / 10), ), Text( '${TranslationBase.of(context).orderNo}. ${prescriptionsOrder.iD}', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), ), ], ), ), Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( DateUtil.formatDateToDate(prescriptionsOrder.createdOn, projectViewModel.isArabic), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, height: 16 / 10), ), Text( DateUtil.formatDateToTime(prescriptionsOrder.createdOn), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), ), ], ) ], ), SizedBox(height: 16), ListView.separated( physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) => Row( children: [ Container( 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( model.prescriptionReportEnhList[index].imageSRCUrl, fit: BoxFit.cover, width: 48, height: 48, ), ), ), SizedBox(width: 14), Expanded( child: Text( (model.prescriptionReportEnhList[index].itemDescription.isNotEmpty ? model.prescriptionReportEnhList[index].itemDescription : model.prescriptionReportEnhList[index].itemDescriptionN ?? '') .toLowerCase() .capitalizeFirstofEach, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), ), ) ], ), separatorBuilder: (context, index) => SizedBox(height: 12), itemCount: model.prescriptionReportEnhList.length) ], ), ), ), ], ), ), Container( color: Colors.white, padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), child: DefaultButton( TranslationBase.of(context).cancelOrder, prescriptionsOrder.status != 1 ? null : () { showCDialog(model, context); }, disabledColor: Color(0xff575757), ), ), ], ), // bottomSheet: Container( // //padding: EdgeInsets.all(8.0), // // margin: EdgeInsets.all(8.0), // child: BottomButton( // label: TranslationBase.of(context).cancelOrder, // disabled: prescriptionsOrder.status != 1, // textColor: Colors.white, // onTap: () { // showCDialog(model, context); // //showAlertDialog(context); // }, // ), // ), ); }, ); } showCDialog(PrescriptionsViewModel model, context) { ConfirmDialog( context: context, confirmMessage: "Are you sure ?", okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel, okFunction: () { Navigator.of(context).pop(); model.updatePressOrder(presOrderID: prescriptionsOrder.iD).then((value) { Navigator.of(context).pop(); }); }, cancelFunction: () => {}).showAlertDialog(context); // dialog.showAlertDialog(context); } }