Fix model, delete if necessary
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
private enum MainScreenSelection: Int {
|
||||
case unlock = 0
|
||||
case settings = 1
|
||||
case history = 2
|
||||
}
|
||||
|
||||
@main
|
||||
struct Sesame_Watch_Watch_AppApp: App {
|
||||
struct SesameWatchApp: App {
|
||||
|
||||
@State
|
||||
var modelContainer: ModelContainer
|
||||
@@ -13,36 +19,32 @@ struct Sesame_Watch_Watch_AppApp: App {
|
||||
let keyManagement = KeyManagement()
|
||||
|
||||
@State
|
||||
var selected: Int = 0
|
||||
private var selectedScreen: MainScreenSelection = .unlock
|
||||
|
||||
@State
|
||||
var didLaunchFromComplication = false
|
||||
|
||||
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)")
|
||||
}
|
||||
let modelContainer = SesameWatchApp.loadModelContainer()
|
||||
self.modelContainer = modelContainer
|
||||
self.coordinator = .init(modelContext: modelContainer.mainContext)
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
TabView(selection: $selected) {
|
||||
TabView(selection: $selectedScreen) {
|
||||
ContentView(coordinator: coordinator, didLaunchFromComplication: $didLaunchFromComplication)
|
||||
.tag(1)
|
||||
.tag(MainScreenSelection.unlock)
|
||||
SettingsView()
|
||||
.environmentObject(keyManagement)
|
||||
.tag(2)
|
||||
.tag(MainScreenSelection.settings)
|
||||
HistoryView()
|
||||
.tag(3)
|
||||
.tag(MainScreenSelection.history)
|
||||
}
|
||||
.tabViewStyle(PageTabViewStyle())
|
||||
.onOpenURL { url in
|
||||
selected = 0
|
||||
didLaunchFromComplication = true
|
||||
selectedScreen = .unlock
|
||||
}
|
||||
}
|
||||
.modelContainer(modelContainer)
|
||||
|
Reference in New Issue
Block a user