Prevent the system from automatically hiding the sidebar when backgrounding the app
This commit is contained in:
committed by
Stefan Ceriu
parent
f2a24853b4
commit
a49cc47936
@@ -329,6 +329,7 @@ private struct NavigationSplitCoordinatorView: View {
|
||||
@State private var columnVisibility = NavigationSplitViewVisibility.all
|
||||
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
@Bindable var navigationSplitCoordinator: NavigationSplitCoordinator
|
||||
|
||||
@@ -352,6 +353,12 @@ private struct NavigationSplitCoordinatorView: View {
|
||||
module.coordinator?.toPresentable()
|
||||
.id(module.id)
|
||||
}
|
||||
.onChange(of: columnVisibility) { oldValue, _ in
|
||||
// Preserve the current column visibility when backgrounding the app
|
||||
if scenePhase == .background {
|
||||
columnVisibility = oldValue
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea() // Necessary when embedded in a TabView on iPadOS otherwise there's a gap at the top (as of 18.5).
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user