import 'package:diplomaticquarterapp/core/viewModels/ancillary_orders_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import "package:collection/collection.dart"; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; class AnicllaryOrdersDetails extends StatefulWidget { final dynamic appoNo; final dynamic orderNo; AnicllaryOrdersDetails(this.appoNo, this.orderNo); @override _AnicllaryOrdersState createState() => _AnicllaryOrdersState(); } class _AnicllaryOrdersState extends State with SingleTickerProviderStateMixin { void initState() { super.initState(); } void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getOrdersDetails(widget.appoNo, widget.orderNo), builder: (_, model, widget) => AppScaffold( isShowAppBar: true, baseViewModel: model, appBarTitle: TranslationBase.of(context).anicllaryOrders, body: SingleChildScrollView( padding: EdgeInsets.all(12), child: model.ancillaryListsDetails.length > 0 ? Column(children: [ getPatientInfo(model), getInvoiceDetails(model), getInsuranceDetails(model), getAncillaryDetails(model), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Texts( TranslationBase.of(context).total, fontSize: 20, fontWeight: FontWeight.bold, ), Texts( getTotalValue(model), fontSize: 20, fontWeight: FontWeight.bold, ) ], ), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Button( label: TranslationBase.of(context).payNow, onTap: () {}, ) ], ) ]) : SizedBox()))); } Widget getPatientInfo(AnciallryOrdersViewModel model) { print(model.ancillaryListsDetails); return Padding( child: Column( children: [ Row( children: [ Texts( TranslationBase.of(context).mrn, fontWeight: FontWeight.bold, fontSize: 22, ), Texts( " : ", fontSize: 20, ), Texts( model.ancillaryListsDetails[0].patientID.toString(), ) ], ), Row( children: [ Texts( TranslationBase.of(context).patientName, fontWeight: FontWeight.bold, fontSize: 20, ), Texts( " : ", fontSize: 20, ), Texts( model.ancillaryLists[0].patientName, ) ], ), Divider( color: Colors.black26, ) ], ), padding: EdgeInsets.only(top: 5.0, bottom: 5.0), ); } Widget getInvoiceDetails(model) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Texts( TranslationBase.of(context).invoiceNo, fontWeight: FontWeight.bold, ), Texts(" : "), Texts( model.ancillaryListsDetails[0].appointmentNo.toString(), ) ], ), Row( children: [ Texts( TranslationBase.of(context).date, fontWeight: FontWeight.bold, ), Texts(" : "), Texts( DateUtil.getFormattedDate( DateUtil.convertStringToDate( model.ancillaryListsDetails[0].appointmentDate), "MMM dd,yyyy"), ) ], ), Row( children: [ Texts( TranslationBase.of(context).date, fontWeight: FontWeight.bold, ), Texts(" : "), Texts( model.ancillaryListsDetails[0].doctorName, ), ], ), SizedBox( height: 10, ), Divider( color: Colors.black26, ) ], ); } Widget getInsuranceDetails(model) { return Padding( padding: EdgeInsets.only(top: 10, bottom: 10), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Texts( TranslationBase.of(context).insurance, fontWeight: FontWeight.bold, ), Texts( TranslationBase.of(context).insuranceID, fontWeight: FontWeight.bold, ) ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Texts( model.ancillaryListsDetails[0].policyName, ), Texts( model.ancillaryListsDetails[0].insurancePolicyNo, ) ], ), SizedBox( height: 15, ), Divider( color: Colors.red[800], thickness: 3, ) ], )); } Widget getAncillaryDetails(model) { Map newMap = groupBy(model.ancillaryListsDetails[0].ancillaryOrderProcList, (obj) => obj.procedureCategoryName); print(newMap); return Padding( padding: EdgeInsets.only(top: 10, bottom: 10), child: getHeaderDetails(newMap)); } Widget getHeaderDetails(newMap) { List list = new List(); newMap.forEach((key, value) { list.add( Texts( key, fontWeight: FontWeight.bold, ), ); list.add(Row( mainAxisAlignment: MainAxisAlignment.start, children: [ getLabDetails(value), ], )); }); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: list, ); } String getTotalValue(value) { double total = 0.0; value.ancillaryListsDetails[0].ancillaryOrderProcList .forEach((result) => {total += result.companyShareWithTax}); return total.toStringAsFixed(2); } getLabDetails(value) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: value.map((result) { return Container( width: MediaQuery.of(context).size.width * .9, padding: EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Expanded( flex: 3, child: Text(result.procedureName.toString(), overflow: TextOverflow.ellipsis)), Expanded(child: AppText(result.companyShare.toString())), Expanded(child: AppText(result.companyTaxAmount.toString())), Expanded( child: AppText( result.companyShareWithTax.toString(), )) ], )); }).toList(), ); } }