From 223ddeae2242aaff0705902b21b16a19d95f6688 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Tue, 22 Sep 2026 17:41:23 +0100 Subject: [PATCH] Fix the split view layout on iOS 27. (#6180) --- .../Navigation/NavigationCoordinators.swift | 12 ++++++++++++ .../Navigation/NavigationTabCoordinator.swift | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift index e84c5205d..9c2510b98 100644 --- a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift +++ b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift @@ -397,6 +397,8 @@ private struct NavigationSplitCoordinatorView: View { .environment(\.isInSidebar, true) // The tab rail's background tracks the detail module, so exclude the sidebar's background value. .transformPreference(CompoundBackgroundPreferenceKey.self) { $0 = nil } + .overlay(alignment: .leading) { sidebarDivider } + .overlay(alignment: .trailing) { sidebarDivider } } detail: { if let detailModule = navigationSplitCoordinator.detailModule { detailModule.coordinator?.toPresentable() @@ -414,6 +416,16 @@ private struct NavigationSplitCoordinatorView: View { .animation(.elementDefault, value: navigationSplitCoordinator.sidebarModule) .animation(.noAnimation, value: navigationSplitCoordinator.detailModule) // Don't crossfade the detail transition on iPad. } + + @ViewBuilder + var sidebarDivider: some View { + if #available(iOS 27, *) { + HStack(spacing: 0) { // The stack is necessary for the divider's orientation. + Divider() + } + .ignoresSafeArea() + } + } } // MARK: - NavigationStackCoordinator diff --git a/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift b/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift index 8a4234e6d..67dae1fa5 100644 --- a/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift +++ b/ElementX/Sources/Application/Navigation/NavigationTabCoordinator.swift @@ -416,6 +416,7 @@ private struct NavigationTabCoordinatorView: View { } // Match the rail's background to the colour of the split view's detail (or the root if there isn't a split). .onPreferenceChange(CompoundBackgroundPreferenceKey.self) { background in + guard #unavailable(iOS 27) else { return } // The background is only necessary for iOS 26's inset sidebar. railBackgroundColor = background?.colorValue ?? .compound.bgCanvasDefault } .introspect(.window, on: .supportedVersions) { window in @@ -488,6 +489,14 @@ struct TabRailView: View { isFullScreen || ProcessInfo.processInfo.isiOSAppOnMac ? 0 : 48 } + var trailingPadding: CGFloat { + if #available(iOS 27, *) { + 8 + } else { + 0 + } + } + var body: some View { ScrollView { VStack(spacing: 16) { @@ -508,6 +517,7 @@ struct TabRailView: View { } } .padding(.leading, 8) + .padding(.trailing, trailingPadding) .padding(.top, topPadding) .padding(.bottom) }