| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- //
- // ApplicationCoordinator.swift
- // SUIExamples
- //
- // Created by Pavel Yurchenko on 28.11.2024.
- //
- import CoordinatorSUI
- import SwiftUI
- final class ApplicationCoordinator: BaseCoordinator {
- static var rootRouter = Router()
- override init() {
- super.init()
- self.currentRouter = Self.rootRouter
- }
- func run() -> some View {
- runMainFlow()
- }
- func buildDestination(_ route: Route) -> some View {
- guard let coordinator = currentCoordinator as? MainCoordinator else {
- fatalError("Invalid coordinator type")
- }
- return coordinator.buildDestination(route)
- }
- // MARK: - Private methods
- private func runMainFlow() -> some View {
- let coordinator = MainCoordinator(router: self.currentRouter)
- addChild(coordinator)
- coordinator.finishFlow = { [weak self] in
- self?.removeChild(coordinator)
- }
- return coordinator.run()
- }
- }
|