I am trying to implement the new Commands for iPadOS 15 and to do that you have to declare them in the App like the following example
@main
struct I_FeelApp: App {
@State private var sceneCommands = GlobalCommands()
var body: some Scene {
WindowGroup {
ContentView(globalCommands: sceneCommands)
}
.commands(content: { sceneCommands.commands })
}
}
The problem I have with this approach is that the object GlobalCommands()
is created for the entire App not for every scene, so a change in one of the scenes will modify all of them like in the following example
I have tried to create a new scene struct and create there the commands, but SwiftUI creates it for the App, no for the Scene
Creating it in a normal View doesn't work, because I can't add commands to the a View, only to a Scene