diff --git a/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart b/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart index 30bfa13e..0d955cb6 100644 --- a/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart +++ b/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart @@ -1,13 +1,17 @@ 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/widgets/buttons/BottomButton.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; @@ -16,138 +20,187 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getPrescriptionReportEnh( - prescriptionsOrder: prescriptionsOrder), - builder: (_, model, widget) => AppScaffold( - isShowAppBar: true, - appBarTitle: TranslationBase.of(context).orderDetails, - baseViewModel: model, - body: SingleChildScrollView( - child: Container( - margin: EdgeInsets.all(15.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 5, - ), - Container( - width: double.infinity, - decoration: BoxDecoration( - color: prescriptionsOrder.status == 3 ?Colors.green : prescriptionsOrder.status ==2 ? Colors.grey: Colors.red, - borderRadius: BorderRadius.circular(5)), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).orderStatus +' : ${prescriptionsOrder.descriptionN}',color: Colors.white,), - )), - SizedBox( - height: 15, - ), - Table( - border: TableBorder.symmetric( - inside: BorderSide(width: 0.5), - outside: BorderSide(width: 0.5)), - children: [ - TableRow(children: [ - Container( - height: 50, - color: Colors.white, - child: Center( - child: Texts(TranslationBase.of(context).orderNo), - ), - ), - Container( - height: 50, - color: Colors.white, - child: Center( - child: Texts(TranslationBase.of(context).date), - ), - ), - ]), - TableRow(children: [ - Container( - height: 70, - color: Colors.white, - child: Center( - child: Texts('${prescriptionsOrder.iD}'), - ), - ), - Container( - height: 70, - color: Colors.white, - child: Center( - child: Texts('${prescriptionsOrder.createdOn.year}-${prescriptionsOrder.createdOn.day}-${prescriptionsOrder.createdOn.day} ${prescriptionsOrder.createdOn.hour}:${prescriptionsOrder.createdOn.minute}'), + 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), + ), + ], ), - ]) - ], - ), - SizedBox( - height: 15, - ), - ...List.generate( - model.prescriptionReportEnhList.length, - (index) => Container( - margin: EdgeInsets.all(8.0), - color: Colors.white, - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5)), - child: Image.network( - model.prescriptionReportEnhList[index].imageSRCUrl, - fit: BoxFit.cover, - width: 60, - height: 70, + 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), ), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts(model.prescriptionReportEnhList[index] - .itemDescription), + 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) + ], ), - ], + ), ), - ), + ], ), - SizedBox(height: 120,) - ], - ), - ), - ), - 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); - }, + ), + 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){ + showCDialog(PrescriptionsViewModel model, context) { ConfirmDialog( context: context, confirmMessage: "Are you sure ?", okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel, - okFunction: () { + okFunction: () { Navigator.of(context).pop(); model.updatePressOrder(presOrderID: prescriptionsOrder.iD).then((value) { Navigator.of(context).pop(); @@ -156,5 +209,4 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { cancelFunction: () => {}).showAlertDialog(context); // dialog.showAlertDialog(context); } - }