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()
|
2023-08-10 18:20:16 +02:00
|
|
|
|
|
|
|
@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 {
|
2023-08-10 18:20:16 +02:00
|
|
|
TabView(selection: $selected) {
|
2023-12-12 17:33:42 +01:00
|
|
|
ContentView(coordinator: coordinator, didLaunchFromComplication: $didLaunchFromComplication)
|
2023-08-10 18:20:16 +02:00
|
|
|
.tag(1)
|
2023-08-07 15:57:09 +02:00
|
|
|
SettingsView()
|
2023-08-09 16:29:18 +02:00
|
|
|
.environmentObject(keyManagement)
|
2023-08-10 18:20:16 +02:00
|
|
|
.tag(2)
|
2023-12-12 17:33:42 +01:00
|
|
|
HistoryView()
|
2023-08-10 18:20:16 +02:00
|
|
|
.tag(3)
|
2023-08-07 15:57:09 +02:00
|
|
|
}
|
|
|
|
.tabViewStyle(PageTabViewStyle())
|
2023-08-10 18:20:16 +02:00
|
|
|
.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
|
|
|
}
|
|
|
|
}
|