mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-11 13:59:13 +00:00
Fixes #617 - Prevent navigation bar breaking when backgrounding the app froma a split view
This commit is contained in:
parent
d182202c78
commit
1a12c729de
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user