diff --git a/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift b/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift index 80659c6bc..d75d2d00e 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift @@ -19,13 +19,14 @@ struct RoomHeaderView: View { let mediaProvider: MediaProviderProtocol? var body: some View { - if ProcessInfo.isRunningAccessibilityTests || ProcessInfo.processInfo.isiOSAppOnMac { - // Accessibility tests scale up the dynamic size in real time which may break the view. - // macOS really doesn't like the greedy size and does weird things to it. + if #available(iOS 26.0, *) { + // On iOS 26+ we use the toolbarRole(.editor) to leading align. content } else { + // On iOS 18 and lower, the editor role causes an animation glitch with the back button whenever + // you push a screen whilst the large title is visible on the room screen. content - // Take up as much space as possible, with a leading alignment for use in the principal toolbar position + // So take up as much space as possible, with a leading alignment for use in the default principal toolbar position .frame(idealWidth: .greatestFiniteMagnitude, maxWidth: .infinity, alignment: .leading) } } @@ -64,9 +65,19 @@ struct RoomHeaderView: View { } } +extension RoomHeaderView { + static var toolbarRole: ToolbarRole { + if #available(iOS 26.0, *) { + .editor + } else { + .automatic + } + } +} + struct RoomHeaderView_Previews: PreviewProvider, TestablePreview { static var previews: some View { - VStack(spacing: 8) { + VStack(alignment: .leading, spacing: 8) { makeHeader(avatarURL: nil, verificationState: .notVerified) makeHeader(avatarURL: .mockMXCAvatar, verificationState: .notVerified) makeHeader(avatarURL: .mockMXCAvatar, verificationState: .verified) diff --git a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift index 7e7f853ef..ea99afbd0 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift @@ -40,6 +40,7 @@ struct JoinRoomScreen: View { .alert(item: $context.alertInfo) .background() .backgroundStyle(.compound.bgCanvasDefault) + .toolbarRole(RoomHeaderView.toolbarRole) .navigationBarTitleDisplayMode(.inline) .toolbar { toolbar } .shouldScrollOnKeyboardDidShow(focus == .knockMessage, to: Focus.knockMessage) diff --git a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift index 4b633e8b3..0960d3595 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/RoomScreen.swift @@ -66,6 +66,7 @@ struct RoomScreen: View { .environment(\.shouldAutomaticallyLoadImages, !timelineContext.viewState.hideTimelineMedia) } } + .toolbarRole(RoomHeaderView.toolbarRole) .navigationTitle(L10n.screenRoomTitle) // Hidden but used for back button text. .navigationBarTitleDisplayMode(.inline) .toolbar { toolbar } diff --git a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift index 3e4c88666..62b4c1039 100644 --- a/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift +++ b/ElementX/Sources/Screens/Spaces/SpaceScreen/View/SpaceScreen.swift @@ -21,6 +21,7 @@ struct SpaceScreen: View { } } .background(Color.compound.bgCanvasDefault.ignoresSafeArea()) + .toolbarRole(RoomHeaderView.toolbarRole) .navigationTitle(context.viewState.space.name) .navigationBarTitleDisplayMode(.inline) .toolbar { toolbar } diff --git a/ElementX/Sources/Screens/ThreadTimelineScreen/View/ThreadTimelineScreen.swift b/ElementX/Sources/Screens/ThreadTimelineScreen/View/ThreadTimelineScreen.swift index 9af33e3a4..662ea6e9b 100644 --- a/ElementX/Sources/Screens/ThreadTimelineScreen/View/ThreadTimelineScreen.swift +++ b/ElementX/Sources/Screens/ThreadTimelineScreen/View/ThreadTimelineScreen.swift @@ -24,10 +24,11 @@ struct ThreadTimelineScreen: View { var body: some View { TimelineView(timelineContext: timelineContext) + .background(.compound.bgCanvasDefault) + .toolbarRole(RoomHeaderView.toolbarRole) .navigationTitle(L10n.commonThread) .navigationBarTitleDisplayMode(.inline) .toolbar { toolbar } - .background(.compound.bgCanvasDefault) .toolbarBackground(.visible, for: .navigationBar) // Fix the toolbar's background. .timelineMediaPreview(viewModel: $context.mediaPreviewViewModel) .overlay(alignment: .bottomTrailing) { diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-en-GB-0.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-en-GB-0.png index 9edc45ab5..b1065dbfe 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-en-GB-0.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-en-GB-0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3642081cbd670f8cd3db79b211081f6b8f780da486ae6d3c388d05931efed0e -size 96541 +oid sha256:06bdbba08a5d7d53d356b4a02eb94b090588b90683cf574239c868252ab8ee14 +size 97107 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-pseudo-0.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-pseudo-0.png index 9edc45ab5..b1065dbfe 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-pseudo-0.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPad-pseudo-0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3642081cbd670f8cd3db79b211081f6b8f780da486ae6d3c388d05931efed0e -size 96541 +oid sha256:06bdbba08a5d7d53d356b4a02eb94b090588b90683cf574239c868252ab8ee14 +size 97107 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-en-GB-0.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-en-GB-0.png index 8ce754228..218fbd746 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-en-GB-0.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-en-GB-0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cad5aff3deb96a20f9b1eec7d40112c33b288b7c5c60d5d5c755f9011a9dfaa6 -size 74246 +oid sha256:e57968b4e8159f7bae287d25c095f0f50592876e8d53b0f74016a184d1fd6a0c +size 74497 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-pseudo-0.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-pseudo-0.png index 8ce754228..218fbd746 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-pseudo-0.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/roomHeaderView.iPhone-16-pseudo-0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cad5aff3deb96a20f9b1eec7d40112c33b288b7c5c60d5d5c755f9011a9dfaa6 -size 74246 +oid sha256:e57968b4e8159f7bae287d25c095f0f50592876e8d53b0f74016a184d1fd6a0c +size 74497