Moves to monitoring changes in scene phase

This commit is contained in:
Stuart Breckenridge
2020-07-11 21:02:46 +08:00
parent 9991b3760e
commit c3d4834879
4 changed files with 17 additions and 21 deletions

View File

@@ -16,6 +16,7 @@ struct SceneNavigationView: View {
#if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Environment(\.scenePhase) private var scenePhase
#endif
var body: some View {
@@ -62,6 +63,13 @@ struct SceneNavigationView: View {
.onChange(of: sheetToShow) { value in
value != .none ? (showSheet = true) : (showSheet = false)
}
.onChange(of: scenePhase) { newPhase in
if newPhase == .background {
#if os(iOS)
WidgetDataEncoder.encodeWidgetData()
#endif
}
}
.toolbar {
#if os(macOS)