|
|
|
@ -1,9 +1,14 @@
|
|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.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/service/AlHabibMedicalService/customer_addresses_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/location_util.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/location_util.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
import 'package:diplomaticquarterapp/widgets/dialogs/select_location_dialog.dart';
|
|
|
|
import 'package:diplomaticquarterapp/widgets/dialogs/select_location_dialog.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
@ -18,24 +23,16 @@ import 'package:google_maps_place_picker/google_maps_place_picker.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'cmc_location_page.dart';
|
|
|
|
import 'cmc_location_page.dart';
|
|
|
|
|
|
|
|
import 'new_cmc_step_three_page.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class NewCMCStepTowPage extends StatefulWidget {
|
|
|
|
class NewCMCStepTowPage extends StatefulWidget {
|
|
|
|
final Function(PickResult) onPick;
|
|
|
|
final Function(PickResult) onPick;
|
|
|
|
final double latitude;
|
|
|
|
final double latitude;
|
|
|
|
final double longitude;
|
|
|
|
final double longitude;
|
|
|
|
final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel;
|
|
|
|
final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel;
|
|
|
|
final Function changePageViewIndex;
|
|
|
|
|
|
|
|
final CMCViewModel model;
|
|
|
|
final CMCViewModel model;
|
|
|
|
|
|
|
|
|
|
|
|
const NewCMCStepTowPage(
|
|
|
|
const NewCMCStepTowPage({Key key, this.onPick, this.latitude, this.longitude, this.cmcInsertPresOrderRequestModel, this.model}) : super(key: key);
|
|
|
|
{Key key,
|
|
|
|
|
|
|
|
this.onPick,
|
|
|
|
|
|
|
|
this.latitude,
|
|
|
|
|
|
|
|
this.longitude,
|
|
|
|
|
|
|
|
this.cmcInsertPresOrderRequestModel,
|
|
|
|
|
|
|
|
this.changePageViewIndex,
|
|
|
|
|
|
|
|
this.model})
|
|
|
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
_NewCMCStepTowPageState createState() => _NewCMCStepTowPageState();
|
|
|
|
_NewCMCStepTowPageState createState() => _NewCMCStepTowPageState();
|
|
|
|
@ -47,6 +44,14 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
|
|
|
|
AddressInfo _selectedAddress;
|
|
|
|
AddressInfo _selectedAddress;
|
|
|
|
bool showCurrentLocation = false;
|
|
|
|
bool showCurrentLocation = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Completer<GoogleMapController> _controller = Completer();
|
|
|
|
|
|
|
|
static CameraPosition _kGooglePlex = CameraPosition(
|
|
|
|
|
|
|
|
target: LatLng(37.42796133580664, -122.085749655962),
|
|
|
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Set<Marker> markers = new Set();
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
if (widget.cmcInsertPresOrderRequestModel.latitude == null) {
|
|
|
|
if (widget.cmcInsertPresOrderRequestModel.latitude == null) {
|
|
|
|
@ -54,29 +59,43 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
latitude = widget.cmcInsertPresOrderRequestModel.latitude;
|
|
|
|
latitude = widget.cmcInsertPresOrderRequestModel.latitude;
|
|
|
|
longitude = widget.cmcInsertPresOrderRequestModel.longitude;
|
|
|
|
longitude = widget.cmcInsertPresOrderRequestModel.longitude;
|
|
|
|
|
|
|
|
setMap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setLatitudeAndLongitude({bool isSetState = false, String latLong}) async {
|
|
|
|
setMap() {
|
|
|
|
if (latLong == null){
|
|
|
|
markers.clear();
|
|
|
|
if(widget.model.addressesList.isEmpty) {
|
|
|
|
markers.add(
|
|
|
|
|
|
|
|
Marker(
|
|
|
|
|
|
|
|
markerId: MarkerId(
|
|
|
|
|
|
|
|
latitude.hashCode.toString(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
position: LatLng(latitude, longitude)),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
_kGooglePlex = CameraPosition(
|
|
|
|
|
|
|
|
target: LatLng(latitude, longitude),
|
|
|
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setLatitudeAndLongitude({bool isSetState = false, String latLong}) async {
|
|
|
|
|
|
|
|
if (latLong == null) {
|
|
|
|
|
|
|
|
if (widget.model.addressesList.isEmpty) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
showCurrentLocation = true;
|
|
|
|
showCurrentLocation = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
latLong = widget
|
|
|
|
latLong = widget.model.addressesList[widget.model.addressesList.length - 1].latLong;
|
|
|
|
.model.addressesList[widget.model.addressesList.length - 1].latLong;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!showCurrentLocation) {
|
|
|
|
if (!showCurrentLocation) {
|
|
|
|
List latLongArr = latLong.split(',');
|
|
|
|
List latLongArr = latLong.split(',');
|
|
|
|
|
|
|
|
|
|
|
|
latitude = double.parse(latLongArr[0]);
|
|
|
|
latitude = double.parse(latLongArr[0]);
|
|
|
|
longitude = double.parse(latLongArr[1]);
|
|
|
|
longitude = double.parse(latLongArr[1]);
|
|
|
|
|
|
|
|
setMap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,113 +103,119 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
return AppScaffold(
|
|
|
|
return AppScaffold(
|
|
|
|
isShowDecPage: false,
|
|
|
|
isShowAppBar: true,
|
|
|
|
body: Stack(
|
|
|
|
description: TranslationBase.of(context).infoCMC,
|
|
|
|
|
|
|
|
imagesInfo: [
|
|
|
|
|
|
|
|
ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
appBarTitle: TranslationBase.of(context).comprehensiveMedicalCheckup,
|
|
|
|
|
|
|
|
showNewAppBar: true,
|
|
|
|
|
|
|
|
showNewAppBarTitle: true,
|
|
|
|
|
|
|
|
backgroundColor: CustomColors.appBackgroudGreyColor,
|
|
|
|
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
PlacePicker(
|
|
|
|
if (widget.model.addressesList.isNotEmpty)
|
|
|
|
apiKey: GOOGLE_API_KEY,
|
|
|
|
Card(
|
|
|
|
enableMyLocationButton: true,
|
|
|
|
margin: EdgeInsets.only(left: 12, right: 12, bottom: 12),
|
|
|
|
automaticallyImplyAppBarLeading: false,
|
|
|
|
shape: cardRadius(12),
|
|
|
|
autocompleteOnTrailingWhitespace: true,
|
|
|
|
elevation: 3,
|
|
|
|
selectInitialPosition: true,
|
|
|
|
|
|
|
|
autocompleteLanguage: projectViewModel.currentLanguage,
|
|
|
|
|
|
|
|
enableMapTypeButton: true,
|
|
|
|
|
|
|
|
searchForInitialValue: false,
|
|
|
|
|
|
|
|
onPlacePicked: (PickResult result) {
|
|
|
|
|
|
|
|
print(result.adrAddress);
|
|
|
|
|
|
|
|
widget.changePageViewIndex(3);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
selectedPlaceWidgetBuilder:
|
|
|
|
|
|
|
|
(_, selectedPlace, state, isSearchBarFocused) {
|
|
|
|
|
|
|
|
print("state: $state, isSearchBarFocused: $isSearchBarFocused");
|
|
|
|
|
|
|
|
return isSearchBarFocused
|
|
|
|
|
|
|
|
? Container()
|
|
|
|
|
|
|
|
: FloatingCard(
|
|
|
|
|
|
|
|
bottomPosition: 0.0,
|
|
|
|
|
|
|
|
leftPosition: 0.0,
|
|
|
|
|
|
|
|
rightPosition: 0.0,
|
|
|
|
|
|
|
|
width: 500,
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12.0),
|
|
|
|
|
|
|
|
child: state == SearchingState.Searching
|
|
|
|
|
|
|
|
? Center(child: CircularProgressIndicator())
|
|
|
|
|
|
|
|
: Container(
|
|
|
|
|
|
|
|
margin: EdgeInsets.all(12),
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
SecondaryButton(
|
|
|
|
|
|
|
|
color: Colors.grey[800],
|
|
|
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
FadePage(
|
|
|
|
|
|
|
|
page: CMCLocationPage(
|
|
|
|
|
|
|
|
latitude: latitude,
|
|
|
|
|
|
|
|
longitude: longitude,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
label: TranslationBase.of(context)
|
|
|
|
|
|
|
|
.addNewAddress,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 10,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SecondaryButton(
|
|
|
|
|
|
|
|
color: Colors.red[800],
|
|
|
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel
|
|
|
|
|
|
|
|
.latitude =
|
|
|
|
|
|
|
|
selectedPlace.geometry.location.lat;
|
|
|
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel
|
|
|
|
|
|
|
|
.longitude =
|
|
|
|
|
|
|
|
selectedPlace.geometry.location.lng;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
widget.changePageViewIndex(3);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
label: TranslationBase.of(context).confirm,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
initialPosition: LatLng(latitude, longitude),
|
|
|
|
|
|
|
|
useCurrentLocation: showCurrentLocation,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
if(widget.model.addressesList.isNotEmpty)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
child: InkWell(
|
|
|
|
|
|
|
|
onTap: () =>
|
|
|
|
|
|
|
|
confirmSelectLocationDialog(widget.model.addressesList),
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
child: InkWell(
|
|
|
|
width: double.infinity,
|
|
|
|
onTap: () => confirmSelectLocationDialog(widget.model.addressesList),
|
|
|
|
// height: 65,
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
width: double.infinity,
|
|
|
|
color: Theme.of(context).primaryColor),
|
|
|
|
// height: 65,
|
|
|
|
child: Row(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
children: [
|
|
|
|
color: Colors.white,
|
|
|
|
Expanded(
|
|
|
|
),
|
|
|
|
child: Texts(
|
|
|
|
child: Row(
|
|
|
|
getAddressName(),
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
fontSize: 14,
|
|
|
|
children: [
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
getAddressName(),
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
|
|
letterSpacing: -0.45,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Icon(Icons.arrow_drop_down)
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Icon(Icons.arrow_drop_down)
|
|
|
|
),
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
height: 50,
|
|
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
InkWell(
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
FadePage(
|
|
|
|
|
|
|
|
page: CMCLocationPage(
|
|
|
|
|
|
|
|
latitude: latitude,
|
|
|
|
|
|
|
|
longitude: longitude,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.only(left: 12, right: 12, bottom: 16, top: 8),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Icon(Icons.add_circle_outline_sharp),
|
|
|
|
|
|
|
|
mWidth(12),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
TranslationBase.of(context).addNewAddress,
|
|
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
|
|
letterSpacing: -0.46,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
height: 56,
|
|
|
|
),
|
|
|
|
width: double.infinity,
|
|
|
|
Expanded(
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
child: GoogleMap(
|
|
|
|
)
|
|
|
|
mapType: MapType.normal,
|
|
|
|
|
|
|
|
markers: markers,
|
|
|
|
|
|
|
|
zoomControlsEnabled: false,
|
|
|
|
|
|
|
|
initialCameraPosition: _kGooglePlex,
|
|
|
|
|
|
|
|
onMapCreated: (GoogleMapController controller) {
|
|
|
|
|
|
|
|
_controller.complete(controller);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
|
|
|
|
|
|
|
|
child: SecondaryButton(
|
|
|
|
|
|
|
|
color: Colors.red[800],
|
|
|
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel.latitude = latitude;
|
|
|
|
|
|
|
|
widget.cmcInsertPresOrderRequestModel.longitude = longitude;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// widget.changePageViewIndex(3);
|
|
|
|
|
|
|
|
navigateTo(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
NewCMCStepThreePage(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmcInsertPresOrderRequestModel: widget.cmcInsertPresOrderRequestModel,
|
|
|
|
|
|
|
|
model: widget.model,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
label: TranslationBase.of(context).continues,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|