|
|
|
|
@ -1,16 +1,21 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/app_map/google_huawei_map.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:geocoding/geocoding.dart';
|
|
|
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
|
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
@ -32,6 +37,16 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
double longitude = 0;
|
|
|
|
|
bool showCurrentLocation = false;
|
|
|
|
|
|
|
|
|
|
AppMap appMap;
|
|
|
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
|
static CameraPosition _kGooglePlex = CameraPosition(
|
|
|
|
|
target: LatLng(37.42796133580664, -122.085749655962),
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
);
|
|
|
|
|
LatLng currentPostion;
|
|
|
|
|
Completer<GoogleMapController> mapController = Completer();
|
|
|
|
|
Placemark selectedPlace;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
latitude = widget.latitude;
|
|
|
|
|
@ -39,6 +54,23 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
if (latitude == 0.0 && longitude == 0.0) {
|
|
|
|
|
showCurrentLocation = true;
|
|
|
|
|
}
|
|
|
|
|
appMap = AppMap(
|
|
|
|
|
_kGooglePlex.toMap(),
|
|
|
|
|
onCameraMove: (camera) {
|
|
|
|
|
_updatePosition(camera);
|
|
|
|
|
},
|
|
|
|
|
onMapCreated: () {
|
|
|
|
|
currentPostion = LatLng(widget.latitude, widget.longitude);
|
|
|
|
|
latitude = widget.latitude;
|
|
|
|
|
longitude = widget.longitude;
|
|
|
|
|
setMap();
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
onCameraIdle: () async {
|
|
|
|
|
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
|
|
|
|
|
selectedPlace = placemarks[0];
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -54,7 +86,60 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
showNewAppBarTitle: true,
|
|
|
|
|
showNewAppBar: true,
|
|
|
|
|
body: PlacePicker(
|
|
|
|
|
body:
|
|
|
|
|
// Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// Expanded(
|
|
|
|
|
// child: Stack(
|
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
|
// children: [
|
|
|
|
|
// if (appMap != null) appMap,
|
|
|
|
|
// Container(
|
|
|
|
|
// margin: EdgeInsets.only(bottom: 50.0),
|
|
|
|
|
// child: Icon(
|
|
|
|
|
// Icons.place,
|
|
|
|
|
// color: CustomColors.accentColor,
|
|
|
|
|
// size: 50,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// Container(
|
|
|
|
|
// padding: const EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
|
|
|
|
|
// child: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
|
|
|
|
|
// AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
|
|
|
|
|
// customer: Customer(addresses: [
|
|
|
|
|
// Addresses(
|
|
|
|
|
// address1: selectedPlace.name,
|
|
|
|
|
// address2: selectedPlace.street,
|
|
|
|
|
// customerAttributes: "",
|
|
|
|
|
// city: selectedPlace.locality,
|
|
|
|
|
// createdOnUtc: "",
|
|
|
|
|
// id: "0",
|
|
|
|
|
// faxNumber: "",
|
|
|
|
|
// phoneNumber: projectViewModel.user.mobileNumber,
|
|
|
|
|
// province: selectedPlace.locality,
|
|
|
|
|
// countryId: 69,
|
|
|
|
|
// latLong: "$latitude,$longitude",
|
|
|
|
|
// country: selectedPlace.country,
|
|
|
|
|
// zipPostalCode: selectedPlace.postalCode,
|
|
|
|
|
// email: projectViewModel.user.emailAddress)
|
|
|
|
|
// ]),
|
|
|
|
|
// );
|
|
|
|
|
// await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
|
|
|
|
|
// if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
// Utils.showErrorToast(model.error);
|
|
|
|
|
// } else {
|
|
|
|
|
// AppToast.showSuccessToast(message: "Address Added Successfully");
|
|
|
|
|
// }
|
|
|
|
|
// Navigator.of(context).pop(addNewAddressRequestModel);
|
|
|
|
|
// }),
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
|
|
PlacePicker(
|
|
|
|
|
apiKey: GOOGLE_API_KEY,
|
|
|
|
|
enableMyLocationButton: true,
|
|
|
|
|
automaticallyImplyAppBarLeading: false,
|
|
|
|
|
@ -76,7 +161,7 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
width: 500,
|
|
|
|
|
borderRadius: BorderRadius.circular(0.0),
|
|
|
|
|
child: state == SearchingState.Searching
|
|
|
|
|
? SizedBox(height: 43,child: Center(child: CircularProgressIndicator())).insideContainer
|
|
|
|
|
? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer
|
|
|
|
|
: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
|
|
|
|
|
AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
|
|
|
|
|
customer: Customer(addresses: [
|
|
|
|
|
@ -84,11 +169,22 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
address1: selectedPlace.formattedAddress,
|
|
|
|
|
address2: selectedPlace.formattedAddress,
|
|
|
|
|
customerAttributes: "",
|
|
|
|
|
city: "",
|
|
|
|
|
createdOnUtc: "",
|
|
|
|
|
id: 0,
|
|
|
|
|
latLong: "${selectedPlace.geometry.location}",
|
|
|
|
|
email: "")
|
|
|
|
|
id: "0",
|
|
|
|
|
faxNumber: "",
|
|
|
|
|
phoneNumber: projectViewModel.user.mobileNumber,
|
|
|
|
|
countryId: 69,
|
|
|
|
|
latLong: "$latitude,$longitude",
|
|
|
|
|
email: projectViewModel.user.emailAddress)
|
|
|
|
|
// Addresses(
|
|
|
|
|
// address1: selectedPlace.formattedAddress,
|
|
|
|
|
// address2: selectedPlace.formattedAddress,
|
|
|
|
|
// customerAttributes: "",
|
|
|
|
|
// city: "",
|
|
|
|
|
// createdOnUtc: "",
|
|
|
|
|
// id: "0",
|
|
|
|
|
// latLong: "${selectedPlace.geometry.location}",
|
|
|
|
|
// email: "")
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@ -111,8 +207,7 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
AppToast.showSuccessToast(message: "Address Added Successfully");
|
|
|
|
|
}
|
|
|
|
|
Navigator.of(context).pop(addNewAddressRequestModel);
|
|
|
|
|
}).insideContainer
|
|
|
|
|
);
|
|
|
|
|
}).insideContainer);
|
|
|
|
|
},
|
|
|
|
|
initialPosition: LatLng(latitude, longitude),
|
|
|
|
|
useCurrentLocation: showCurrentLocation,
|
|
|
|
|
@ -120,4 +215,19 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setMap() {
|
|
|
|
|
setState(() {
|
|
|
|
|
_kGooglePlex = CameraPosition(
|
|
|
|
|
target: currentPostion,
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
);
|
|
|
|
|
appMap.moveTo(cameraPostion: _kGooglePlex);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _updatePosition(CameraPosition _position) {
|
|
|
|
|
latitude = _position.target.latitude;
|
|
|
|
|
longitude = _position.target.longitude;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|