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.
HMG_Patient_App/lib/pages/medical/balance/confirm_payment_page.dart

177 lines
5.9 KiB
Dart

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/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<MyBalanceViewModel>(
builder: (_, model, w) => AppScaffold(
isShowAppBar: true,
appBarTitle: 'Advance Payment',
body: SingleChildScrollView(
physics: ScrollPhysics(),
child: Container(
margin: EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Texts(
'Confirm the Payment',
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: 'File Number',
initialValue: advanceModel.fileNumber,
isEnabled: false,
),
),
),
Expanded(
child: Container(
margin: EdgeInsets.all(3),
child: NewTextFields(
hintText: 'Name',
initialValue: patientInfoAndMobileNumber.firstName,
isEnabled: false,
),
),
),
],
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: 'Mobile Number',
initialValue: patientInfoAndMobileNumber.mobileNumber,
isEnabled: false,
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: 'Depositor Name',
initialValue: advanceModel.depositorName,
isEnabled: false,
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: 'Note',
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: 'CONFIRM',
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';
}
}