mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-11 13:59:13 +00:00

* New LICENSE-COMMERCIAL file * Apply dual licenses: AGPL + Element Commercial to file headers * Update README with dual licensing
55 lines
1.6 KiB
Swift
55 lines
1.6 KiB
Swift
//
|
|
// Copyright 2022-2024 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.
|
|
//
|
|
|
|
// periphery:ignore:all - this is just a template remove this comment once generating the final file
|
|
|
|
import Combine
|
|
import SwiftUI
|
|
|
|
struct TemplateScreenCoordinatorParameters { }
|
|
|
|
enum TemplateScreenCoordinatorAction {
|
|
case done
|
|
|
|
// Consider adding CustomStringConvertible conformance if the actions contain PII
|
|
}
|
|
|
|
final class TemplateScreenCoordinator: CoordinatorProtocol {
|
|
private let parameters: TemplateScreenCoordinatorParameters
|
|
private let viewModel: TemplateScreenViewModelProtocol
|
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
private let actionsSubject: PassthroughSubject<TemplateScreenCoordinatorAction, Never> = .init()
|
|
var actionsPublisher: AnyPublisher<TemplateScreenCoordinatorAction, Never> {
|
|
actionsSubject.eraseToAnyPublisher()
|
|
}
|
|
|
|
init(parameters: TemplateScreenCoordinatorParameters) {
|
|
self.parameters = parameters
|
|
|
|
viewModel = TemplateScreenViewModel()
|
|
}
|
|
|
|
func start() {
|
|
viewModel.actionsPublisher.sink { [weak self] action in
|
|
MXLog.info("Coordinator: received view model action: \(action)")
|
|
|
|
guard let self else { return }
|
|
switch action {
|
|
case .done:
|
|
actionsSubject.send(.done)
|
|
}
|
|
}
|
|
.store(in: &cancellables)
|
|
}
|
|
|
|
func toPresentable() -> AnyView {
|
|
AnyView(TemplateScreen(context: viewModel.context))
|
|
}
|
|
}
|