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.
358 lines
17 KiB
Dart
358 lines
17 KiB
Dart
import 'package:diplomaticquarterapp/core/enum/OrderService.dart';
|
|
import 'package:diplomaticquarterapp/core/model/er/PatientER.dart';
|
|
import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart';
|
|
import 'package:diplomaticquarterapp/core/model/er/get_all_transportation_method_list_model.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart';
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
enum Direction { ToHospital, FromHospital }
|
|
enum Way { OneWay, TwoWays }
|
|
|
|
class SelectTransportationMethod extends StatefulWidget {
|
|
final Function changeCurrentTab;
|
|
final PatientER patientER;
|
|
final PatientER_RC patientER_RC;
|
|
final AmRequestViewModel amRequestViewModel;
|
|
|
|
SelectTransportationMethod({Key key, this.changeCurrentTab, this.patientER, this.patientER_RC, this.amRequestViewModel});
|
|
|
|
@override
|
|
_SelectTransportationMethodState createState() => _SelectTransportationMethodState();
|
|
}
|
|
|
|
class _SelectTransportationMethodState extends State<SelectTransportationMethod> {
|
|
PatientERTransportationMethod _erTransportationMethod = PatientERTransportationMethod();
|
|
Direction _direction = Direction.FromHospital;
|
|
Way _way = Way.OneWay;
|
|
|
|
OrderService _orderService = OrderService.AMBULANCE;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// if (widget.patientER.direction != null) {
|
|
// _direction = widget.patientER.direction == 0 ? Direction.ToHospital : Direction.FromHospital;
|
|
// _way = widget.patientER.tripType == 1 ? Way.OneWay : Way.TwoWays;
|
|
// _erTransportationMethod = widget.amRequestViewModel.amRequestModeList[(widget.patientER.selectedAmbulate - 1)];
|
|
// } else {
|
|
// if (widget.amRequestViewModel.amRequestModeList.length != 0) _erTransportationMethod = widget.amRequestViewModel.amRequestModeList[widget.amRequestViewModel.amRequestModeList.length - 1];
|
|
// }
|
|
|
|
//RC API Revamp
|
|
if (widget.patientER_RC.transportationDetails.direction != null) {
|
|
_direction = widget.patientER_RC.transportationDetails.direction == 0 ? Direction.ToHospital : Direction.FromHospital;
|
|
_way = widget.patientER_RC.transportationDetails.tripType == 1 ? Way.OneWay : Way.TwoWays;
|
|
_erTransportationMethod = widget.amRequestViewModel.amRequestModeList[(widget.patientER_RC.transportationDetails.ambulate - 1)];
|
|
} else {
|
|
if (widget.amRequestViewModel.amRequestModeList.length != 0) _erTransportationMethod = widget.amRequestViewModel.amRequestModeList[widget.amRequestViewModel.amRequestModeList.length - 1];
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
return AppScaffold(
|
|
isShowAppBar: false,
|
|
isShowDecPage: false,
|
|
body: SingleChildScrollView(
|
|
physics: BouncingScrollPhysics(),
|
|
child: Container(
|
|
margin: EdgeInsets.only(left: 12, right: 12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
Text(TranslationBase.of(context).transportHeading, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 12),
|
|
decoration: cardRadius(12),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
...List.generate(
|
|
widget.amRequestViewModel.amRequestModeList.length,
|
|
(index) => InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_erTransportationMethod = widget.amRequestViewModel.amRequestModeList[index];
|
|
});
|
|
},
|
|
child: Container(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
flex: 4,
|
|
child: ListTile(
|
|
contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
|
|
title: Row(
|
|
children: [
|
|
Radio(
|
|
value: widget.amRequestViewModel.amRequestModeList[index],
|
|
groupValue: _erTransportationMethod,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_erTransportationMethod = value;
|
|
});
|
|
},
|
|
),
|
|
Flexible(
|
|
child: Text(
|
|
projectViewModel.isArabic ? widget.amRequestViewModel.amRequestModeList[index].textN : widget.amRequestViewModel.amRequestModeList[index].text,
|
|
style: TextStyle(
|
|
fontSize: 12.0,
|
|
letterSpacing: -0.48,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Text(
|
|
TranslationBase.of(context).sar + ' ${widget.amRequestViewModel.amRequestModeList[index].price}',
|
|
style: TextStyle(
|
|
fontSize: 12.0,
|
|
letterSpacing: -0.48,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 12,
|
|
),
|
|
Text(TranslationBase.of(context).directionHeading, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)),
|
|
Container(
|
|
width: double.maxFinite,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_direction = Direction.ToHospital;
|
|
});
|
|
},
|
|
child: Container(
|
|
width: double.maxFinite,
|
|
child: ListTile(
|
|
contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
|
|
title: Row(
|
|
children: [
|
|
Radio(
|
|
value: Direction.ToHospital,
|
|
groupValue: _direction,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_direction = value;
|
|
});
|
|
},
|
|
),
|
|
Text(TranslationBase.of(context).toHospital,
|
|
style: TextStyle(
|
|
fontSize: 12.0,
|
|
letterSpacing: -0.48,
|
|
fontWeight: FontWeight.w600,
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_direction = Direction.FromHospital;
|
|
});
|
|
},
|
|
child: Container(
|
|
width: double.maxFinite,
|
|
child: ListTile(
|
|
contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
|
|
title: Row(
|
|
children: [
|
|
Radio(
|
|
value: Direction.FromHospital,
|
|
groupValue: _direction,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_direction = value;
|
|
});
|
|
},
|
|
),
|
|
Text(TranslationBase.of(context).fromHospital,
|
|
style: TextStyle(
|
|
fontSize: 12.0,
|
|
letterSpacing: -0.48,
|
|
fontWeight: FontWeight.w600,
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (_direction == Direction.ToHospital)
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: 8,
|
|
),
|
|
Text(TranslationBase.of(context).wayHeading, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)),
|
|
SizedBox(
|
|
height: 5,
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(bottom: 65),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_way = Way.OneWay;
|
|
});
|
|
},
|
|
child: Container(
|
|
child: ListTile(
|
|
contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
|
|
title: Row(
|
|
children: [
|
|
Radio(
|
|
value: Way.OneWay,
|
|
groupValue: _way,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_way = value;
|
|
});
|
|
},
|
|
),
|
|
Text(TranslationBase.of(context).oneDirec,
|
|
style: TextStyle(
|
|
fontSize: 12.0,
|
|
letterSpacing: -0.48,
|
|
fontWeight: FontWeight.w600,
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
_way = Way.TwoWays;
|
|
});
|
|
},
|
|
child: Container(
|
|
child: ListTile(
|
|
contentPadding: EdgeInsets.only(left: 0.0, right: 0.0),
|
|
title: Row(
|
|
children: [
|
|
Radio(
|
|
value: Way.TwoWays,
|
|
groupValue: _way,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_way = value;
|
|
});
|
|
},
|
|
),
|
|
Text(TranslationBase.of(context).twoDirec,
|
|
style: TextStyle(
|
|
fontSize: 12.0,
|
|
letterSpacing: -0.48,
|
|
fontWeight: FontWeight.w600,
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 30,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 15,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
bottomSheet: Container(
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
padding: EdgeInsets.all(12.0),
|
|
child: DefaultButton(
|
|
TranslationBase.of(context).next,
|
|
() {
|
|
setState(() {
|
|
// widget.patientER.transportationMethodId = (widget.amRequestViewModel.amRequestModeList.indexOf(_erTransportationMethod) + 1);
|
|
// widget.patientER.direction = _direction == Direction.ToHospital ? 1 : 0;
|
|
// widget.patientER.tripType = _way == Way.TwoWays ? 0 : 1;
|
|
// widget.patientER.selectedAmbulate = (widget.amRequestViewModel.amRequestModeList.indexOf(_erTransportationMethod) + 1);
|
|
// widget.patientER.patientERTransportationMethod = _erTransportationMethod;
|
|
// widget.patientER.orderServiceID = _orderService.getIdOrderService();
|
|
// widget.patientER.pickupUrgency = 1;
|
|
// widget.patientER.lineItemNo = 1;
|
|
// widget.patientER.cost = _erTransportationMethod.price.toDouble();
|
|
// widget.patientER.vAT = _erTransportationMethod.priceVAT ?? 0;
|
|
// widget.patientER.totalPrice = _erTransportationMethod.priceTotal.toDouble();
|
|
// widget.changeCurrentTab(1);
|
|
|
|
// widget.patientER_RC.transportationDetails.id = (widget.amRequestViewModel.amRequestModeList.indexOf(_erTransportationMethod) + 1);
|
|
widget.patientER_RC.transportationDetails.direction = _direction == Direction.ToHospital ? 0 : 1;
|
|
widget.patientER_RC.transportationDetails.tripType = _way == Way.TwoWays ? 0 : 1;
|
|
widget.patientER_RC.transportationDetails.ambulate = (widget.amRequestViewModel.amRequestModeList.indexOf(_erTransportationMethod) + 1);
|
|
widget.patientER_RC.transportationDetails.transportationType = _erTransportationMethod.iD.toString();
|
|
widget.patientER_RC.patientERTransportationMethod = _erTransportationMethod;
|
|
widget.patientER_RC.transportationDetails.pickupUrgency = 1;
|
|
// widget.patientER.orderServiceID = _orderService.getIdOrderService();
|
|
// widget.patientER.lineItemNo = 1;
|
|
// widget.patientER.cost = _erTransportationMethod.price.toDouble();
|
|
// widget.patientER.vAT = _erTransportationMethod.priceVAT ?? 0;
|
|
// widget.patientER.totalPrice = _erTransportationMethod.priceTotal.toDouble();
|
|
widget.changeCurrentTab(1);
|
|
});
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|