mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
LLS Sheet implementation (#5420)
* Add LiveLocationSheet and refactor existing views to share code * Implement logic for highlighting a specific LLS from a user once selected in the sheet * Updated tests, project and added new previews for the LLS sheet. # Conflicts: # PreviewTests/Sources/__Snapshots__/PreviewTests/liveLocationRoomTimelineView.Bubbles-iPad-pseudo.png # PreviewTests/Sources/__Snapshots__/PreviewTests/liveLocationRoomTimelineView.Bubbles-iPhone-pseudo.png * add Equatable conformance to CLLocationCoordinate2D
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import CoreLocation
|
||||
|
||||
extension CLLocationCoordinate2D: @retroactive Equatable {
|
||||
public static func == (lhs: Self, rhs: Self) -> Bool {
|
||||
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,13 @@ struct MapLibreMapView: UIViewRepresentable {
|
||||
mapView.styleURL = dynamicMapURL
|
||||
}
|
||||
|
||||
// If the center coordinate was updated externally (not by the map itself), move the map.
|
||||
if let newCenter = mapCenterCoordinate,
|
||||
newCenter != context.coordinator.lastReportedCenter {
|
||||
context.coordinator.lastReportedCenter = newCenter
|
||||
mapView.setCenter(newCenter, animated: true)
|
||||
}
|
||||
|
||||
// Update existing annotation views with fresh SwiftUI content.
|
||||
// This handles the case where the annotation's view data changes after
|
||||
// the annotation was initially placed (e.g. user avatar loads asynchronously).
|
||||
@@ -169,6 +176,9 @@ extension MapLibreMapView {
|
||||
var mapLibreView: MapLibreMapView
|
||||
|
||||
private var previousUserLocation: MLNUserLocation?
|
||||
/// Tracks the last center coordinate reported by the map (or set programmatically),
|
||||
/// so that `updateUIView` can tell apart external binding changes from internal ones.
|
||||
var lastReportedCenter: CLLocationCoordinate2D?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
@@ -220,8 +230,10 @@ extension MapLibreMapView {
|
||||
|
||||
func mapView(_ mapView: MLNMapView, regionDidChangeAnimated animated: Bool) {
|
||||
// Avoid `Publishing changes from within view update` warnings
|
||||
DispatchQueue.main.async { [mapLibreView] in
|
||||
mapLibreView.mapCenterCoordinate = mapView.centerCoordinate
|
||||
DispatchQueue.main.async { [mapLibreView, weak self] in
|
||||
let center = mapView.centerCoordinate
|
||||
self?.lastReportedCenter = center
|
||||
mapLibreView.mapCenterCoordinate = center
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct StopButton: View {
|
||||
let stopAction: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button { stopAction() } label: {
|
||||
CompoundIcon(\.stop, size: .small, relativeTo: .compound.bodySMSemibold)
|
||||
.foregroundStyle(.compound.iconOnSolidPrimary)
|
||||
.padding(8)
|
||||
.background(Color.compound.bgCriticalPrimary, in: Circle())
|
||||
.accessibilityLabel(L10n.actionStop)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@ enum TestablePreviewsDictionary {
|
||||
"LinkNewDeviceScreen_Previews" : LinkNewDeviceScreen_Previews.self,
|
||||
"LiveLocationRoomTimelineView_Previews" : LiveLocationRoomTimelineView_Previews.self,
|
||||
"LiveLocationSharingBannerView_Previews" : LiveLocationSharingBannerView_Previews.self,
|
||||
"LiveLocationSheet_Previews" : LiveLocationSheet_Previews.self,
|
||||
"LoadableImage_Previews" : LoadableImage_Previews.self,
|
||||
"LocationMarkerView_Previews" : LocationMarkerView_Previews.self,
|
||||
"LocationPickerSheet_Previews" : LocationPickerSheet_Previews.self,
|
||||
@@ -214,6 +215,7 @@ enum TestablePreviewsDictionary {
|
||||
"UserDetailsEditScreen_Previews" : UserDetailsEditScreen_Previews.self,
|
||||
"UserIndicatorModalView_Previews" : UserIndicatorModalView_Previews.self,
|
||||
"UserIndicatorToastView_Previews" : UserIndicatorToastView_Previews.self,
|
||||
"UserLocationCell_Previews" : UserLocationCell_Previews.self,
|
||||
"UserProfileCell_Previews" : UserProfileCell_Previews.self,
|
||||
"UserProfileScreen_Previews" : UserProfileScreen_Previews.self,
|
||||
"VerificationBadge_Previews" : VerificationBadge_Previews.self,
|
||||
|
||||
Reference in New Issue
Block a user