|
|
|
|
@ -9,7 +9,6 @@ import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
@ -42,6 +41,8 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
double longitude = 0;
|
|
|
|
|
bool showCurrentLocation = false;
|
|
|
|
|
|
|
|
|
|
GoogleMapController mapController;
|
|
|
|
|
|
|
|
|
|
AppMap appMap;
|
|
|
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
|
static CameraPosition _kGooglePlex = CameraPosition(
|
|
|
|
|
@ -49,7 +50,7 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
);
|
|
|
|
|
LatLng currentPostion;
|
|
|
|
|
Completer<GoogleMapController> mapController = Completer();
|
|
|
|
|
// Completer<GoogleMapController> mapController = Completer();
|
|
|
|
|
Placemark selectedPlace;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -145,152 +146,156 @@ class _LocationPageState extends State<LocationPage> {
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
|
|
// PlacePicker(
|
|
|
|
|
// apiKey: GOOGLE_API_KEY,
|
|
|
|
|
// enableMyLocationButton: true,
|
|
|
|
|
// automaticallyImplyAppBarLeading: false,
|
|
|
|
|
// autocompleteOnTrailingWhitespace: true,
|
|
|
|
|
// selectInitialPosition: true,
|
|
|
|
|
// autocompleteLanguage: projectViewModel.currentLanguage,
|
|
|
|
|
// enableMapTypeButton: true,
|
|
|
|
|
// searchForInitialValue: false,
|
|
|
|
|
// onPlacePicked: (PickResult result) {
|
|
|
|
|
// print(result.adrAddress);
|
|
|
|
|
// },
|
|
|
|
|
// selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) {
|
|
|
|
|
// return isSearchBarFocused
|
|
|
|
|
// ? Container()
|
|
|
|
|
// : FloatingCard(
|
|
|
|
|
// bottomPosition: 0.0,
|
|
|
|
|
// leftPosition: 0.0,
|
|
|
|
|
// rightPosition: 0.0,
|
|
|
|
|
// width: 500,
|
|
|
|
|
// borderRadius: BorderRadius.circular(0.0),
|
|
|
|
|
// child: state == SearchingState.Searching
|
|
|
|
|
// ? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer
|
|
|
|
|
// : DefaultButton(TranslationBase.of(context).addNewAddress, () async {
|
|
|
|
|
// AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
|
|
|
|
|
// customer: Customer(addresses: [
|
|
|
|
|
// Addresses(
|
|
|
|
|
// address1: selectedPlace.formattedAddress,
|
|
|
|
|
// address2: selectedPlace.formattedAddress,
|
|
|
|
|
// customerAttributes: "",
|
|
|
|
|
// createdOnUtc: "",
|
|
|
|
|
// 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: "")
|
|
|
|
|
// ]),
|
|
|
|
|
// );
|
|
|
|
|
//
|
|
|
|
|
// selectedPlace.addressComponents.forEach((e) {
|
|
|
|
|
// if (e.types.contains("country")) {
|
|
|
|
|
// addNewAddressRequestModel.customer.addresses[0].country = e.longName;
|
|
|
|
|
// }
|
|
|
|
|
// if (e.types.contains("postal_code")) {
|
|
|
|
|
// addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
|
|
|
|
|
// }
|
|
|
|
|
// if (e.types.contains("locality")) {
|
|
|
|
|
// addNewAddressRequestModel.customer.addresses[0].city = e.longName;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// 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);
|
|
|
|
|
// }).insideContainer);
|
|
|
|
|
// },
|
|
|
|
|
// initialPosition: LatLng(latitude, longitude),
|
|
|
|
|
// useCurrentLocation: showCurrentLocation,
|
|
|
|
|
// ),
|
|
|
|
|
PlacePicker(
|
|
|
|
|
apiKey: GOOGLE_API_KEY,
|
|
|
|
|
enableMyLocationButton: true,
|
|
|
|
|
automaticallyImplyAppBarLeading: false,
|
|
|
|
|
autocompleteOnTrailingWhitespace: true,
|
|
|
|
|
selectInitialPosition: true,
|
|
|
|
|
autocompleteLanguage: projectViewModel.currentLanguage,
|
|
|
|
|
enableMapTypeButton: true,
|
|
|
|
|
searchForInitialValue: false,
|
|
|
|
|
onMapCreated: (GoogleMapController controller) {
|
|
|
|
|
mapController = controller;
|
|
|
|
|
},
|
|
|
|
|
onPlacePicked: (PickResult result) {
|
|
|
|
|
print(result.adrAddress);
|
|
|
|
|
},
|
|
|
|
|
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(0.0),
|
|
|
|
|
child: state == SearchingState.Searching
|
|
|
|
|
? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer
|
|
|
|
|
: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
|
|
|
|
|
AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
|
|
|
|
|
customer: Customer(addresses: [
|
|
|
|
|
Addresses(
|
|
|
|
|
address1: selectedPlace.formattedAddress,
|
|
|
|
|
address2: selectedPlace.formattedAddress,
|
|
|
|
|
customerAttributes: "",
|
|
|
|
|
createdOnUtc: "",
|
|
|
|
|
id: "0",
|
|
|
|
|
faxNumber: "",
|
|
|
|
|
phoneNumber: projectViewModel.user.mobileNumber,
|
|
|
|
|
countryId: 69,
|
|
|
|
|
latLong: selectedPlace.geometry.location.lat.toString() + "," + selectedPlace.geometry.location.lng.toString(),
|
|
|
|
|
email: projectViewModel.user.emailAddress)
|
|
|
|
|
// Addresses(
|
|
|
|
|
// address1: selectedPlace.formattedAddress,
|
|
|
|
|
// address2: selectedPlace.formattedAddress,
|
|
|
|
|
// customerAttributes: "",
|
|
|
|
|
// city: "",
|
|
|
|
|
// createdOnUtc: "",
|
|
|
|
|
// id: "0",
|
|
|
|
|
// latLong: "${selectedPlace.geometry.location}",
|
|
|
|
|
// email: "")
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
// FloatingCard(
|
|
|
|
|
// bottomPosition: 0.0,
|
|
|
|
|
// leftPosition: 0.0,
|
|
|
|
|
// rightPosition: 0.0,
|
|
|
|
|
// width: 500,
|
|
|
|
|
// borderRadius: BorderRadius.circular(0.0),
|
|
|
|
|
// // child: state == SearchingState.Searching
|
|
|
|
|
// // ? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer
|
|
|
|
|
// // :
|
|
|
|
|
// child: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
|
|
|
|
|
// AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
|
|
|
|
|
// customer: Customer(addresses: [
|
|
|
|
|
// // Addresses(
|
|
|
|
|
// // address1: selectedPlace.formattedAddress,
|
|
|
|
|
// // address2: selectedPlace.formattedAddress,
|
|
|
|
|
// // customerAttributes: "",
|
|
|
|
|
// // createdOnUtc: "",
|
|
|
|
|
// // 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: "")
|
|
|
|
|
// ]),
|
|
|
|
|
// );
|
|
|
|
|
//
|
|
|
|
|
// // selectedPlace.addressComponents.forEach((e) {
|
|
|
|
|
// // if (e.types.contains("country")) {
|
|
|
|
|
// // addNewAddressRequestModel.customer.addresses[0].country = e.longName;
|
|
|
|
|
// // }
|
|
|
|
|
// // if (e.types.contains("postal_code")) {
|
|
|
|
|
// // addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
|
|
|
|
|
// // }
|
|
|
|
|
// // if (e.types.contains("locality")) {
|
|
|
|
|
// // addNewAddressRequestModel.customer.addresses[0].city = e.longName;
|
|
|
|
|
// // }
|
|
|
|
|
// // });
|
|
|
|
|
//
|
|
|
|
|
// 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);
|
|
|
|
|
// }).insideContainer),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
selectedPlace.addressComponents.forEach((e) {
|
|
|
|
|
if (e.types.contains("country")) {
|
|
|
|
|
addNewAddressRequestModel.customer.addresses[0].country = e.longName;
|
|
|
|
|
}
|
|
|
|
|
if (e.types.contains("postal_code")) {
|
|
|
|
|
addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
|
|
|
|
|
}
|
|
|
|
|
if (e.types.contains("locality")) {
|
|
|
|
|
addNewAddressRequestModel.customer.addresses[0].city = e.longName;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}).insideContainer);
|
|
|
|
|
},
|
|
|
|
|
initialPosition: LatLng(latitude, longitude),
|
|
|
|
|
useCurrentLocation: showCurrentLocation,
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// // FloatingCard(
|
|
|
|
|
// // bottomPosition: 0.0,
|
|
|
|
|
// // leftPosition: 0.0,
|
|
|
|
|
// // rightPosition: 0.0,
|
|
|
|
|
// // width: 500,
|
|
|
|
|
// // borderRadius: BorderRadius.circular(0.0),
|
|
|
|
|
// // // child: state == SearchingState.Searching
|
|
|
|
|
// // // ? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer
|
|
|
|
|
// // // :
|
|
|
|
|
// // child: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
|
|
|
|
|
// // AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
|
|
|
|
|
// // customer: Customer(addresses: [
|
|
|
|
|
// // // Addresses(
|
|
|
|
|
// // // address1: selectedPlace.formattedAddress,
|
|
|
|
|
// // // address2: selectedPlace.formattedAddress,
|
|
|
|
|
// // // customerAttributes: "",
|
|
|
|
|
// // // createdOnUtc: "",
|
|
|
|
|
// // // 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: "")
|
|
|
|
|
// // ]),
|
|
|
|
|
// // );
|
|
|
|
|
// //
|
|
|
|
|
// // // selectedPlace.addressComponents.forEach((e) {
|
|
|
|
|
// // // if (e.types.contains("country")) {
|
|
|
|
|
// // // addNewAddressRequestModel.customer.addresses[0].country = e.longName;
|
|
|
|
|
// // // }
|
|
|
|
|
// // // if (e.types.contains("postal_code")) {
|
|
|
|
|
// // // addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
|
|
|
|
|
// // // }
|
|
|
|
|
// // // if (e.types.contains("locality")) {
|
|
|
|
|
// // // addNewAddressRequestModel.customer.addresses[0].city = e.longName;
|
|
|
|
|
// // // }
|
|
|
|
|
// // // });
|
|
|
|
|
// //
|
|
|
|
|
// // 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);
|
|
|
|
|
// // }).insideContainer),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|