I want to detect Settings Scene's on disappear/close event.
But when I watch scenePhase
of Settings
, nothing is printed.
@main
struct MyApp: App {
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
ContentView()
}
#if os(macOS)
Settings {
SettingsView()
}
.onChange(of: scenePhase) { newValue in
print(newValue)
}
#endif
}
}
Also ask on stackoverflow