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/medical/prescriptions/prescriptions_history_detai...

197 lines
9.8 KiB
Dart

import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/GetCMCAllOrdersResponseModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/extensions/string_extensions.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/defaultButton.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 GetCMCAllOrdersResponseModel prescriptionsOrder;
PrescriptionsHistoryDetailsPage({Key key, this.prescriptionsOrder});
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<PrescriptionsViewModel>(
onModelReady: (model) => model.getPrescriptionReportDetailsRC(prescriptionsOrder.iD, projectViewModel.user.patientID),
builder: (_, model, widget) {
int status = prescriptionsOrder.statusId;
String _statusDisp = prescriptionsOrder.statusText;
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 || status == 6 || status == 7) {
//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: <Widget>[
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: projectViewModel.isArabic ? 0 : 6, right: projectViewModel.isArabic ? 6 : 0),
padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.white, width: 1),
borderRadius: BorderRadius.only(
bottomRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0),
topRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0),
bottomLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0),
topLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(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.getDayMonthYearDateFormatted(DateTime.tryParse(prescriptionsOrder.created)),
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, height: 16 / 10),
),
],
)
],
),
SizedBox(height: 16),
ListView.separated(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) => Row(
children: <Widget>[
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.prescriptionsOrderListRC[index].image,
fit: BoxFit.cover,
width: 48,
height: 48,
),
),
),
SizedBox(width: 14),
Expanded(
child: Text(
(model.prescriptionsOrderListRC[index].itemDescription.isNotEmpty
? model.prescriptionsOrderListRC[index].itemDescription
: model.prescriptionsOrderListRC[index].itemDescription ?? '')
.toLowerCase()
.capitalizeFirstofEach,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64),
),
)
],
),
separatorBuilder: (context, index) => SizedBox(height: 12),
itemCount: model.prescriptionsOrderListRC.length)
],
),
),
),
],
),
),
Container(
color: Colors.white,
padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21),
child: DefaultButton(
TranslationBase.of(context).cancelOrder,
// prescriptionsOrder.statusId != 1
// ? null
// :
() {
showCDialog(model, context);
},
disabledColor: Color(0xff575757),
),
),
],
),
);
},
);
}
showCDialog(PrescriptionsViewModel model, context) {
ConfirmDialog(
context: context,
confirmMessage: "Are you sure ?",
okText: TranslationBase.of(context).confirm,
cancelText: TranslationBase.of(context).cancel,
okFunction: () async {
Navigator.of(context).pop();
await model.updatePressOrder(presOrderID: prescriptionsOrder.iD);
Navigator.of(context).pop(true);
},
cancelFunction: () => {}).showAlertDialog(context);
// dialog.showAlertDialog(context);
}
}