Make the space list bloom height match the room list. (#4585)

This commit is contained in:
Doug
2025-10-07 12:52:12 +01:00
committed by GitHub
parent b5b8c38423
commit f67908015e
14 changed files with 82 additions and 8 deletions

View File

@@ -63,6 +63,10 @@ extension AccessibilityTests {
try await performAccessibilityAudit(named: "BlockedUsersScreen_Previews")
}
func testBloomModifier() async throws {
try await performAccessibilityAudit(named: "BloomModifier_Previews")
}
func testBugReportScreen() async throws {
try await performAccessibilityAudit(named: "BugReportScreen_Previews")
}

View File

@@ -23,6 +23,7 @@ enum TestablePreviewsDictionary {
"BadgeLabel_Previews" : BadgeLabel_Previews.self,
"BigIcon_Previews" : BigIcon_Previews.self,
"BlockedUsersScreen_Previews" : BlockedUsersScreen_Previews.self,
"BloomModifier_Previews" : BloomModifier_Previews.self,
"BugReportScreen_Previews" : BugReportScreen_Previews.self,
"CallInviteRoomTimelineView_Previews" : CallInviteRoomTimelineView_Previews.self,
"CallNotificationRoomTimelineView_Previews" : CallNotificationRoomTimelineView_Previews.self,

View File

@@ -11,19 +11,25 @@ import SwiftUI
import SwiftUIIntrospect
extension View {
@ViewBuilder
func bloom() -> some View {
/// Adds a bloom behind the navigation bar.
/// - Parameter hasSearchBar: Whether or not the navigation bar contains a search bar (so that
/// the bloom can be sized appropriately).
@ViewBuilder func toolbarBloom(hasSearchBar: Bool) -> some View {
if #available(iOS 26, *) {
modifier(BloomModifier())
modifier(BloomModifier(hasSearchBar: hasSearchBar))
} else {
modifier(OldBloomModifier())
modifier(OldBloomModifier(hasSearchBar: hasSearchBar))
}
}
}
private struct BloomModifier: ViewModifier {
let hasSearchBar: Bool
@State private var height = CGFloat.zero
private var endPointY: CGFloat { hasSearchBar ? 0.35 : 0.5 }
func body(content: Content) -> some View {
content
.onGeometryChange(for: CGFloat.self) { proxy in
@@ -34,7 +40,7 @@ private struct BloomModifier: ViewModifier {
.overlay(alignment: .top) {
LinearGradient(gradient: .compound.subtle,
startPoint: .top,
endPoint: .init(x: 0.5, y: 0.35))
endPoint: .init(x: 0.5, y: endPointY))
.ignoresSafeArea(edges: .all)
.frame(height: height)
.allowsHitTesting(false)
@@ -47,6 +53,8 @@ private struct BloomModifier: ViewModifier {
private struct OldBloomModifier: ViewModifier {
@Environment(\.colorScheme) private var colorScheme
let hasSearchBar: Bool
@State private var standardAppearance = UINavigationBarAppearance()
@State private var scrollEdgeAppearance = UINavigationBarAppearance()
@@ -93,10 +101,12 @@ private struct OldBloomModifier: ViewModifier {
return bloom
}
private var endPointY: CGFloat { hasSearchBar ? 0.5 : 0.7 }
private var bloomGradient: some View {
LinearGradient(gradient: .compound.subtle,
startPoint: .top,
endPoint: .init(x: 0.5, y: 0.7))
endPoint: .init(x: 0.5, y: endPointY))
.ignoresSafeArea(edges: .all)
.frame(width: 256, height: 256)
}
@@ -115,3 +125,32 @@ private struct OldBloomModifier: ViewModifier {
var baseColor: Color?
}
}
// MARK: - Previews
struct BloomModifier_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
NavigationStack {
mockScreen
.navigationTitle(L10n.screenRoomlistMainSpaceTitle)
.searchable(text: .constant(""), placement: .navigationBarDrawer(displayMode: .always))
.toolbarBloom(hasSearchBar: true)
}
.previewDisplayName("Chats")
NavigationStack {
mockScreen
.navigationTitle(L10n.screenSpaceListTitle)
.toolbarBloom(hasSearchBar: false)
}
.previewDisplayName("Spaces")
}
static var mockScreen: some View {
List { }
.toolbar {
Button { } label: { CompoundIcon(\.check) }
.accessibilityLabel(L10n.actionConfirm) // Keep the a11y tests happy 😄
}
}
}

View File

@@ -25,7 +25,7 @@ struct HomeScreen: View {
.toolbar { toolbar }
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
.track(screen: .Home)
.bloom()
.toolbarBloom(hasSearchBar: true)
.sentryTrace("\(Self.self)")
}

View File

@@ -22,7 +22,7 @@ struct SpaceListScreen: View {
.navigationBarTitleDisplayMode(.inline)
.toolbar { toolbar }
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
.bloom()
.toolbarBloom(hasSearchBar: true)
.onAppear { context.send(viewAction: .screenAppeared) }
.sheet(isPresented: $context.isPresentingFeatureAnnouncement) {
SpacesAnnouncementSheetView(context: context)

View File

@@ -95,6 +95,12 @@ extension PreviewTests {
}
}
func testBloomModifier() async throws {
for (index, preview) in BloomModifier_Previews._allPreviews.enumerated() {
try await assertSnapshots(matching: preview, step: index)
}
}
func testBugReportScreen() async throws {
for (index, preview) in BugReportScreen_Previews._allPreviews.enumerated() {
try await assertSnapshots(matching: preview, step: index)

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:158498fc55b72583eddb12a90533550bc4311ab5421c087d66147dcbe91333a7
size 115492

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:57a4f1a8ca8f11a67078c3263e3c560666dcdf572c0db5695a8c1384557019db
size 115791

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3346489010c047b4286e29afd4113880342d1b73e99e8d1390e2c448863c362e
size 52946

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:988d6d27125778fde9a803e8099a6f13c287dede58a2a6244883377ea1076375
size 54858

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7b35be286bc9ca52ad0e02cb0bee9c9b72973a3968eee457d4c584ccf23ff633
size 112203

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7b35be286bc9ca52ad0e02cb0bee9c9b72973a3968eee457d4c584ccf23ff633
size 112203

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:23f8d1c80181c9634198ae5488cb665e606db61d363d0ebe6e54644fc2ff2a55
size 50960

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cb3072779e29a9f67a8f580c7c07f46c0ab11e603605ce1fef31d6d502df2a0b
size 51525