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.
378 lines
14 KiB
Dart
378 lines
14 KiB
Dart
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
|
|
import 'package:diplomaticquarterapp/core/model/my_balance/patient_info.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart';
|
|
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart';
|
|
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
import 'package:diplomaticquarterapp/pages/medical/balance/dialogs/SelectHospitalDialog.dart';
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.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:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:smart_progress_bar/smart_progress_bar.dart';
|
|
|
|
import '../../../core/model/my_balance/AdvanceModel.dart';
|
|
import 'dialogs/ConfirmSMSDialog.dart';
|
|
import 'dialogs/SelectBeneficiaryDialog.dart';
|
|
import 'dialogs/SelectPatientFamilyDialog.dart';
|
|
import 'dialogs/SelectPatientInfoDialog.dart';
|
|
import 'confirm_payment_page.dart';
|
|
import 'new_text_Field.dart';
|
|
|
|
enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON }
|
|
|
|
class AdvancePaymentPage extends StatefulWidget {
|
|
@override
|
|
_AdvancePaymentPageState createState() => _AdvancePaymentPageState();
|
|
}
|
|
|
|
class _AdvancePaymentPageState extends State<AdvancePaymentPage> {
|
|
TextEditingController _fileTextController = TextEditingController();
|
|
TextEditingController _notesTextController = TextEditingController();
|
|
BeneficiaryType beneficiaryType = BeneficiaryType.NON;
|
|
HospitalsModel _selectedHospital;
|
|
String amount = "";
|
|
String email;
|
|
PatientInfo _selectedPatientInfo;
|
|
GetAllSharedRecordsByStatusList selectedPatientFamily;
|
|
AdvanceModel advanceModel = AdvanceModel();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BaseView<MyBalanceViewModel>(
|
|
onModelReady: (model) => model.getHospitals(),
|
|
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(
|
|
'You can create and add an Advanced Payment for you account or other accounts.',
|
|
textAlign: TextAlign.center,
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
InkWell(
|
|
onTap: () => confirmSelectBeneficiaryDialog(model),
|
|
child: Container(
|
|
padding: EdgeInsets.all(12),
|
|
width: double.infinity,
|
|
height: 65,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Texts(getBeneficiaryType()),
|
|
Icon(Icons.arrow_drop_down)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (beneficiaryType == BeneficiaryType.MyFamilyFiles)
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
if (beneficiaryType == BeneficiaryType.MyFamilyFiles)
|
|
InkWell(
|
|
onTap: () {
|
|
model.getFamilyFiles().then((value) {
|
|
confirmSelectFamilyDialog(model
|
|
.getAllSharedRecordsByStatusResponse
|
|
.getAllSharedRecordsByStatusList);
|
|
}).showProgressBar(
|
|
text: "Loading",
|
|
backgroundColor: Colors.blue.withOpacity(0.6));
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(12),
|
|
width: double.infinity,
|
|
height: 65,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Texts(getFamilyMembersName()),
|
|
Icon(Icons.arrow_drop_down)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
NewTextFields(
|
|
hintText: 'File Number',
|
|
controller: _fileTextController,
|
|
),
|
|
if (beneficiaryType == BeneficiaryType.OtherAccount)
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
if (beneficiaryType == BeneficiaryType.OtherAccount)
|
|
InkWell(
|
|
onTap: () {
|
|
if (_fileTextController.text.isNotEmpty)
|
|
model
|
|
.getPatientInfoByPatientID(
|
|
id: _fileTextController.text)
|
|
.then((value) {
|
|
confirmSelectPatientDialog(model.patientInfoList);
|
|
}).showProgressBar(
|
|
text: "Loading",
|
|
backgroundColor:
|
|
Colors.blue.withOpacity(0.6));
|
|
else
|
|
AppToast.showErrorToast(
|
|
message: 'Please Enter The File Number');
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(12),
|
|
width: double.infinity,
|
|
height: 65,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Texts(getPatientName()),
|
|
Icon(Icons.arrow_drop_down)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
InkWell(
|
|
onTap: () => confirmSelectHospitalDialog(model.hospitals),
|
|
child: Container(
|
|
padding: EdgeInsets.all(12),
|
|
width: double.infinity,
|
|
height: 65,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Colors.white),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Texts(getHospitalName()),
|
|
Icon(Icons.arrow_drop_down)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
NewTextFields(
|
|
hintText: 'Amount*',
|
|
keyboardType: TextInputType.number,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
amount = value;
|
|
});
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
NewTextFields(
|
|
hintText: 'Depositor Email*',
|
|
initialValue: model.user.emailAddress,
|
|
onChanged: (value) {
|
|
email = value;
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
NewTextFields(
|
|
hintText: 'Notes',
|
|
controller: _notesTextController,
|
|
),
|
|
SizedBox(
|
|
height: MediaQuery.of(context).size.height * 0.15,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
bottomSheet: Container(
|
|
height: MediaQuery.of(context).size.height * 0.1,
|
|
width: double.infinity,
|
|
padding: EdgeInsets.all(12),
|
|
child: SecondaryButton(
|
|
textColor: Colors.white,
|
|
label: 'Submit',
|
|
disabled: amount.isEmpty ||
|
|
_fileTextController.text.isEmpty ||
|
|
_selectedHospital == null,
|
|
onTap: () {
|
|
advanceModel.fileNumber = _fileTextController.text;
|
|
advanceModel.hospitalsModel = _selectedHospital;
|
|
advanceModel.note = _notesTextController.text;
|
|
advanceModel.email = email ?? model.user.emailAddress;
|
|
advanceModel.amount = amount;
|
|
|
|
model.getPatientInfoByPatientIDAndMobileNumber().then((value) {
|
|
if (model.state != ViewState.Error &&
|
|
model.state != ViewState.ErrorLocal) {
|
|
Utils.hideKeyboard(context);
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => PaymentMethod())).then(
|
|
(value) {
|
|
Navigator.push(
|
|
context,
|
|
FadePage(
|
|
page: ConfirmPaymentPage(
|
|
advanceModel: advanceModel,
|
|
selectedPaymentMethod: value,
|
|
patientInfoAndMobileNumber:
|
|
model.patientInfoAndMobileNumber,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}).showProgressBar(
|
|
text: "Loading",
|
|
backgroundColor: Colors.blue.withOpacity(0.6));
|
|
},
|
|
),
|
|
)),
|
|
);
|
|
}
|
|
|
|
void confirmSelectBeneficiaryDialog(MyBalanceViewModel model) {
|
|
showDialog(
|
|
context: context,
|
|
child: SelectBeneficiaryDialog(
|
|
beneficiaryType: beneficiaryType,
|
|
onValueSelected: (value) {
|
|
setState(() {
|
|
if (value == BeneficiaryType.MyAccount) {
|
|
_fileTextController.text = model.user.patientID.toString();
|
|
advanceModel.depositorName =
|
|
model.user.firstName + " " + model.user.lastName;
|
|
} else
|
|
_fileTextController.text = "";
|
|
|
|
beneficiaryType = value;
|
|
});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
void confirmSelectHospitalDialog(List<HospitalsModel> hospitals) {
|
|
showDialog(
|
|
context: context,
|
|
child: SelectHospitalDialog(
|
|
hospitals: hospitals,
|
|
selectedHospital: _selectedHospital,
|
|
onValueSelected: (value) {
|
|
setState(() {
|
|
_selectedHospital = value;
|
|
});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
void confirmSelectPatientDialog(List<PatientInfo> patientInfoList) {
|
|
showDialog(
|
|
context: context,
|
|
child: SelectPatientInfoDialog(
|
|
patientInfoList: patientInfoList,
|
|
selectedPatientInfo: _selectedPatientInfo,
|
|
onValueSelected: (value) {
|
|
setState(() {
|
|
advanceModel.depositorName = value.fullName;
|
|
_selectedPatientInfo = value;
|
|
});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
void confirmSelectFamilyDialog(
|
|
List<GetAllSharedRecordsByStatusList> getAllSharedRecordsByStatusList) {
|
|
showDialog(
|
|
context: context,
|
|
child: SelectPatientFamilyDialog(
|
|
getAllSharedRecordsByStatusList: getAllSharedRecordsByStatusList,
|
|
selectedPatientFamily: selectedPatientFamily,
|
|
onValueSelected: (value) {
|
|
setState(() {
|
|
selectedPatientFamily = value;
|
|
_fileTextController.text = selectedPatientFamily.patientID.toString();
|
|
advanceModel.depositorName = value.patientName;
|
|
});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
String getBeneficiaryType() {
|
|
switch (beneficiaryType) {
|
|
case BeneficiaryType.MyAccount:
|
|
return "My Account";
|
|
case BeneficiaryType.MyFamilyFiles:
|
|
return "My Family Files";
|
|
break;
|
|
case BeneficiaryType.OtherAccount:
|
|
return "Other Account";
|
|
break;
|
|
case BeneficiaryType.NON:
|
|
return "Select Beneficiary";
|
|
}
|
|
return "";
|
|
}
|
|
|
|
String getHospitalName() {
|
|
if (_selectedHospital != null)
|
|
return _selectedHospital.name;
|
|
else
|
|
return "Select Hospital";
|
|
}
|
|
|
|
String getPatientName() {
|
|
if (_selectedPatientInfo != null)
|
|
return _selectedPatientInfo.fullName;
|
|
else
|
|
return "Select Patient Name";
|
|
}
|
|
|
|
String getFamilyMembersName() {
|
|
if (selectedPatientFamily != null)
|
|
return selectedPatientFamily.patientName;
|
|
else
|
|
return "Select Patient Name";
|
|
}
|
|
}
|