Use the editor toolbar role on iOS 26 instead of left aligning the header by frame. (#4647)

The weird back button animation doesn't happen anymore 🥳
This commit is contained in:
Doug
2025-10-22 11:36:14 +01:00
committed by GitHub
parent 17c2dc96d0
commit a9796cce68
9 changed files with 29 additions and 14 deletions
@@ -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)