There is several objects in SwiftUI 2 like Scene and WindowGroup as some sort of Scene.
After reading documentation and looking WWDC2020 video related to scenes I see hierarchy by the following way :
Single App => One or multiple scenes => Hierarchy of Views (or a few)
Each scene contains the root view of a view hierarchy and has a life cycle managed by the system. Each scene can be displayed with different ways depends to the platform.
- In case of few children of WindowGroup scene - how it's choosing the way to display them? ( vertically / horizontally )? And how to control it manually?
I'm not sure that this is controlled with HStack and VStack because of in my test project I got different result instead expected by some reason.
How I can control Scene displayed? As example app have 2 scenes - each WindowGroup with 2 Views in it. How can I switch from one scene to another in the same window of macOS?
How to open second scene in new window using SwiftUI?
Why do we need WindowGroup at all? Isn't it a just a set of Views?
How to work with them in general?
Or where I can read more details than written in documentation or WWDC 1 min video (from 2.00 to 3.05) as there is not enough information to understand the topic.
so all you need to change view displayed is to send signal to change
displayedScene
.Another way is to do displayedScene as
EnvironmentVariable
. But in this case you will be able to work with ONLY ONE INSTANCE of window correctly. So this is a bad way. But can be OK for someone.handlesExternalEvents
. Sample:Why do we need WindowGroup at all? Isn't it a just a set of Views? -- It's telling to swiftUI that exactly this view can be shown as separated Window.
How to work with them in general? -- only with lot of hacks. Looks like SwiftUI is works really bad with MacOS.