import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/Dialog/confirm_cancel_order_dialog.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/StepsWidget.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'new_cmc_step_one_page.dart'; import 'new_cmc_step_three_page.dart'; import 'new_cmc_step_tow_page.dart'; class NewCMCPage extends StatefulWidget { NewCMCPage({this.model}); final CMCViewModel model; @override _NewCMCPageState createState() => _NewCMCPageState(); } class _NewCMCPageState extends State with TickerProviderStateMixin { PageController _controller; int _currentIndex = 1; double _latitude; double _longitude; CMCInsertPresOrderRequestModel cMCInsertPresOrderRequestModel; @override void initState() { super.initState(); PatientERCMCInsertServicesList patientERCMCInsertServicesList; if (widget.model.cmcAllServicesList.length > 0) { patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( price: widget.model.cmcAllServicesList[0].price, serviceID: widget.model.cmcAllServicesList[0].serviceID.toString(), selectedServiceName: widget.model.cmcAllServicesList[0].description, selectedServiceNameAR: widget.model.cmcAllServicesList[0].description, recordID: 1, totalPrice: widget.model.cmcAllServicesList[0].totalPrice, vAT: widget.model.cmcAllServicesList[0].vAT); cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel( patientERCMCInsertServicesList: [patientERCMCInsertServicesList]); } cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel( patientERCMCInsertServicesList: patientERCMCInsertServicesList != null ? [patientERCMCInsertServicesList] : []); _controller = new PageController(); _getCurrentLocation(); } _getCurrentLocation() async { await getLastKnownPosition().then((value) { _latitude = value.latitude; _longitude = value.longitude; }).catchError((e) { _longitude = 0; _latitude = 0; }); } @override void dispose() { super.dispose(); } changePageViewIndex(pageIndex) { _controller.jumpToPage(pageIndex); } @override Widget build(BuildContext context) { void showConfirmMessage( CMCViewModel model, GetOrderDetailByOrderIDResponseModel order) { showDialog( context: context, child: ConfirmCancelOrderDialog( model: model, onTap: () async { UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel( presOrderID: order.presOrderID, rejectionReason: "", presOrderStatus: 4, editedBy: 3); await model.updateCmcPresOrder(updatePresOrderRequestModel); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); } else { AppToast.showSuccessToast(message: "Done Successfully"); await model.getCmcAllPresOrders(); } }, )); } return Scaffold( body: SafeArea( child: SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height * 0.8, child: Column( children: [ Container( margin: EdgeInsets.only(left: MediaQuery.of(context).size.width*0.05, right: MediaQuery.of(context).size.width*0.05), child: StepsWidget( index: _currentIndex, changeCurrentTab: changePageViewIndex, ), ), Expanded( child: PageView( physics: NeverScrollableScrollPhysics(), controller: _controller, onPageChanged: (index) { setState(() { _currentIndex = index; }); }, scrollDirection: Axis.horizontal, children: [ widget.model.cmcAllOrderDetail.length != 0 ? FractionallySizedBox( heightFactor: 0.8, widthFactor: 0.9, child: Container( width: double.infinity, margin: EdgeInsets.only(top: 15), decoration: BoxDecoration( border: Border.all(color: Colors.grey, width: 1), borderRadius: BorderRadius.circular(12), color: Colors.white), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 12, ), Container( width: double.infinity, padding: EdgeInsets.only( left: 15, bottom: 15, top: 15), decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Colors.grey, width: 1.0, ), ), // borderRadius: BorderRadius.circular(12), color: Colors.white), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( "Request ID", bold: false, fontSize: 13, ), SizedBox( height: 4, ), Texts( widget.model.cmcAllOrderDetail[0].iD.toString(), fontSize: 22, ), ], ), ), Container( width: double.infinity, padding: EdgeInsets.only( left: 15, bottom: 15, top: 15), decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Colors.grey, width: 1.0, ), ), // borderRadius: BorderRadius.circular(12), color: Colors.white), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( "Status", bold: false, fontSize: 13, ), SizedBox( height: 4, ), Texts( "Pending", fontSize: 22, ), ], ), ), Container( width: double.infinity, padding: EdgeInsets.only( left: 15, bottom: 15, top: 15), decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Colors.grey, width: 1.0, ), ), // borderRadius: BorderRadius.circular(12), color: Colors.white), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( "Pickup Date", bold: false, fontSize: 13, ), SizedBox( height: 4, ), Texts( DateUtil.getDayMonthYearDateFormatted( DateUtil.convertStringToDate( widget.model.cmcAllOrderDetail[0] .createdOn)), fontSize: 22, ), ], ), ), Container( width: double.infinity, padding: EdgeInsets.only( left: 15, bottom: 15, top: 15), decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Colors.grey, width: 1.0, ), ), // borderRadius: BorderRadius.circular(12), color: Colors.white), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( "Service Name", bold: false, fontSize: 13, ), SizedBox( height: 4, ), Texts( widget.model.cmcAllOrderDetail[0].description .toString() ?? widget.model.cmcAllOrderDetail[0] .descriptionN .toString(), fontSize: 22, ), ], ), ), SizedBox( height: 12, ), Center( child: Container( width: MediaQuery .of(context) .size .width * 0.85, child: SecondaryButton( label: "Cancel".toUpperCase(), onTap: () { showConfirmMessage(widget.model, widget.model.cmcAllOrderDetail[0]); } , color: Colors.red[800], disabled: false, textColor: Theme .of(context) .backgroundColor), ), ), SizedBox( height: 12, ), ], ), ), ) : NewCMCStepOnePage( changePageViewIndex: changePageViewIndex, cMCInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel, model: widget.model, ), NewCMCStepTowPage( longitude: _longitude, latitude: _latitude, changePageViewIndex: changePageViewIndex, cmcInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel, model: widget.model, ), NewCMCStepThreePage( changePageViewIndex: changePageViewIndex, cmcInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel, model: widget.model, ), ], ), ), ], ), ), ), ), ); } }