|
|
|
@ -3,19 +3,24 @@ import 'dart:async';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/Dialog/confirm_dialog.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
|
import 'package:maps_launcher/maps_launcher.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class NewCMCStepThreePage extends StatefulWidget {
|
|
|
|
@ -31,6 +36,12 @@ class NewCMCStepThreePage extends StatefulWidget {
|
|
|
|
|
class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
|
|
|
|
|
Completer<GoogleMapController> _controller = Completer();
|
|
|
|
|
|
|
|
|
|
String projectDropdownValue;
|
|
|
|
|
List<HospitalsModel> projectsList = [];
|
|
|
|
|
HospitalsModel selectedHospital;
|
|
|
|
|
final GlobalKey projectDropdownKey = GlobalKey();
|
|
|
|
|
bool isLocationSelected = false;
|
|
|
|
|
|
|
|
|
|
static CameraPosition _kGooglePlex = CameraPosition(
|
|
|
|
|
target: LatLng(37.42796133580664, -122.085749655962),
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
@ -53,6 +64,11 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
// if (projectViewModel.isLogin) {
|
|
|
|
|
getProjectsList();
|
|
|
|
|
// }
|
|
|
|
|
});
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -100,53 +116,136 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).orderDetails + " : ",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
letterSpacing: -0.46,
|
|
|
|
|
color: CustomColors.grey,
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
decoration: containerRadius(Colors.white, 12),
|
|
|
|
|
margin: EdgeInsets.only(top: 12),
|
|
|
|
|
padding: EdgeInsets.only(left: 0, right: 0, top: 0, bottom: 12),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).selectLocation,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
letterSpacing: -0.44,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: 18,
|
|
|
|
|
child: DropdownButtonHideUnderline(
|
|
|
|
|
child: DropdownButton<HospitalsModel>(
|
|
|
|
|
key: projectDropdownKey,
|
|
|
|
|
hint: new Text(TranslationBase.of(context).selectHospital),
|
|
|
|
|
value: selectedHospital,
|
|
|
|
|
iconSize: 0,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black),
|
|
|
|
|
items: projectsList.map((item) {
|
|
|
|
|
return new DropdownMenuItem<HospitalsModel>(
|
|
|
|
|
value: item,
|
|
|
|
|
child: new Text(item.name),
|
|
|
|
|
);
|
|
|
|
|
}).toList(),
|
|
|
|
|
onChanged: (newValue) async {
|
|
|
|
|
setState(() {
|
|
|
|
|
selectedHospital = newValue;
|
|
|
|
|
projectDropdownValue = newValue.mainProjectID.toString();
|
|
|
|
|
isLocationSelected = true;
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel.projectID = newValue.mainProjectID;
|
|
|
|
|
// getDoctorsList(context);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Icon(Icons.keyboard_arrow_down),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 6,
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 200,
|
|
|
|
|
decoration: containerColorRadiusBorder(Colors.white, 12, Colors.grey),
|
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: cardRadius(12),
|
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
|
margin: const EdgeInsets.all(0),
|
|
|
|
|
// child: GoogleMap(
|
|
|
|
|
// mapType: MapType.normal,
|
|
|
|
|
// markers: markers,
|
|
|
|
|
// initialCameraPosition: _kGooglePlex,
|
|
|
|
|
// onMapCreated: (GoogleMapController controller) {
|
|
|
|
|
// _controller.complete(controller);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
child: Image.network(
|
|
|
|
|
"https://maps.googleapis.com/maps/api/staticmap?center=" +
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel.latitude.toString() +
|
|
|
|
|
"," +
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel.longitude.toString() +
|
|
|
|
|
"&zoom=16&size=600x300&maptype=roadmap&markers=color:red%7C" +
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel.latitude.toString() +
|
|
|
|
|
"," +
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel.longitude.toString() +
|
|
|
|
|
"&key=AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8",
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
isLocationSelected
|
|
|
|
|
? Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
height: 200,
|
|
|
|
|
decoration: containerColorRadiusBorder(Colors.white, 12, Colors.grey),
|
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: cardRadius(12),
|
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
|
margin: const EdgeInsets.all(0),
|
|
|
|
|
child: Image.network(
|
|
|
|
|
"https://maps.googleapis.com/maps/api/staticmap?center=" +
|
|
|
|
|
selectedHospital.latitude.toString() +
|
|
|
|
|
"," +
|
|
|
|
|
selectedHospital.longitude.toString() +
|
|
|
|
|
"&zoom=16&size=600x300&maptype=roadmap&markers=color:red%7C" +
|
|
|
|
|
selectedHospital.latitude.toString() +
|
|
|
|
|
"," +
|
|
|
|
|
selectedHospital.longitude.toString() +
|
|
|
|
|
"&key=AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8",
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
getDirections();
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: cardRadius(1000),
|
|
|
|
|
margin: EdgeInsets.all(12),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 12, right: 12, top: 6, bottom: 6),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(3.0),
|
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
|
"assets/images/new/direction.svg",
|
|
|
|
|
width: 13,
|
|
|
|
|
height: 13,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
mWidth(6),
|
|
|
|
|
Text(
|
|
|
|
|
TranslationBase.of(context).getDirections,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
letterSpacing: -0.44,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 12,
|
|
|
|
|
),
|
|
|
|
@ -196,32 +295,89 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.9,
|
|
|
|
|
child: SecondaryButton(
|
|
|
|
|
label: TranslationBase.of(context).confirm,
|
|
|
|
|
color: CustomColors.green,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
String requestId = await widget.model.insertCMCOrderRC(order: widget.cmcInsertPresOrderRequestModel);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (widget.model.state != ViewState.ErrorLocal) {
|
|
|
|
|
//show scuccess dialog
|
|
|
|
|
showCMCConfirmDialog(
|
|
|
|
|
context,
|
|
|
|
|
requestId,
|
|
|
|
|
onClick: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: widget.model.error);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
textColor: Theme.of(context).backgroundColor),
|
|
|
|
|
child: DefaultButton(
|
|
|
|
|
TranslationBase.of(context).confirm,
|
|
|
|
|
!isLocationSelected
|
|
|
|
|
? null
|
|
|
|
|
: () async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
String requestId = await widget.model.insertCMCOrderRC(order: widget.cmcInsertPresOrderRequestModel);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (widget.model.state != ViewState.ErrorLocal) {
|
|
|
|
|
showCMCConfirmDialog(
|
|
|
|
|
context,
|
|
|
|
|
requestId,
|
|
|
|
|
onClick: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: widget.model.error);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
color: CustomColors.green,
|
|
|
|
|
disabledColor: CustomColors.grey,
|
|
|
|
|
),
|
|
|
|
|
// SecondaryButton(
|
|
|
|
|
// label: TranslationBase.of(context).confirm,
|
|
|
|
|
// color: CustomColors.green,
|
|
|
|
|
// onTap: () async {
|
|
|
|
|
// if(isLocationSelected) {
|
|
|
|
|
// GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
// String requestId = await widget.model.insertCMCOrderRC(order: widget.cmcInsertPresOrderRequestModel);
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
// if (widget.model.state != ViewState.ErrorLocal) {
|
|
|
|
|
// showCMCConfirmDialog(
|
|
|
|
|
// context,
|
|
|
|
|
// requestId,
|
|
|
|
|
// onClick: () {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
// },
|
|
|
|
|
// );
|
|
|
|
|
// } else {
|
|
|
|
|
// AppToast.showErrorToast(message: widget.model.error);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// Utils.showErrorToast("Please select hospital from the dropdown menu to continue");
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// textColor: Theme.of(context).backgroundColor),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDirections() {
|
|
|
|
|
if (isLocationSelected) {
|
|
|
|
|
MapsLauncher.launchCoordinates(double.parse(selectedHospital.latitude), double.parse(selectedHospital.longitude), selectedHospital.name);
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showErrorToast("Please select address from the dropdown menu to get directions");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getProjectsList() {
|
|
|
|
|
ClinicListService service = new ClinicListService();
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
List<HospitalsModel> projectsListLocal = [];
|
|
|
|
|
service.getProjectsList(context).then((res) {
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
setState(() {
|
|
|
|
|
res['ListProject'].forEach((v) {
|
|
|
|
|
projectsListLocal.add(new HospitalsModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
projectsList = projectsListLocal;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|