import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/my_balance/patient_info_and_mobile_number.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'dialogs/ConfirmSMSDialog.dart'; import 'new_text_Field.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; class ConfirmPaymentPage extends StatelessWidget { final AdvanceModel advanceModel; final PatientInfoAndMobileNumber patientInfoAndMobileNumber; final String selectedPaymentMethod; ConfirmPaymentPage( {this.advanceModel, this.patientInfoAndMobileNumber, this.selectedPaymentMethod}); @override Widget build(BuildContext context) { void showSMSDialog() { showDialog( context: context, barrierDismissible: false, child: ConfirmSMSDialog( phoneNumber: patientInfoAndMobileNumber.mobileNumber, ), ); } return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).advancePayment, body: SingleChildScrollView( physics: ScrollPhysics(), child: Container( margin: EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( TranslationBase.of(context).confirmThePayment, textAlign: TextAlign.center, fontWeight: FontWeight.w500, fontSize: 24, ), SizedBox( height: 12, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( height: 100.0, padding: EdgeInsets.all(7.0), width: MediaQuery.of(context).size.width * 0.45, child: Image.asset(getImagePath(selectedPaymentMethod)), ), Texts( '${advanceModel.amount} SAR', fontSize: 26, bold: true, ) ], ), SizedBox( height: 12, ), Row( children: [ Expanded( child: Container( margin: EdgeInsets.all(3), child: NewTextFields( hintText: TranslationBase.of(context).fileNumber, initialValue: advanceModel.fileNumber, isEnabled: false, ), ), ), Expanded( child: Container( margin: EdgeInsets.all(3), child: NewTextFields( hintText: TranslationBase.of(context).name, initialValue: patientInfoAndMobileNumber.firstName, isEnabled: false, ), ), ), ], ), SizedBox( height: 12, ), NewTextFields( hintText: TranslationBase.of(context).mobileNumber, initialValue: patientInfoAndMobileNumber.mobileNumber, isEnabled: false, ), SizedBox( height: 12, ), NewTextFields( hintText: TranslationBase.of(context).depositorName, initialValue: advanceModel.depositorName, isEnabled: false, ), SizedBox( height: 12, ), NewTextFields( hintText: TranslationBase.of(context).notes, initialValue: advanceModel.note, isEnabled: false, ), ], ), ), ), bottomSheet: Container( height: MediaQuery.of(context).size.height * 0.1, width: double.infinity, padding: EdgeInsets.all(12), child: SecondaryButton( textColor: Colors.white, label: TranslationBase.of(context).confirm.toUpperCase(), disabled: model.state == ViewState.Busy, onTap: () { model .sendActivationCodeForAdvancePayment( patientID: int.parse(advanceModel.fileNumber),projectID: advanceModel.hospitalsModel.iD) .then((value) { if (model.state != ViewState.ErrorLocal && model.state != ViewState.Error) showSMSDialog(); }).showProgressBar( text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); }, ), ), ), ); } String getImagePath(String paymentMethod) { switch (paymentMethod) { case "MADA": return 'assets/images/new-design/mada.png'; break; case "SADAD": return 'assets/images/new-design/sadad.png'; break; case "VISA": return 'assets/images/new-design/visa.png'; break; case "MASTERCARD": return 'assets/images/new-design/mastercard.png'; break; case "Installment": return 'assets/images/new-design/installment.png'; break; } return 'assets/images/new-design/mada.png'; } }