mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fixes #617 - Prevent navigation bar breaking when backgrounding the app froma a split view
This commit is contained in:
committed by
Stefan Ceriu
parent
d182202c78
commit
1a12c729de
@@ -359,15 +359,19 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
|
|||||||
|
|
||||||
private struct NavigationSplitCoordinatorView: View {
|
private struct NavigationSplitCoordinatorView: View {
|
||||||
@State private var columnVisibility = NavigationSplitViewVisibility.all
|
@State private var columnVisibility = NavigationSplitViewVisibility.all
|
||||||
|
@State private var isInSplitMode = true
|
||||||
|
|
||||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
|
|
||||||
@ObservedObject var navigationSplitCoordinator: NavigationSplitCoordinator
|
@ObservedObject var navigationSplitCoordinator: NavigationSplitCoordinator
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
if horizontalSizeClass == .compact {
|
if isInSplitMode {
|
||||||
navigationStack
|
|
||||||
} else {
|
|
||||||
navigationSplitView
|
navigationSplitView
|
||||||
|
} else {
|
||||||
|
navigationStack
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This needs to be handled on the top level otherwise sheets
|
// This needs to be handled on the top level otherwise sheets
|
||||||
@@ -380,6 +384,25 @@ private struct NavigationSplitCoordinatorView: View {
|
|||||||
.fullScreenCover(item: $navigationSplitCoordinator.fullScreenCoverModule) { module in
|
.fullScreenCover(item: $navigationSplitCoordinator.fullScreenCoverModule) { module in
|
||||||
module.coordinator?.toPresentable()
|
module.coordinator?.toPresentable()
|
||||||
}
|
}
|
||||||
|
// Handle `horizontalSizeClass` changes breaking the navigation bar
|
||||||
|
// https://github.com/vector-im/element-x-ios/issues/617
|
||||||
|
.onChange(of: horizontalSizeClass) { value in
|
||||||
|
guard scenePhase != .background else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
isInSplitMode = value == .regular
|
||||||
|
}
|
||||||
|
.onChange(of: scenePhase) { value in
|
||||||
|
guard value == .active else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
isInSplitMode = horizontalSizeClass == .regular
|
||||||
|
}
|
||||||
|
.task {
|
||||||
|
isInSplitMode = horizontalSizeClass == .regular
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The NavigationStack that will be used in compact layouts
|
/// The NavigationStack that will be used in compact layouts
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ struct PlaceholderScreen: View {
|
|||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.background()
|
.background()
|
||||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||||
.toolbar(.hidden, for: .automatic)
|
.ignoresSafeArea(edges: .top)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
|||||||
Reference in New Issue
Block a user