Sesame-iOS/Sesame-Watch Watch App/Sesame_WatchApp.swift

51 lines
1.3 KiB
Swift
Raw Normal View History

2023-08-07 15:57:09 +02:00
import SwiftUI
2023-12-12 17:33:42 +01:00
import SwiftData
2023-08-07 15:57:09 +02:00
@main
struct Sesame_Watch_Watch_AppApp: App {
2023-12-12 17:33:42 +01:00
@State
var modelContainer: ModelContainer
@ObservedObject
var coordinator: RequestCoordinator
2023-08-07 15:57:09 +02:00
let keyManagement = KeyManagement()
@State
var selected: Int = 0
@State
var didLaunchFromComplication = false
2023-08-07 15:57:09 +02:00
2023-12-12 17:33:42 +01:00
init() {
do {
let modelContainer = try ModelContainer(for: HistoryItem.self)
self.modelContainer = modelContainer
self.coordinator = .init(modelContext: modelContainer.mainContext)
} catch {
fatalError("Failed to create model container: \(error)")
}
}
2023-08-07 15:57:09 +02:00
var body: some Scene {
WindowGroup {
TabView(selection: $selected) {
2023-12-12 17:33:42 +01:00
ContentView(coordinator: coordinator, didLaunchFromComplication: $didLaunchFromComplication)
.tag(1)
2023-08-07 15:57:09 +02:00
SettingsView()
2023-08-09 16:29:18 +02:00
.environmentObject(keyManagement)
.tag(2)
2023-12-12 17:33:42 +01:00
HistoryView()
.tag(3)
2023-08-07 15:57:09 +02:00
}
.tabViewStyle(PageTabViewStyle())
.onOpenURL { url in
selected = 0
didLaunchFromComplication = true
}
2023-08-07 15:57:09 +02:00
}
2023-12-12 17:33:42 +01:00
.modelContainer(modelContainer)
2023-08-07 15:57:09 +02:00
}
}