-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApp.swift
More file actions
79 lines (66 loc) · 1.63 KB
/
App.swift
File metadata and controls
79 lines (66 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// App.swift
// RubyEvents
//
// Created by Marco Roth on 17.01.2025.
//
import HotwireNative
import SwiftUI
import UIKit
class App {
static var instance = App()
var isTabbed: Bool = true
var sceneDelegate: SceneDelegate?
lazy var tabBarController = HotwireTabBarController(navigatorDelegate: self)
var window: UIWindow? {
sceneDelegate?.window
}
var isDebug: Bool {
#if DEBUG
return true
#else
return false
#endif
}
var isTestFlight: Bool {
Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
}
var environment: Environment {
if isDebug {
return .development
}
if isTestFlight {
return .staging
}
return .production
}
func start(sceneDelegate: SceneDelegate) {
self.sceneDelegate = sceneDelegate
window?.rootViewController = tabBarController
Appearance.configure()
tabBarController.load(HotwireTab.all)
}
func hideNavigationBar() {
tabBarController.activeNavigator.rootViewController.navigationBar.isHidden = true
}
func showNavigationBar() {
tabBarController.activeNavigator.rootViewController.navigationBar.isHidden = false
}
}
extension App: NavigatorDelegate {
func handle(proposal: VisitProposal, from navigator: Navigator) -> ProposalResult {
switch proposal.viewController {
case "home":
let viewController = UIHostingController(
rootView: HomeView(
navigator: tabBarController.activeNavigator
)
)
hideNavigationBar()
return .acceptCustom(viewController)
default:
showNavigationBar()
return .accept
}
}
}