Files
element-x-ios/ElementX/Sources/Screens/LocationSharing/LocationSharingScreenCoordinator.swift
Mauro da5360c8e8 Hide user dot and track own user marker in Live Location mode. (#5707)
* added a new tracking mode for following a marker and the logic for switching such tracking mode

* implemented the follow marker tracking mode

* improved and added new tests
2026-06-05 13:51:57 +02:00

73 lines
2.8 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2023-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Combine
import SwiftUI
struct LocationSharingScreenCoordinatorParameters {
let interactionMode: LocationSharingInteractionMode
let mapURLBuilder: MapTilerURLBuilderProtocol
let roomProxy: JoinedRoomProxyProtocol
let timelineController: TimelineControllerProtocol
let liveLocationManager: LiveLocationManagerProtocol
let appSettings: AppSettings
let appMediator: AppMediatorProtocol
let analytics: AnalyticsServiceProtocol
let userIndicatorController: UserIndicatorControllerProtocol
let mediaProvider: MediaProviderProtocol
}
enum LocationSharingScreenCoordinatorAction {
case close
}
final class LocationSharingScreenCoordinator: CoordinatorProtocol {
private let parameters: LocationSharingScreenCoordinatorParameters
private let viewModel: LocationSharingScreenViewModelProtocol
private let actionsSubject: PassthroughSubject<LocationSharingScreenCoordinatorAction, Never> = .init()
private var cancellables = Set<AnyCancellable>()
var actions: AnyPublisher<LocationSharingScreenCoordinatorAction, Never> {
actionsSubject.eraseToAnyPublisher()
}
init(parameters: LocationSharingScreenCoordinatorParameters) {
self.parameters = parameters
viewModel = LocationSharingScreenViewModel(interactionMode: parameters.interactionMode,
mapURLBuilder: parameters.mapURLBuilder,
roomProxy: parameters.roomProxy,
timelineController: parameters.timelineController,
liveLocationManager: parameters.liveLocationManager,
appSettings: parameters.appSettings,
analytics: parameters.analytics,
userIndicatorController: parameters.userIndicatorController,
mediaProvider: parameters.mediaProvider)
}
// MARK: - Public
func start() {
viewModel.actions.sink { [weak self] action in
guard let self else { return }
switch action {
case .close:
actionsSubject.send(.close)
case .openSystemSettings:
parameters.appMediator.openAppSettings()
}
}
.store(in: &cancellables)
}
func toPresentable() -> AnyView {
AnyView(LocationSharingScreen(context: viewModel.context))
}
}