krz/hutch

an ios client for sourcehut

clone: git clone https://gitbay.org/krz/hutch.git

v2.15.0: Hutch/App/HutchApp.swift · raw

 1import SwiftUI
 2
 3@main
 4struct HutchApp: App {
 5    @State private var appState = AppState()
 6    @State private var networkMonitor = NetworkMonitor()
 7
 8    var body: some Scene {
 9        WindowGroup {
10            RootView()
11                .environment(appState)
12                .environment(networkMonitor)
13                .onOpenURL { url in
14                    if let link = DeepLink(url: url) {
15                        appState.pendingDeepLink = link
16                    }
17                }
18                .onChange(of: HutchIntentNavigator.shared.pendingDestination) { _, destination in
19                    guard let destination else { return }
20                    HutchIntentNavigator.shared.pendingDestination = nil
21                    let link: DeepLink
22                    switch destination {
23                    case .home: link = .home
24                    case .inbox: link = .home
25                    case .builds: link = .buildsTab
26                    case .repositories: link = .repositoriesTab
27                    case .trackers: link = .trackersTab
28                    case .systemStatus: link = .systemStatus
29                    case .lookup: link = .lookup
30                    }
31                    appState.pendingDeepLink = link
32                }
33        }
34    }
35}