Send app to background in OrganizerView handler

Keep handler in a single place.
This commit is contained in:
Davide De Rosa 2022-07-16 21:37:36 +02:00
parent 781291940f
commit 2c5f3d0bf0
2 changed files with 3 additions and 14 deletions

View File

@ -30,8 +30,6 @@ import PassepartoutLibrary
struct PassepartoutApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
@Environment(\.scenePhase) private var scenePhase
@SceneBuilder var body: some Scene {
WindowGroup {
MainView()
@ -44,18 +42,6 @@ struct PassepartoutApp: App {
.onIntentActivity(IntentDispatcher.trustCurrentNetwork)
.onIntentActivity(IntentDispatcher.untrustCellularNetwork)
.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
}
}
}

View File

@ -94,6 +94,9 @@ extension OrganizerView {
case .background:
persist()
#if targetEnvironment(macCatalyst)
MacBundle.shared.utils.sendAppToBackground()
#endif
default:
break