|
|
|
@ -5,23 +5,20 @@ import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.da
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/Blood/dialogs/SelectHospitalDialog.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/ErService/widgets/AppointmentCard.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/landing/home_page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/ProgressDialog.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.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:diplomaticquarterapp/widgets/pickupLocation/PickupLocationFromMap.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
|
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
|
|
|
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
|
|
|
|
|
|
import '../AmbulanceReq.dart';
|
|
|
|
|
import '../AvailableAppointmentsPage.dart';
|
|
|
|
|
|
|
|
|
|
enum HaveAppointment { YES, NO }
|
|
|
|
@ -68,7 +65,10 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
isShowAppBar: false,
|
|
|
|
|
isShowDecPage: false,
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 12, right: 12),
|
|
|
|
@ -111,7 +111,7 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(getSelectFromMapName(context)),
|
|
|
|
|
Expanded(child: Texts(getSelectFromMapName(context))),
|
|
|
|
|
Icon(
|
|
|
|
|
FontAwesomeIcons.mapMarkerAlt,
|
|
|
|
|
size: 24,
|
|
|
|
@ -144,7 +144,6 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
child: ListTile(
|
|
|
|
|
title: Texts(TranslationBase.of(context).insideHome),
|
|
|
|
|
leading: Checkbox(
|
|
|
|
|
activeColor: Colors.red[800],
|
|
|
|
|
value: _isInsideHome,
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
@ -187,7 +186,6 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
leading: Radio(
|
|
|
|
|
value: HaveAppointment.YES,
|
|
|
|
|
groupValue: _haveAppointment,
|
|
|
|
|
activeColor: Colors.red[800],
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
if (myAppointment == null) {
|
|
|
|
|
getAppointment();
|
|
|
|
@ -222,7 +220,6 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
leading: Radio(
|
|
|
|
|
value: HaveAppointment.NO,
|
|
|
|
|
groupValue: _haveAppointment,
|
|
|
|
|
activeColor: Colors.red[800],
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_haveAppointment = value;
|
|
|
|
@ -271,7 +268,8 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(getHospitalName(TranslationBase.of(context).pickupLocation)),
|
|
|
|
|
Texts(getHospitalName(
|
|
|
|
|
TranslationBase.of(context).pickupLocation)),
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.arrow_drop_down,
|
|
|
|
|
size: 24,
|
|
|
|
@ -307,7 +305,8 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(getHospitalName(TranslationBase.of(context).pickupLocation)),
|
|
|
|
|
Texts(getHospitalName(
|
|
|
|
|
TranslationBase.of(context).pickupLocation)),
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.arrow_drop_down,
|
|
|
|
|
size: 24,
|
|
|
|
@ -352,7 +351,7 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(getSelectFromMapName(context)),
|
|
|
|
|
Expanded(child: Texts(getSelectFromMapName(context))),
|
|
|
|
|
Icon(
|
|
|
|
|
FontAwesomeIcons.mapMarkerAlt,
|
|
|
|
|
size: 24,
|
|
|
|
@ -364,14 +363,18 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 45,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
bottomSheet: Container(
|
|
|
|
|
padding: EdgeInsets.all(15),
|
|
|
|
|
width: double.maxFinite,
|
|
|
|
|
height: 76,
|
|
|
|
|
height: 90,
|
|
|
|
|
child: SecondaryButton(
|
|
|
|
|
color: Colors.grey[800],
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
@ -383,37 +386,61 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.patientER.pickupSpot = _isInsideHome ? 1 : 0;
|
|
|
|
|
if (widget.patientER.direction == 0) {
|
|
|
|
|
widget.patientER.pickupLocationLattitude = _result.geometry.location.lat.toString();
|
|
|
|
|
widget.patientER.pickupLocationLongitude = _result.geometry.location.lng.toString();
|
|
|
|
|
widget.patientER.dropoffLocationLattitude = _selectedHospital.latitude;
|
|
|
|
|
widget.patientER.dropoffLocationLongitude = _selectedHospital.longitude;
|
|
|
|
|
widget.patientER.pickupLocationLattitude =
|
|
|
|
|
_result.geometry.location.lat.toString();
|
|
|
|
|
widget.patientER.pickupLocationLongitude =
|
|
|
|
|
_result.geometry.location.lng.toString();
|
|
|
|
|
widget.patientER.dropoffLocationLattitude =
|
|
|
|
|
_selectedHospital.latitude;
|
|
|
|
|
widget.patientER.dropoffLocationLongitude =
|
|
|
|
|
_selectedHospital.longitude;
|
|
|
|
|
} else {
|
|
|
|
|
widget.patientER.pickupLocationLattitude = _selectedHospital.latitude;
|
|
|
|
|
widget.patientER.pickupLocationLongitude = _selectedHospital.longitude;
|
|
|
|
|
widget.patientER.dropoffLocationLattitude = _result.geometry.location.lat.toString();
|
|
|
|
|
widget.patientER.dropoffLocationLongitude = _result.geometry.location.lng.toString();
|
|
|
|
|
widget.patientER.pickupLocationLattitude =
|
|
|
|
|
_selectedHospital.latitude;
|
|
|
|
|
widget.patientER.pickupLocationLongitude =
|
|
|
|
|
_selectedHospital.longitude;
|
|
|
|
|
widget.patientER.dropoffLocationLattitude =
|
|
|
|
|
_result.geometry.location.lat.toString();
|
|
|
|
|
widget.patientER.dropoffLocationLongitude =
|
|
|
|
|
_result.geometry.location.lng.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
widget.patientER.latitude = widget.patientER.pickupLocationLattitude;
|
|
|
|
|
widget.patientER.longitude = widget.patientER.pickupLocationLongitude;
|
|
|
|
|
widget.patientER.dropoffLocationName = _selectedHospital.name;
|
|
|
|
|
widget.patientER.createdBy = widget.amRequestViewModel.user.patientID;
|
|
|
|
|
widget.patientER.isOutPatient = widget.amRequestViewModel.user.outSA;
|
|
|
|
|
widget.patientER.patientIdentificationID = widget.amRequestViewModel.user.patientIdentificationNo;
|
|
|
|
|
widget.patientER.pickupDateTime = DateUtil.convertDateToStringLocation(DateTime.now());
|
|
|
|
|
widget.patientER.pickupLocationName = _result.formattedAddress;
|
|
|
|
|
widget.patientER.projectID = widget.amRequestViewModel.user.projectID;
|
|
|
|
|
widget.patientER.requesterFileNo = widget.amRequestViewModel.user.patientID;
|
|
|
|
|
widget.patientER.latitude =
|
|
|
|
|
widget.patientER.pickupLocationLattitude;
|
|
|
|
|
widget.patientER.longitude =
|
|
|
|
|
widget.patientER.pickupLocationLongitude;
|
|
|
|
|
widget.patientER.dropoffLocationName =
|
|
|
|
|
_selectedHospital.name;
|
|
|
|
|
widget.patientER.createdBy =
|
|
|
|
|
widget.amRequestViewModel.user.patientID;
|
|
|
|
|
widget.patientER.isOutPatient =
|
|
|
|
|
widget.amRequestViewModel.user.outSA;
|
|
|
|
|
widget.patientER.patientIdentificationID = widget
|
|
|
|
|
.amRequestViewModel.user.patientIdentificationNo;
|
|
|
|
|
widget.patientER.pickupDateTime =
|
|
|
|
|
DateUtil.convertDateToStringLocation(DateTime.now());
|
|
|
|
|
widget.patientER.pickupLocationName =
|
|
|
|
|
_result.formattedAddress;
|
|
|
|
|
widget.patientER.projectID =
|
|
|
|
|
widget.amRequestViewModel.user.projectID;
|
|
|
|
|
widget.patientER.requesterFileNo =
|
|
|
|
|
widget.amRequestViewModel.user.patientID;
|
|
|
|
|
widget.patientER.requesterIsOutSA = false;
|
|
|
|
|
widget.patientER.lineItemNo = 0;
|
|
|
|
|
widget.patientER.requesterMobileNo = widget.amRequestViewModel.user.mobileNumber;
|
|
|
|
|
widget.patientER.requesterMobileNo =
|
|
|
|
|
widget.amRequestViewModel.user.mobileNumber;
|
|
|
|
|
|
|
|
|
|
if (_haveAppointment == HaveAppointment.YES) {
|
|
|
|
|
widget.patientER.appointmentNo = myAppointment.appointmentNo.toString();
|
|
|
|
|
widget.patientER.appointmentClinicName = myAppointment.clinicName;
|
|
|
|
|
widget.patientER.appointmentDoctorName = myAppointment.doctorNameObj;
|
|
|
|
|
widget.patientER.appointmentBranch = myAppointment.projectName;
|
|
|
|
|
widget.patientER.appointmentTime = myAppointment.appointmentDate;
|
|
|
|
|
widget.patientER.appointmentNo =
|
|
|
|
|
myAppointment.appointmentNo.toString();
|
|
|
|
|
widget.patientER.appointmentClinicName =
|
|
|
|
|
myAppointment.clinicName;
|
|
|
|
|
widget.patientER.appointmentDoctorName =
|
|
|
|
|
myAppointment.doctorNameObj;
|
|
|
|
|
widget.patientER.appointmentBranch =
|
|
|
|
|
myAppointment.projectName;
|
|
|
|
|
widget.patientER.appointmentTime =
|
|
|
|
|
myAppointment.appointmentDate;
|
|
|
|
|
widget.patientER.haveAppointment = true;
|
|
|
|
|
} else {
|
|
|
|
|
widget.patientER.appointmentNo = "0";
|
|
|
|
@ -430,9 +457,6 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
},
|
|
|
|
|
label: TranslationBase.of(context).next,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -457,11 +481,13 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getSelectFromMapName(context) {
|
|
|
|
|
return _result != null ? _result.formattedAddress : TranslationBase.of(context).selectMap;
|
|
|
|
|
return _result != null
|
|
|
|
|
? _result.formattedAddress
|
|
|
|
|
: TranslationBase.of(context).selectMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getAppointment() {
|
|
|
|
|
ProgressDialogUtil.showProgressDialog(context);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
widget.amRequestViewModel.getAppointmentHistory().then((value) {
|
|
|
|
|
if (widget.amRequestViewModel.state == ViewState.Error ||
|
|
|
|
|
widget.amRequestViewModel.state == ViewState.ErrorLocal) {
|
|
|
|
@ -469,7 +495,7 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
} else if (widget
|
|
|
|
|
.amRequestViewModel.appoitmentAllHistoryResultList.length >
|
|
|
|
|
0) {
|
|
|
|
|
ProgressDialogUtil.hideProgressDialog(context);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
@ -491,14 +517,15 @@ class _PickupLocationState extends State<PickupLocation> {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
ProgressDialogUtil.hideProgressDialog(context);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
setState(() {
|
|
|
|
|
_haveAppointment = HaveAppointment.NO;
|
|
|
|
|
});
|
|
|
|
|
AppToast.showErrorToast(message: TranslationBase.of(context).noAppointment);
|
|
|
|
|
AppToast.showErrorToast(
|
|
|
|
|
message: TranslationBase.of(context).noAppointment);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((e) {
|
|
|
|
|
ProgressDialogUtil.hideProgressDialog(context);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: e);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|