mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
merged element-ios 1.10.5 into 4409_basis_update_1_10_5
This commit is contained in:
@@ -18,6 +18,15 @@ import Combine
|
||||
import Mapbox
|
||||
import SwiftUI
|
||||
|
||||
/*
|
||||
Behavior mode of the current user's location, can be hidden, only shown and shown following the user
|
||||
*/
|
||||
enum ShowUserLocationMode {
|
||||
case follow
|
||||
case show
|
||||
case hide
|
||||
}
|
||||
|
||||
struct LocationSharingMapView: UIViewRepresentable {
|
||||
// MARK: - Constants
|
||||
|
||||
@@ -39,8 +48,8 @@ struct LocationSharingMapView: UIViewRepresentable {
|
||||
/// Current user avatar data, used to replace current location annotation view with the user avatar
|
||||
let userAvatarData: AvatarInputProtocol?
|
||||
|
||||
/// True to indicate to show and follow current user location
|
||||
var showsUserLocation = false
|
||||
/// Behavior mode of the current user's location, can be hidden, only shown and shown following the user
|
||||
var showsUserLocationMode: ShowUserLocationMode = .hide
|
||||
|
||||
/// True to indicate that a touch on user annotation can show a callout
|
||||
var userAnnotationCanShowCallout = false
|
||||
@@ -75,14 +84,23 @@ struct LocationSharingMapView: UIViewRepresentable {
|
||||
mapView.vc_removeAllAnnotations()
|
||||
mapView.addAnnotations(annotations)
|
||||
|
||||
if let highlightedAnnotation = highlightedAnnotation {
|
||||
mapView.setCenter(highlightedAnnotation.coordinate, zoomLevel: Constants.mapZoomLevel, animated: false)
|
||||
/*
|
||||
if there is an highlighted annotation,
|
||||
and the current user's location it's either hidden or only shown,
|
||||
we can center to the highlighted annotation
|
||||
*/
|
||||
if let highlightedAnnotation = highlightedAnnotation, showsUserLocationMode != .follow {
|
||||
mapView.setCenter(highlightedAnnotation.coordinate, zoomLevel: Constants.mapZoomLevel, animated: true)
|
||||
}
|
||||
|
||||
if showsUserLocation {
|
||||
switch showsUserLocationMode {
|
||||
case .follow:
|
||||
mapView.showsUserLocation = true
|
||||
mapView.userTrackingMode = .follow
|
||||
} else {
|
||||
case .show:
|
||||
mapView.showsUserLocation = true
|
||||
mapView.userTrackingMode = .none
|
||||
case .hide:
|
||||
mapView.showsUserLocation = false
|
||||
mapView.userTrackingMode = .none
|
||||
}
|
||||
@@ -125,11 +143,14 @@ extension LocationSharingMapView {
|
||||
return LocationAnnotationView(userLocationAnnotation: userLocationAnnotation)
|
||||
} else if let pinLocationAnnotation = annotation as? PinLocationAnnotation {
|
||||
return LocationAnnotationView(pinLocationAnnotation: pinLocationAnnotation)
|
||||
} else if annotation is MGLUserLocation, let currentUserAvatarData = locationSharingMapView.userAvatarData {
|
||||
// Replace default current location annotation view with a UserLocationAnnotatonView when the map is center on user location
|
||||
return LocationAnnotationView(avatarData: currentUserAvatarData)
|
||||
} else if annotation is MGLUserLocation {
|
||||
if let currentUserAvatarData = locationSharingMapView.userAvatarData {
|
||||
// Replace default current location annotation view with a UserLocationAnnotatonView when the map is center on user location
|
||||
return LocationAnnotationView(avatarData: currentUserAvatarData)
|
||||
} else {
|
||||
return LocationAnnotationView(userPinLocationAnnotation: annotation)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user