-
Notifications
You must be signed in to change notification settings - Fork 8
/
PocketApp.swift
37 lines (30 loc) · 1.05 KB
/
PocketApp.swift
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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
import PocketKit
import SwiftUI
import SwiftData
@main
struct PocketApp: App {
@UIApplicationDelegateAdaptor private var delegate: PocketAppDelegate
@Environment(\.scenePhase)
private var scenePhase
@StateObject private var rootViewModel: RootViewModel
private let modelContainer: ModelContainer
init() {
_rootViewModel = StateObject(wrappedValue: RootViewModel())
modelContainer = DataController().makeModelContainer()
}
var body: some Scene {
WindowGroup {
RootView(model: rootViewModel)
.onAppear {
PocketShortcuts.updateAppShortcutParameters()
}
}
.modelContainer(modelContainer)
.onChange(of: scenePhase) { oldScenePhase, newScenePhase in
rootViewModel.scenePhaseDidChange(newScenePhase)
}
}
}