mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 03:06:37 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -21,6 +21,7 @@ struct SpaceScreen: View {
|
||||
}
|
||||
}
|
||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||
.toolbarRole(RoomHeaderView.toolbarRole)
|
||||
.navigationTitle(context.viewState.space.name)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar { toolbar }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d3642081cbd670f8cd3db79b211081f6b8f780da486ae6d3c388d05931efed0e
|
||||
size 96541
|
||||
oid sha256:06bdbba08a5d7d53d356b4a02eb94b090588b90683cf574239c868252ab8ee14
|
||||
size 97107
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d3642081cbd670f8cd3db79b211081f6b8f780da486ae6d3c388d05931efed0e
|
||||
size 96541
|
||||
oid sha256:06bdbba08a5d7d53d356b4a02eb94b090588b90683cf574239c868252ab8ee14
|
||||
size 97107
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cad5aff3deb96a20f9b1eec7d40112c33b288b7c5c60d5d5c755f9011a9dfaa6
|
||||
size 74246
|
||||
oid sha256:e57968b4e8159f7bae287d25c095f0f50592876e8d53b0f74016a184d1fd6a0c
|
||||
size 74497
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cad5aff3deb96a20f9b1eec7d40112c33b288b7c5c60d5d5c755f9011a9dfaa6
|
||||
size 74246
|
||||
oid sha256:e57968b4e8159f7bae287d25c095f0f50592876e8d53b0f74016a184d1fd6a0c
|
||||
size 74497
|
||||
|
||||
Reference in New Issue
Block a user