40 lines
1.0 KiB
Swift
40 lines
1.0 KiB
Swift
//
|
|
// SettingsCoordinator.swift
|
|
// AutoCat
|
|
//
|
|
// Created by Selim Mustafaev on 17.08.2024.
|
|
// Copyright © 2024 Selim Mustafaev. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import SwiftUI
|
|
import AutoCatCore
|
|
|
|
@MainActor
|
|
class SettingsCoordinator {
|
|
|
|
weak var tabController: UITabBarController?
|
|
|
|
init(tabController: UITabBarController) {
|
|
|
|
self.tabController = tabController
|
|
}
|
|
|
|
func start() -> UIViewController {
|
|
|
|
let viewModel = SettingsViewModel(settingsService: ServiceContainer.shared.resolve(SettingsServiceProtocol.self))
|
|
viewModel.coordinator = self
|
|
let controller = UIHostingController(rootView: SettingsScreen(viewModel: viewModel))
|
|
return UINavigationController(rootViewController: controller)
|
|
}
|
|
|
|
func openAuthScreen() {
|
|
guard let window = tabController?.tabBar.window else {
|
|
return
|
|
}
|
|
|
|
let coordinator = AuthCoordinator(window: window)
|
|
window.rootViewController = coordinator.start()
|
|
}
|
|
}
|