mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
da5360c8e8
* 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
73 lines
2.8 KiB
Swift
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))
|
|
}
|
|
}
|