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/ErService/rapid-response-team/rrt-request-page.dart

434 lines
17 KiB
Dart

7 months ago
import 'package:hmg_patient_app/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/GetCMCAllOrdersResponseModel.dart';
import 'package:hmg_patient_app/core/service/AlHabibMedicalService/customer_addresses_service.dart';
import 'package:hmg_patient_app/core/viewModels/er/rrt-view-model.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/models/rrt/RRTProcedureList.dart';
import 'package:hmg_patient_app/models/rrt/service_price.dart';
import 'package:hmg_patient_app/pages/ErService/rapid-response-team/rrt-order-list-item.dart';
import 'package:hmg_patient_app/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart';
import 'package:hmg_patient_app/pages/base/base_view.dart';
import 'package:hmg_patient_app/pages/medical/reports/user_agreement_page.dart';
import 'package:hmg_patient_app/services/appointment_services/GetDoctorsList.dart';
import 'package:hmg_patient_app/theme/colors.dart';
import 'package:hmg_patient_app/uitl/app_toast.dart';
import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/uitl/utils.dart';
import 'package:hmg_patient_app/uitl/utils_new.dart';
import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart';
import 'package:hmg_patient_app/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
2 years ago
import 'package:provider/provider.dart';
4 years ago
class RRTRequestPage extends StatefulWidget {
final List<GetCMCAllOrdersResponseModel> pendingOrders;
final ServicePrice servicePrice;
4 years ago
RRTViewModel viewModel;
RRTRequestPage({required this.pendingOrders, required this.servicePrice, required this.viewModel});
@override
4 years ago
State<StatefulWidget> createState() => RRTRequestPageState();
}
4 years ago
class RRTRequestPageState extends State<RRTRequestPage> {
bool acceptTerms = false;
late VidaProcedureList selectedProcedure;
4 years ago
ProjectViewModel? projectViewModel;
2 years ago
4 years ago
@override
void initState() {
// getProcedureDetails();
super.initState();
}
@override
Widget build(BuildContext context) {
2 years ago
projectViewModel = Provider.of(context);
return BaseView<RRTViewModel>(
4 years ago
onModelReady: (vm) {
4 years ago
// viewModel = vm;
selectedProcedure = widget.viewModel.rrtProcedureList[0];
},
4 years ago
builder: (ctx, vm, widgetState) {
if (widget.pendingOrders.isNotEmpty)
return currentOrderContent();
else
return requestContent();
},
);
}
4 years ago
Widget requestContent() {
return Column(
children: [
Expanded(
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
children: [
serviceDescription(context),
SizedBox(height: 20),
4 years ago
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
...List.generate(
widget.viewModel.rrtProcedureList.length,
(index) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 1,
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: InkWell(
onTap: () {
setState(() {
selectedProcedure = widget.viewModel.rrtProcedureList[index];
// getPaymentInfo(context, widget.projectID.toString(), widget.selectedProcedure.procedureID);
});
},
child: Row(
children: [
Radio(
value: widget.viewModel.rrtProcedureList[index],
groupValue: selectedProcedure,
activeColor: Colors.red[800],
toggleable: true,
onChanged: (value) {
setState(() {
selectedProcedure = value!;
4 years ago
print(selectedProcedure.procedureName);
// getPaymentInfo(context, widget.projectID.toString(), widget.selectedProcedure.procedureID);
});
},
),
Expanded(
child: Text(
// projectViewModel.isArabic ? widget.proceduresList[index].procedureNameN : widget.proceduresList[index].procedureName,
widget.viewModel.rrtProcedureList[index].procedureName!,
4 years ago
style: TextStyle(
fontSize: 12.0,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
)
],
),
],
),
),
],
),
),
priceTable(context),
acceptPolicy(),
2 years ago
Container(height: 0.5, color: Theme.of(context).appBarTheme.backgroundColor), // Seperator
Container(
padding: EdgeInsets.only(top: 20, bottom: 5),
alignment: Alignment.center,
child: Text(TranslationBase.of(context).youCanPayByTheFollowingOptions,
2 years ago
style: TextStyle(fontSize: 13, color: Theme.of(context).appBarTheme.backgroundColor, fontWeight: FontWeight.w500), maxLines: 2)),
4 years ago
Container(margin: EdgeInsets.only(left: 15.0, right: 15.0, top: 10.0), child: getPaymentMethods())
],
),
),
actionButtons()
],
);
}
4 years ago
Widget currentOrderContent() {
var orders = widget.pendingOrders;
return ListView.builder(
itemCount: orders.length,
4 years ago
padding: EdgeInsets.all(21),
itemBuilder: (ctx, idx) {
4 years ago
var order = orders[idx];
return RRTLogListItem(order, onCancel: deleteOrder);
4 years ago
});
}
4 years ago
Widget serviceDescription(BuildContext context) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
TranslationBase.of(context).rrtDDetails,
textAlign: TextAlign.justify,
4 years ago
style: TextStyle(fontSize: 14.0, letterSpacing: -0.64, color: CustomColors.textColor, fontWeight: FontWeight.w300),
),
);
4 years ago
Widget priceTable(BuildContext context) {
var radius = Radius.circular(8);
4 years ago
String amount = selectedProcedure.patientShare.toString();
String vat = selectedProcedure.patientTaxAmount.toString();
String total = selectedProcedure.patientShareWithTax.toString();
2 years ago
return Container(
decoration: cardRadius(12),
padding: EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).billAmount,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w600,
letterSpacing: -0.64,
),
),
mHeight(10),
Row(
children: [
Expanded(
child: Text(
TranslationBase.of(context).patientShareToDo,
style: TextStyle(
fontSize: 10,
letterSpacing: -0.4,
color: CustomColors.textColor,
fontWeight: FontWeight.w600,
),
),
),
Expanded(
child: Row(
children: [
projectViewModel!.isArabic ? Container() : SvgPicture.asset("assets/images/new/Saudi_Riyal_Symbol.svg", width: 16, height: 16),
mWidth(6),
Text(
amount,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
),
),
mWidth(6),
projectViewModel!.isArabic ? SvgPicture.asset("assets/images/new/Saudi_Riyal_Symbol.svg", width: 16, height: 16) : Container(),
],
2 years ago
),
),
],
),
mHeight(4),
mDivider(CustomColors.lightGreyColor),
mHeight(4),
Row(
children: [
Expanded(
child: Text(
TranslationBase.of(context).patientTaxToDo,
style: TextStyle(
fontSize: 10,
letterSpacing: -0.4,
color: CustomColors.textColor,
fontWeight: FontWeight.w600,
),
),
),
Expanded(
child: Row(
children: [
projectViewModel!.isArabic ? Container() : SvgPicture.asset("assets/images/new/Saudi_Riyal_Symbol.svg", width: 16, height: 16),
mWidth(6),
Text(
vat,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w600,
),
),
mWidth(6),
projectViewModel!.isArabic ? SvgPicture.asset("assets/images/new/Saudi_Riyal_Symbol.svg", width: 16, height: 16) : Container(),
],
2 years ago
),
),
],
),
mHeight(4),
mDivider(CustomColors.lightGreyColor),
mHeight(4),
Row(
children: [
Expanded(
child: Text(
TranslationBase.of(context).patientShareTotalToDo,
style: TextStyle(
fontSize: 14,
letterSpacing: -0.4,
color: CustomColors.textColor,
fontWeight: FontWeight.bold,
),
),
),
Expanded(
child: Row(
children: [
projectViewModel!.isArabic ? Container() : SvgPicture.asset("assets/images/new/Saudi_Riyal_Symbol.svg", width: 14, height: 14),
mWidth(6),
Text(
total,
style: TextStyle(fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold, color: CustomColors.black),
),
mWidth(6),
projectViewModel!.isArabic ? SvgPicture.asset("assets/images/new/Saudi_Riyal_Symbol.svg", width: 16, height: 16) : Container(),
],
2 years ago
),
),
],
),
],
),
);
2 years ago
// Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [
// Container(
// height: 30,
// decoration: BoxDecoration(color: Theme.of(context).appBarTheme.color, borderRadius: BorderRadius.only(topLeft: radius, topRight: radius)),
// child: Center(child: Text(TranslationBase.of(context).approximateServiceFee, style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500, letterSpacing: 1))),
// ),
// pricingRow(label: TranslationBase.of(context).patientShare, value: '$amount ${TranslationBase.of(context).sar}'),
// Container(height: 0.5, color: Theme.of(context).appBarTheme.color),
// pricingRow(label: TranslationBase.of(context).patientTaxToDo, value: '$vat ${TranslationBase.of(context).sar}'),
// Container(height: 0.5, color: Theme.of(context).appBarTheme.color),
// pricingRow(label: TranslationBase.of(context).patientShareWithTax, value: '$total ${TranslationBase.of(context).sar}', labelBold: true),
// Container(height: 0.5, color: Theme.of(context).appBarTheme.color),
// ],
// );
}
Widget pricingRow({required String label, required String value, bool labelBold = false, bool valueBold = false}) {
4 years ago
return Container(
4 years ago
height: 35,
4 years ago
margin: EdgeInsets.symmetric(horizontal: 10),
child: Row(
children: [
4 years ago
Text(label, style: TextStyle(fontSize: 12, color: CustomColors.textColor, fontWeight: labelBold ? FontWeight.bold : FontWeight.normal)),
4 years ago
Spacer(),
Container(
4 years ago
height: 35,
2 years ago
color: Theme.of(context).appBarTheme.backgroundColor,
4 years ago
width: 0.5,
),
Container(
alignment: Alignment.center,
width: MediaQuery.of(context).size.width * 0.25,
4 years ago
child: Text(value, style: TextStyle(fontSize: 12, color: CustomColors.textColor, fontWeight: valueBold ? FontWeight.bold : FontWeight.normal))),
4 years ago
],
),
);
}
4 years ago
Widget acceptPolicy() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
children: [
4 years ago
Checkbox(
value: acceptTerms,
onChanged: (v) {
setState(() => acceptTerms = v!);
4 years ago
}),
SizedBox(width: 10),
4 years ago
Expanded(child: Text(TranslationBase.of(context).iAcceptTermsConditions, style: TextStyle(fontSize: 12, color: CustomColors.textColor), maxLines: 2)),
Container(
alignment: Alignment.center,
width: MediaQuery.of(context).size.width * 0.25,
child: TextButton(
child: Text(TranslationBase.of(context).clickHere, style: TextStyle(fontSize: 12, color: Colors.blue, fontWeight: FontWeight.w400)),
4 years ago
onPressed: () {
Navigator.push(
context,
FadePage(
page: UserAgreementContent(),
),
);
4 years ago
}),
)
],
),
);
}
4 years ago
Widget paymentOptions() => Container(
height: 30,
alignment: Alignment.center,
4 years ago
child: Image.asset(
"assets/payment_options/payment_options.png",
fit: BoxFit.fill,
));
4 years ago
Widget actionButtons() {
return Container(
margin: EdgeInsets.all(15),
child: Row(
children: [
Expanded(
4 years ago
child: DefaultButton(
TranslationBase.of(context).next,
() {
4 years ago
if (acceptTerms && selectedProcedure != null)
4 years ago
goToPickupAddress();
else
AppToast.showErrorToast(message: TranslationBase.of(context).pleaseAcceptTerms);
4 years ago
},
4 years ago
color: acceptTerms ? CustomColors.accentColor : Colors.grey,
),
),
],
),
);
}
4 years ago
4 years ago
getProcedureDetails() {
GifLoaderDialogUtils.showMyDialog(context);
DoctorsListService service = new DoctorsListService();
service.getRRTProcedures(15, projectViewModel!.isArabic ? 1 : 2).then((res) {
4 years ago
GifLoaderDialogUtils.hideDialog(context);
print(res['Vida_ProcedureList']);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err);
print(err);
});
}
4 years ago
goToPickupAddress() async {
Navigator.push(
context,
4 years ago
FadePage(
page: RRTRequestPickupAddressPage(
servicePrice: widget.servicePrice,
4 years ago
selectedProcedure: selectedProcedure,
4 years ago
)));
}
deleteOrder(GetCMCAllOrdersResponseModel order) async {
GifLoaderDialogUtils.showMyDialog(context);
4 years ago
var success = await widget.viewModel.cancelOrderRC(order);
GifLoaderDialogUtils.hideDialog(context);
4 years ago
if (success)
setState(() {
widget.pendingOrders.remove(order);
});
4 years ago
await widget.viewModel.getAllOrdersRC();
}
4 years ago
}