diff --git a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift index 5b6462745..bbc1a5cf4 100644 --- a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift +++ b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift @@ -359,15 +359,19 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS private struct NavigationSplitCoordinatorView: View { @State private var columnVisibility = NavigationSplitViewVisibility.all + @State private var isInSplitMode = true + @Environment(\.horizontalSizeClass) private var horizontalSizeClass + @Environment(\.scenePhase) private var scenePhase + @ObservedObject var navigationSplitCoordinator: NavigationSplitCoordinator var body: some View { Group { - if horizontalSizeClass == .compact { - navigationStack - } else { + if isInSplitMode { navigationSplitView + } else { + navigationStack } } // 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 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 diff --git a/ElementX/Sources/Screens/Other/PlaceholderScreenCoordinator.swift b/ElementX/Sources/Screens/Other/PlaceholderScreenCoordinator.swift index 4578b1809..a104015a6 100644 --- a/ElementX/Sources/Screens/Other/PlaceholderScreenCoordinator.swift +++ b/ElementX/Sources/Screens/Other/PlaceholderScreenCoordinator.swift @@ -37,7 +37,7 @@ struct PlaceholderScreen: View { .frame(maxWidth: .infinity, maxHeight: .infinity) .background() .environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault)) - .toolbar(.hidden, for: .automatic) + .ignoresSafeArea(edges: .top) } @ViewBuilder