| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- //
- // Router.swift
- // SUIExamples
- //
- // Created by Pavel Yurchenko on 27.11.2024.
- //
- import Foundation
- import SwiftUI
- final class Router: ObservableObject {
- @Published
- var path = NavigationPath()
- func push(_ route: Route) {
- path.append(route)
- }
- func pop() {
- path.removeLast()
- }
- @ViewBuilder
- func buildDestination(_ route: Route) -> some View {
- switch route {
- case .main:
- MainBuilder().build(with: .init(onProducts: { [weak self] in
- self?.push(.products)
- }))
- case .products:
- ProductsBuilder().build(with: .init())
- case .product:
- MainBuilder().build(with: .init())
- case .cart:
- MainBuilder().build(with: .init())
- case .feedback:
- MainBuilder().build(with: .init())
- }
- }
- }
|