mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Send pin-drop location (#1179)
* add location sharing action in room, and open location sharing screen * add pin location sharing * fix asset, add tests for location viewModel, add send location request * fix map zoom level, fix assets for location * add feature flag for location sharing * hide attribution button
This commit is contained in:
@@ -23,6 +23,7 @@ struct MapLibreMapView: UIViewRepresentable {
|
||||
|
||||
private enum Constants {
|
||||
static let mapZoomLevel = 15.0
|
||||
static let mapZoomLevelWithoutPermission = 5.0
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
@@ -36,12 +37,22 @@ struct MapLibreMapView: UIViewRepresentable {
|
||||
|
||||
/// Bind view errors if any
|
||||
let error: Binding<MapLibreError?>
|
||||
|
||||
/// Coordinate of the center of the map
|
||||
@Binding var mapCenterCoordinate: CLLocationCoordinate2D?
|
||||
|
||||
/// Called when the user pan on the map
|
||||
var userDidPan: (() -> Void)?
|
||||
|
||||
// MARK: - UIViewRepresentable
|
||||
|
||||
func makeUIView(context: Context) -> MGLMapView {
|
||||
let mapView = makeMapView()
|
||||
mapView.delegate = context.coordinator
|
||||
let panGesture = UIPanGestureRecognizer(target: context.coordinator, action: #selector(context.coordinator.didPan))
|
||||
panGesture.delegate = context.coordinator
|
||||
mapView.addGestureRecognizer(panGesture)
|
||||
mapView.zoomLevel = Constants.mapZoomLevelWithoutPermission
|
||||
return mapView
|
||||
}
|
||||
|
||||
@@ -65,12 +76,9 @@ struct MapLibreMapView: UIViewRepresentable {
|
||||
|
||||
private func makeMapView() -> MGLMapView {
|
||||
let mapView = MGLMapView(frame: .zero, styleURL: colorScheme == .dark ? builder.dynamicMapURL(for: .dark) : builder.dynamicMapURL(for: .light))
|
||||
|
||||
mapView.logoView.isHidden = true
|
||||
mapView.attributionButton.isHidden = true
|
||||
mapView.zoomLevel = Constants.mapZoomLevel
|
||||
|
||||
showUserLocation(in: mapView)
|
||||
mapView.attributionButton.isHidden = true
|
||||
|
||||
return mapView
|
||||
}
|
||||
@@ -134,7 +142,9 @@ extension MapLibreMapView {
|
||||
}
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool) { }
|
||||
func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {
|
||||
mapLibreView.mapCenterCoordinate = mapView.centerCoordinate
|
||||
}
|
||||
|
||||
// MARK: Callout
|
||||
|
||||
@@ -147,6 +157,11 @@ extension MapLibreMapView {
|
||||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
gestureRecognizer is UIPanGestureRecognizer
|
||||
}
|
||||
|
||||
@objc
|
||||
func didPan() {
|
||||
mapLibreView.userDidPan?()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user