The X button is for closing your App. You can control the hidden logic for your view
Example
Check "The Solar System" scene in the sample project Hello World.
A NavigationStack View will show in default:
Click the "View Outer Space" button to trigger the full immersive mode and then the NavigationStack View is hidden:
The NavigationStack View will return after you click the "Exit the Solar System" button.
How to do?
This can be implemented by the .opacity modifier in SwiftUI. The "Hello World" sample uses the model.isShowingSolar to control the view's hidden state.
// The main navigation element for the app.
NavigationStack(path: $model.navigationPath) {
TableOfContents()
.navigationDestination(for: Module.self) { module in
ModuleDetail(module: module)
.navigationTitle(module.eyebrow)
}
}
.opacity(model.isShowingSolar ? 0 : 1)
Try it