Files
bundesmessenger-ios/RiotSwiftUI/Modules/UserSessions/UserSession/UserSessionFlowCoordinator.swift
T
Aleksandrs Proskurins fa28df12f1 Added unit tests
2022-09-19 16:05:28 +03:00

79 lines
2.4 KiB
Swift

// File created from FlowTemplate
// $ createRootCoordinator.sh Folder UserSessionFlow UserSessionOverview
/*
Copyright 2021 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import CommonKit
import UIKit
struct UserSessionFlowCoordinatorParameters {
let session: MXSession
let navigationRouter: NavigationRouterType
let userSessionInfo: UserSessionInfo
}
final class UserSessionFlowCoordinator: Coordinator, Presentable {
// MARK: - Properties
// MARK: Private
private let parameters: UserSessionFlowCoordinatorParameters
private let userSessionDetailsViewHostingController: UIViewController
private var userSessionDetailsViewModel: UserSessionDetailsViewModel
private var navigationRouter: NavigationRouterType {
return self.parameters.navigationRouter
}
// MARK: Public
// Must be used only internally
var childCoordinators: [Coordinator] = []
// MARK: - Setup
init(parameters: UserSessionFlowCoordinatorParameters) {
self.parameters = parameters
let viewModel = UserSessionDetailsViewModel(userSessionInfo: parameters.userSessionInfo)
let view = UserSessionDetailsView(viewModel: viewModel.context)
userSessionDetailsViewModel = viewModel
userSessionDetailsViewHostingController = VectorHostingController(rootView: view)
}
// MARK: - Public
func start() {
// TODO: change to showUserSessionOverview()
showUserSessionDetails()
}
private func showUserSessionOverview() {
// TODO: PSG-690
}
private func showUserSessionDetails() {
self.navigationRouter.push(self.userSessionDetailsViewHostingController, animated: true, popCompletion: nil)
}
func toPresentable() -> UIViewController {
return self.navigationRouter.toPresentable()
}
// MARK: - Private
}