mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Moves to monitoring changes in scene phase
This commit is contained in:
@@ -16,7 +16,6 @@ struct MainApp: App {
|
||||
#endif
|
||||
#if os(iOS)
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
#endif
|
||||
|
||||
@StateObject private var defaults = AppDefaults.shared
|
||||
@@ -87,10 +86,6 @@ struct MainApp: App {
|
||||
SceneNavigationView()
|
||||
.environmentObject(defaults)
|
||||
.modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette))
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
|
||||
print("didEnterBackgroundNotification")
|
||||
WidgetDataEncoder.encodeWidgetData()
|
||||
}
|
||||
}
|
||||
.commands {
|
||||
CommandGroup(after: .newItem, addition: {
|
||||
@@ -136,18 +131,6 @@ struct MainApp: App {
|
||||
.keyboardShortcut(.rightArrow, modifiers: [.command])
|
||||
})
|
||||
}
|
||||
.onChange(of: scenePhase, perform: { newPhase in
|
||||
switch newPhase {
|
||||
case .active:
|
||||
print("active")
|
||||
case .inactive:
|
||||
print("inactive")
|
||||
case .background:
|
||||
print("background")
|
||||
@unknown default:
|
||||
print("unknown")
|
||||
}
|
||||
})
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user