Send app to background in OrganizerView handler
Keep handler in a single place.
This commit is contained in:
parent
781291940f
commit
2c5f3d0bf0
|
@ -30,8 +30,6 @@ import PassepartoutLibrary
|
||||||
struct PassepartoutApp: App {
|
struct PassepartoutApp: App {
|
||||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||||
|
|
||||||
@Environment(\.scenePhase) private var scenePhase
|
|
||||||
|
|
||||||
@SceneBuilder var body: some Scene {
|
@SceneBuilder var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
MainView()
|
MainView()
|
||||||
|
@ -44,18 +42,6 @@ struct PassepartoutApp: App {
|
||||||
.onIntentActivity(IntentDispatcher.trustCurrentNetwork)
|
.onIntentActivity(IntentDispatcher.trustCurrentNetwork)
|
||||||
.onIntentActivity(IntentDispatcher.untrustCellularNetwork)
|
.onIntentActivity(IntentDispatcher.untrustCellularNetwork)
|
||||||
.onIntentActivity(IntentDispatcher.untrustCurrentNetwork)
|
.onIntentActivity(IntentDispatcher.untrustCurrentNetwork)
|
||||||
}.onChange(of: scenePhase, perform: onScenePhase)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func onScenePhase(_ scenePhase: ScenePhase) {
|
|
||||||
switch scenePhase {
|
|
||||||
case .background:
|
|
||||||
#if targetEnvironment(macCatalyst)
|
|
||||||
MacBundle.shared.utils.sendAppToBackground()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,9 @@ extension OrganizerView {
|
||||||
|
|
||||||
case .background:
|
case .background:
|
||||||
persist()
|
persist()
|
||||||
|
#if targetEnvironment(macCatalyst)
|
||||||
|
MacBundle.shared.utils.sendAppToBackground()
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue