From 93b8b8febc85b91f1fb9e4dc1f8203778d438c10 Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Sun, 1 Nov 2026 21:41:40 +0000 Subject: [PATCH] Standardize mobile navigation edges (#8895) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Standardizes mobile navigation headers: Android uses Home’s shared Flutter blur; iOS uses native soft edges, with graduated material retained during large-title collapse and the iOS 26 fallback preserved. Preserves Home’s upward title motion with a soft boundary and keeps the avatar crop title visible. Validation: 4,112 Flutter tests and 111 native tests passed after merging main. Rendered partial-scroll regression verified on the iOS 27 simulator; removing either review fix fails its regression assertion. The earlier preview was installed on a physical iPhone with the existing profile. --------- Signed-off-by: kenny lopez Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> --- mobile/ios/Runner.xcodeproj/project.pbxproj | 4 + mobile/ios/Runner/IosNavigationBar.swift | 49 +- mobile/ios/Runner/NativeAddMembersSheet.swift | 7 +- mobile/ios/Runner/NativeCommunityEntry.swift | 6 +- mobile/ios/Runner/NativeProfileSetup.swift | 14 +- .../ios/Runner/NativeProfileTextEditor.swift | 13 +- mobile/ios/Runner/NavigationTopEdge.swift | 18 + mobile/ios/RunnerTests/RunnerTests.swift | 130 ++++- .../lib/features/activity/activity_page.dart | 3 +- mobile/lib/features/agents/agents_page.dart | 3 +- .../channel_detail_page/placement_route.dart | 4 +- .../channels/channel_details_page.dart | 7 +- .../lib/features/channels/channels_page.dart | 54 +- .../channels_page/community_switcher.dart | 95 ++-- mobile/lib/features/channels/me/me_page.dart | 3 +- .../features/channels/media_viewer_page.dart | 32 +- .../media_viewer_page/video_viewer.dart | 34 +- mobile/lib/features/pairing/pairing_page.dart | 53 +- .../lib/features/settings/settings_page.dart | 2 +- .../theme_preview_sheet.dart | 2 +- .../lib/shared/widgets/frosted_app_bar.dart | 70 +-- .../shared/widgets/ios_navigation_bar.dart | 5 + .../shared/widgets/navigation_backdrop.dart | 63 +++ .../shared/widgets/onboarding_step_page.dart | 23 +- .../widgets/profile_avatar_crop_page.dart | 465 +++++++++--------- .../features/activity/activity_page_test.dart | 3 +- .../channels/channel_detail_page_test.dart | 9 +- .../features/channels/channels_page_test.dart | 44 +- mobile/test/features/home/home_page_test.dart | 35 ++ .../features/pairing/pairing_page_test.dart | 18 +- .../profile/profile_edit_page_test.dart | 1 + mobile/test/shared/theme/buzz_theme_test.dart | 42 +- .../shared/widgets/frosted_app_bar_test.dart | 2 +- .../shared/widgets/frosted_scaffold_test.dart | 122 +++-- .../widgets/navigation_backdrop_test.dart | 97 ++++ scripts/test-mobile-me-agent-accessibility.sh | 1 + scripts/test-mobile-member-picker.sh | 1 + 37 files changed, 910 insertions(+), 624 deletions(-) create mode 100644 mobile/ios/Runner/NavigationTopEdge.swift create mode 100644 mobile/lib/shared/widgets/navigation_backdrop.dart create mode 100644 mobile/test/shared/widgets/navigation_backdrop_test.dart diff --git a/mobile/ios/Runner.xcodeproj/project.pbxproj b/mobile/ios/Runner.xcodeproj/project.pbxproj index f232a45498..5058a1de15 100644 --- a/mobile/ios/Runner.xcodeproj/project.pbxproj +++ b/mobile/ios/Runner.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ BZZ00000000000000000020 /* BuzzPushKit in Frameworks */ = {isa = PBXBuildFile; productRef = BZZ00000000000000000022 /* BuzzPushKit */; }; BZZ00000000000000000025 /* BuzzPushKit in Frameworks */ = {isa = PBXBuildFile; productRef = BZZ00000000000000000022 /* BuzzPushKit */; }; DCAF00000000000000000001 /* IosNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAF00000000000000000002 /* IosNavigationBar.swift */; }; + DCAF00000000000000000031 /* NavigationTopEdge.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAF00000000000000000032 /* NavigationTopEdge.swift */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 331C809B294A63AB00263BE5 /* MediaSanitizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C809A294A618700263BE5 /* MediaSanitizer.swift */; }; @@ -121,6 +122,7 @@ BZZ00000000000000000009 /* NotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; }; BZZ0000000000000000000A /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Runner.entitlements; sourceTree = ""; }; DCAF00000000000000000002 /* IosNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosNavigationBar.swift; sourceTree = ""; }; + DCAF00000000000000000032 /* NavigationTopEdge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationTopEdge.swift; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 30CE81D3D1E0B195EF2A6390 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; @@ -303,6 +305,7 @@ BZZ0000000000000000002A /* PushSnapshotBridge.swift */, ACAF00000000000000000002 /* ToastLayer.swift */, DCAF00000000000000000002 /* IosNavigationBar.swift */, + DCAF00000000000000000032 /* NavigationTopEdge.swift */, DAAB00000000000000000002 /* NativeTabler.swift */, 331C809A294A618700263BE5 /* MediaSanitizer.swift */, 4A71C0022F40100100A17E01 /* InlinePhotoPicker.swift */, @@ -651,6 +654,7 @@ BZZ00000000000000000029 /* PushSnapshotBridge.swift in Sources */, ACAF00000000000000000001 /* ToastLayer.swift in Sources */, DCAF00000000000000000001 /* IosNavigationBar.swift in Sources */, + DCAF00000000000000000031 /* NavigationTopEdge.swift in Sources */, DAAB00000000000000000001 /* NativeTabler.swift in Sources */, 331C809B294A63AB00263BE5 /* MediaSanitizer.swift in Sources */, 4A71C0012F40100100A17E01 /* InlinePhotoPicker.swift in Sources */, diff --git a/mobile/ios/Runner/IosNavigationBar.swift b/mobile/ios/Runner/IosNavigationBar.swift index 303c65d6e0..428c31c01c 100644 --- a/mobile/ios/Runner/IosNavigationBar.swift +++ b/mobile/ios/Runner/IosNavigationBar.swift @@ -324,15 +324,13 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView { private let container: NavigationClipView private let material = UIVisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterial)) private let materialFade = CAGradientLayer() - // A transparent, noninteractive viewport provides the system status fade - // independently of the layout-only scroll view that collapses large titles. - private let edgeScrollView = UIScrollView() private let content = NavigationContentController() private let navigation: UINavigationController private let channel: FlutterMethodChannel private var offset: CGFloat = 0 private var controlBackground = UIColor.secondarySystemBackground private var alwaysFrosted = false + private var backdropOnly = false private var usesSystemScrollEdge = false private var expandedBarHeight: CGFloat = 0 private var titleIsCollapsed: Bool? @@ -367,18 +365,6 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView { materialFade.locations = [0, 0.55, 1] material.layer.mask = materialFade container.addSubview(material) - if #available(iOS 27.0, *) { - edgeScrollView.accessibilityIdentifier = "navigation-status-edge" - edgeScrollView.isUserInteractionEnabled = false - edgeScrollView.scrollsToTop = false - edgeScrollView.accessibilityElementsHidden = true - edgeScrollView.backgroundColor = .clear - edgeScrollView.contentInsetAdjustmentBehavior = .never - edgeScrollView.contentSize = CGSize(width: 1, height: 10000) - edgeScrollView.topEdgeEffect.style = .soft - edgeScrollView.bottomEdgeEffect.isHidden = true - container.addSubview(edgeScrollView) - } navigation.view.backgroundColor = .clear navigation.navigationBar.isTranslucent = true parent?.addChild(navigation) @@ -411,14 +397,19 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView { // needed for UIKit's scroll-edge and large-title calculations. guard !measuring else { return } let viewportHeight = container.window?.bounds.height ?? container.bounds.height - edgeScrollView.frame = CGRect(x: 0, y: 0, width: container.bounds.width, height: viewportHeight) - navigation.view.frame = edgeScrollView.frame + navigation.view.frame = CGRect(x: 0, y: 0, width: container.bounds.width, height: viewportHeight) // Flutter's route can begin offscreen, where UIKit infers a zero safe area. // Keep the toolbar below the status region throughout that transition. // Read the unmodified host inset, never the inset we are adjusting. // During a slide UIKit may not yet have applied the previous adjustment. let automaticTop = container.safeAreaInsets.top - let requiredTop = max(0, flutterSafeTop - automaticTop) + // An empty native bar supplies the same edge geometry beneath a custom + // Flutter header. Place its lower edge at the end of that header so the + // system fade protects the filters as well as the status area. + let protectedTop = backdropOnly + ? max(flutterSafeTop, container.bounds.height - max(44, navigation.navigationBar.bounds.height)) + : flutterSafeTop + let requiredTop = max(0, protectedTop - automaticTop) if abs(navigation.additionalSafeAreaInsets.top - requiredTop) > 0.5 { navigation.additionalSafeAreaInsets.top = requiredTop } @@ -473,7 +464,6 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView { flutterSafeTop = (args["safeTop"] as? NSNumber)?.doubleValue ?? 0 navigation.overrideUserInterfaceStyle = args["dark"] as? Bool == true ? .dark : .light material.overrideUserInterfaceStyle = navigation.overrideUserInterfaceStyle - edgeScrollView.overrideUserInterfaceStyle = navigation.overrideUserInterfaceStyle // Let the ultra-thin system material provide its own adaptive tint. material.contentView.backgroundColor = .clear let bar = navigation.navigationBar @@ -481,27 +471,28 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView { bar.tintColor = color titleColor = color largeTitleOpacity = -1 + backdropOnly = args["backdropOnly"] as? Bool == true + container.isUserInteractionEnabled = !backdropOnly + navigation.view.isUserInteractionEnabled = !backdropOnly + navigation.view.accessibilityElementsHidden = backdropOnly let largeTitle = args["largeTitle"] as? Bool == true alwaysFrosted = args["alwaysFrosted"] as? Bool == true if #available(iOS 26.0, *) { if #available(iOS 27.0, *) { usesSystemScrollEdge = true } content.scrollView.topEdgeEffect.style = .soft - content.scrollView.topEdgeEffect.isHidden = !usesSystemScrollEdge || !alwaysFrosted || largeTitle - edgeScrollView.isHidden = alwaysFrosted && !largeTitle + content.scrollView.topEdgeEffect.isHidden = !usesSystemScrollEdge } - // Large-title pages need material across the whole header: the stationary - // system edge only blurs the status area, leaving expanded text over rows. - // iOS 26 does not composite this native edge over sibling Flutter content - // in our embedding, so retain the ultra-thin material fallback there. - // Conversations use the navigation controller's native edge. Other pages - // use a stationary native edge so UIKit's large-title inset adjustments - // cannot hide the status-area fade when the title expands or collapses. + // Older embedded views retain material because their native edge cannot + // sample Flutter content. On iOS 27, UIKit also suppresses its native + // edge while the large-title inset is collapsing. + // Keep the graduated material throughout that transition so partial + // scrolling never leaves the title and status area unprotected. material.isHidden = usesSystemScrollEdge && !largeTitle // Let the native fade extend past the bar without enlarging its hit area. // The mirrored content is transparent and the bottom edge is hidden. container.clipsToBounds = !usesSystemScrollEdge let appearance = UINavigationBarAppearance() - if usesSystemScrollEdge && !largeTitle { + if usesSystemScrollEdge { appearance.configureWithDefaultBackground() } else { appearance.configureWithTransparentBackground() diff --git a/mobile/ios/Runner/NativeAddMembersSheet.swift b/mobile/ios/Runner/NativeAddMembersSheet.swift index 0938a1be05..32b17d9e26 100644 --- a/mobile/ios/Runner/NativeAddMembersSheet.swift +++ b/mobile/ios/Runner/NativeAddMembersSheet.swift @@ -142,12 +142,7 @@ final class NativeAddMembersViewController: UITableViewController, UISearchResul definesPresentationContext = true navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancel)) navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Add", style: .done, target: self, action: #selector(add)) - let appearance = UINavigationBarAppearance() - appearance.configureWithOpaqueBackground() - appearance.backgroundColor = pageColor - appearance.shadowColor = .clear - navigationItem.standardAppearance = appearance - navigationItem.scrollEdgeAppearance = appearance + NavigationTopEdge.configure(tableView, item: navigationItem) applyState() } diff --git a/mobile/ios/Runner/NativeCommunityEntry.swift b/mobile/ios/Runner/NativeCommunityEntry.swift index 9338c4041a..24e975b0b6 100644 --- a/mobile/ios/Runner/NativeCommunityEntry.swift +++ b/mobile/ios/Runner/NativeCommunityEntry.swift @@ -118,15 +118,17 @@ private final class NativeCommunityEntryController: UIViewController, UITextFiel navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .close, primaryAction: UIAction { [weak self] _ in self?.close() }) if #available(iOS 17.0, *) { view.keyboardLayoutGuide.usesBottomSafeArea = false } - scroll.contentInsetAdjustmentBehavior = .never + scroll.contentInsetAdjustmentBehavior = .always scroll.translatesAutoresizingMaskIntoConstraints = false stack.translatesAutoresizingMaskIntoConstraints = false stack.axis = .vertical stack.spacing = 12 + NavigationTopEdge.configure(scroll, item: navigationItem) + if #available(iOS 15.0, *) { setContentScrollView(scroll) } view.addSubview(scroll) scroll.addSubview(stack) NSLayoutConstraint.activate([ - scroll.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), + scroll.topAnchor.constraint(equalTo: view.topAnchor), scroll.leadingAnchor.constraint(equalTo: view.leadingAnchor), scroll.trailingAnchor.constraint(equalTo: view.trailingAnchor), scroll.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor), diff --git a/mobile/ios/Runner/NativeProfileSetup.swift b/mobile/ios/Runner/NativeProfileSetup.swift index 73e82abbbb..d62788a04a 100644 --- a/mobile/ios/Runner/NativeProfileSetup.swift +++ b/mobile/ios/Runner/NativeProfileSetup.swift @@ -342,11 +342,21 @@ private final class NativeProfileSetupController: UIViewController, UITextFieldD view.tintColor = UIColor(red: CGFloat((argb >> 16) & 255) / 255, green: CGFloat((argb >> 8) & 255) / 255, blue: CGFloat(argb & 255) / 255, alpha: 1) let stack = UIStackView(); stack.axis = .vertical; stack.spacing = 16; stack.translatesAutoresizingMaskIntoConstraints = false let scroll = UIScrollView(); scroll.translatesAutoresizingMaskIntoConstraints = false + NavigationTopEdge.configure(scroll, item: navigationItem) + if #available(iOS 15.0, *) { setContentScrollView(scroll) } view.addSubview(scroll); scroll.addSubview(stack) + // Content keeps its original keyboard-aware height while the scroll view + // extends beneath navigation for the system soft edge. + let contentViewport = UILayoutGuide() + view.addLayoutGuide(contentViewport) NSLayoutConstraint.activate([ - scroll.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), scroll.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor), + contentViewport.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), + contentViewport.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor), + contentViewport.leadingAnchor.constraint(equalTo: view.leadingAnchor), + contentViewport.trailingAnchor.constraint(equalTo: view.trailingAnchor), + scroll.topAnchor.constraint(equalTo: view.topAnchor), scroll.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor), scroll.leadingAnchor.constraint(equalTo: view.leadingAnchor), scroll.trailingAnchor.constraint(equalTo: view.trailingAnchor), - stack.heightAnchor.constraint(greaterThanOrEqualTo: scroll.frameLayoutGuide.heightAnchor, constant: -48), + stack.heightAnchor.constraint(greaterThanOrEqualTo: contentViewport.heightAnchor, constant: -48), stack.topAnchor.constraint(equalTo: scroll.contentLayoutGuide.topAnchor, constant: 24), stack.bottomAnchor.constraint(equalTo: scroll.contentLayoutGuide.bottomAnchor, constant: -24), stack.leadingAnchor.constraint(equalTo: scroll.frameLayoutGuide.leadingAnchor, constant: 24), stack.trailingAnchor.constraint(equalTo: scroll.frameLayoutGuide.trailingAnchor, constant: -24) ]) diff --git a/mobile/ios/Runner/NativeProfileTextEditor.swift b/mobile/ios/Runner/NativeProfileTextEditor.swift index 41f4ee3a83..23f8a52ee1 100644 --- a/mobile/ios/Runner/NativeProfileTextEditor.swift +++ b/mobile/ios/Runner/NativeProfileTextEditor.swift @@ -370,18 +370,7 @@ private final class NativeProfileTextEditorViewController: tableView.backgroundColor = pageBackgroundColor tableView.keyboardDismissMode = .interactive tableView.alwaysBounceVertical = false - let navigationAppearance = UINavigationBarAppearance() - navigationAppearance.configureWithOpaqueBackground() - navigationAppearance.backgroundColor = pageBackgroundColor - navigationAppearance.shadowColor = UIColor.separator.withAlphaComponent(0.2) - let scrollEdgeAppearance = UINavigationBarAppearance() - scrollEdgeAppearance.configureWithOpaqueBackground() - scrollEdgeAppearance.backgroundColor = pageBackgroundColor - scrollEdgeAppearance.shadowColor = .clear - navigationItem.standardAppearance = navigationAppearance - navigationItem.scrollEdgeAppearance = scrollEdgeAppearance - navigationItem.compactAppearance = navigationAppearance - navigationItem.compactScrollEdgeAppearance = scrollEdgeAppearance + NavigationTopEdge.configure(tableView, item: navigationItem) navigationItem.leftBarButtonItem = UIBarButtonItem( barButtonSystemItem: .cancel, target: self, diff --git a/mobile/ios/Runner/NavigationTopEdge.swift b/mobile/ios/Runner/NavigationTopEdge.swift new file mode 100644 index 0000000000..5d75e4c1d7 --- /dev/null +++ b/mobile/ios/Runner/NavigationTopEdge.swift @@ -0,0 +1,18 @@ +import UIKit + +/// Applies the app's soft navigation edge to app-owned native sheets. +/// OS-owned pickers retain their system presentation. +enum NavigationTopEdge { + static func configure(_ scrollView: UIScrollView, item: UINavigationItem) { + if #available(iOS 26.0, *) { + scrollView.topEdgeEffect.style = .soft + scrollView.bottomEdgeEffect.isHidden = true + } + let appearance = UINavigationBarAppearance() + appearance.configureWithDefaultBackground() + item.standardAppearance = appearance + item.scrollEdgeAppearance = appearance + item.compactAppearance = appearance + item.compactScrollEdgeAppearance = appearance + } +} diff --git a/mobile/ios/RunnerTests/RunnerTests.swift b/mobile/ios/RunnerTests/RunnerTests.swift index a4851bb102..db4d85a17e 100644 --- a/mobile/ios/RunnerTests/RunnerTests.swift +++ b/mobile/ios/RunnerTests/RunnerTests.swift @@ -8,6 +8,65 @@ import XCTest class RunnerTests: XCTestCase { + @MainActor + func testCustomFlutterHeaderUsesDecorativeSoftEdge() throws { + guard #available(iOS 27.0, *) else { return } + let messenger = NavigationTestMessenger() + let parent = UIViewController() + let window = UIWindow(frame: UIScreen.main.bounds) + window.rootViewController = parent + window.makeKeyAndVisible() + defer { window.isHidden = true } + let bar = IosNavigationBarFactory(messenger: messenger, parent: parent).create( + withFrame: CGRect(x: 0, y: 0, width: window.bounds.width, height: 150), + viewIdentifier: 999998, + arguments: ["title": "", "backdropOnly": true, "alwaysFrosted": true] + ) + parent.view.addSubview(bar.view()) + parent.view.layoutIfNeeded() + let navigation = try XCTUnwrap(parent.children.first as? UINavigationController) + XCTAssertFalse(bar.view().isUserInteractionEnabled) + XCTAssertFalse(navigation.view.isUserInteractionEnabled) + XCTAssertTrue(navigation.view.accessibilityElementsHidden) + let scroll = try XCTUnwrap(navigation.topViewController?.view as? UIScrollView) + XCTAssertEqual(scroll.topEdgeEffect.style, .soft) + XCTAssertFalse(scroll.topEdgeEffect.isHidden) + XCTAssertTrue(scroll.bottomEdgeEffect.isHidden) + let material = try XCTUnwrap(bar.view().subviews.first as? UIVisualEffectView) + XCTAssertTrue(material.isHidden) + // Filter collapse changes the protected area without moving the Flutter + // controls or adding a second accessibility owner. + let compactHeight = bar.view().safeAreaInsets.top + navigation.navigationBar.bounds.height + for height in [compactHeight + 48, compactHeight] { + bar.view().frame.size.height = height + bar.view().setNeedsLayout() + bar.view().layoutIfNeeded() + let bottom = navigation.navigationBar.convert(navigation.navigationBar.bounds, to: bar.view()).maxY + XCTAssertEqual(bottom, height, accuracy: 1) + } + } + + @MainActor + func testNativeSheetTopEdgeIsSoftWithoutAnOpaqueNavigationFill() throws { + guard #available(iOS 26.0, *) else { return } + let picker = NativeAddMembersViewController( + state: ["users": [], "selected": [], "query": "", "loading": false], + loadAvatar: { _, _, reply in reply(nil) }, + send: { _, _ in } + ) + picker.loadViewIfNeeded() + let scroll = picker.tableView! + let item = picker.navigationItem + XCTAssertEqual(scroll.topEdgeEffect.style, .soft) + XCTAssertTrue(scroll.bottomEdgeEffect.isHidden) + let appearance = try XCTUnwrap(item.standardAppearance) + XCTAssertLessThan(appearance.backgroundColor?.cgColor.alpha ?? 0, 1) + XCTAssertEqual(item.scrollEdgeAppearance, appearance) + XCTAssertEqual(item.compactAppearance, appearance) + XCTAssertEqual(item.compactScrollEdgeAppearance, appearance) + } + + @MainActor func testProfileAvatarStartupFailureRestoresPageAndAllowsRetry() async throws { let messenger = NavigationTestMessenger() @@ -680,15 +739,9 @@ class RunnerTests: XCTestCase { if #available(iOS 27.0, *) { let navigation = try XCTUnwrap(parent.children.first as? UINavigationController) let mirroredScroll = try XCTUnwrap(navigation.topViewController?.view as? UIScrollView) - XCTAssertTrue(mirroredScroll.topEdgeEffect.isHidden) - let edge = try XCTUnwrap(bar.view().subviews.first { - $0.accessibilityIdentifier == "navigation-status-edge" - } as? UIScrollView) - XCTAssertFalse(edge.isHidden) - XCTAssertFalse(edge.topEdgeEffect.isHidden) - XCTAssertEqual(edge.topEdgeEffect.style, .soft) - XCTAssertEqual(edge.contentOffset, .zero) - XCTAssertFalse(edge.isUserInteractionEnabled) + XCTAssertFalse(mirroredScroll.topEdgeEffect.isHidden) + XCTAssertEqual(mirroredScroll.topEdgeEffect.style, .soft) + XCTAssertFalse(mirroredScroll.isUserInteractionEnabled) XCTAssertTrue(material.isHidden, "Only the native fade should be visible") XCTAssertTrue(mirroredScroll.bottomEdgeEffect.isHidden) } @@ -783,6 +836,7 @@ class RunnerTests: XCTestCase { let messenger = NavigationTestMessenger() let parent = UIViewController() let window = UIWindow(frame: UIScreen.main.bounds) + window.windowScene = try XCTUnwrap(UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.first) window.rootViewController = parent window.makeKeyAndVisible() defer { window.isHidden = true } @@ -801,16 +855,10 @@ class RunnerTests: XCTestCase { XCTAssertEqual(material.alpha, 0) if #available(iOS 27.0, *) { let scroll = try XCTUnwrap(navigation.topViewController?.view as? UIScrollView) - XCTAssertTrue(scroll.topEdgeEffect.isHidden) - let edge = try XCTUnwrap(bar.view().subviews.first { - $0.accessibilityIdentifier == "navigation-status-edge" - } as? UIScrollView) - XCTAssertFalse(edge.isHidden) - XCTAssertFalse(edge.topEdgeEffect.isHidden) - XCTAssertEqual(edge.topEdgeEffect.style, .soft) - XCTAssertEqual(edge.contentOffset, .zero) - XCTAssertFalse(edge.isUserInteractionEnabled) - XCTAssertTrue(material.isHidden) + XCTAssertFalse(scroll.topEdgeEffect.isHidden) + XCTAssertEqual(scroll.topEdgeEffect.style, .soft) + XCTAssertFalse(scroll.isUserInteractionEnabled) + XCTAssertFalse(material.isHidden) XCTAssertFalse(bar.view().clipsToBounds) } let expandedHeight = navigation.navigationBar.frame.height @@ -819,6 +867,41 @@ class RunnerTests: XCTestCase { let measuredExpandedHeight = try XCTUnwrap(metrics["expandedHeight"] as? Double) XCTAssertEqual(expandedHeight, measuredExpandedHeight, accuracy: 0.5) XCTAssertGreaterThan(expandedHeight, compactHeight) + // Compare actual raster output with and without the material while UIKit's + // large-title edge is inactive. Requested edge flags alone missed this bug. + parent.view.backgroundColor = .systemRed + let originalHeight = bar.view().frame.height + let format = UIGraphicsImageRendererFormat() + format.scale = 1 + let renderer = UIGraphicsImageRenderer(size: CGSize(width: 24, height: 24), format: format) + func statusPixels() throws -> Data { + let image = renderer.image { context in + context.cgContext.translateBy(x: -8, y: -8) + window.drawHierarchy(in: window.bounds, afterScreenUpdates: true) + } + let cgImage = try XCTUnwrap(image.cgImage) + return try XCTUnwrap(cgImage.dataProvider?.data) as Data + } + for offset in [30.0, 80.0, 30.0] { + messenger.scroll(to: offset) + bar.view().frame.size.height = originalHeight - min(offset, measuredExpandedHeight - compactHeight) + bar.view().setNeedsLayout() + bar.view().layoutIfNeeded() + let protectedPixels = try statusPixels() + let wasHidden = material.isHidden + material.isHidden = true + let unprotectedPixels = try statusPixels() + material.isHidden = wasHidden + XCTAssertNotEqual(protectedPixels, unprotectedPixels, + "Rendered status area must retain material at offset \(offset)") + let attachment = XCTAttachment(image: UIGraphicsImageRenderer(bounds: window.bounds).image { _ in + window.drawHierarchy(in: window.bounds, afterScreenUpdates: true) + }) + attachment.name = "large-title-offset-\(offset)" + attachment.lifetime = .keepAlways + add(attachment) + } + bar.view().frame.size.height = originalHeight for _ in 0..<3 { messenger.scroll(to: measuredExpandedHeight - compactHeight) bar.view().setNeedsLayout() @@ -834,11 +917,10 @@ class RunnerTests: XCTestCase { XCTAssertEqual(navigation.navigationBar.frame.height, expandedHeight, accuracy: 0.5) XCTAssertEqual(material.alpha, 0) if #available(iOS 27.0, *) { - let edge = try XCTUnwrap(bar.view().subviews.first { - $0.accessibilityIdentifier == "navigation-status-edge" - } as? UIScrollView) - XCTAssertFalse(edge.isHidden, "Returning to rest must not remove the status fade") - XCTAssertEqual(edge.contentOffset, .zero) + let scroll = try XCTUnwrap(navigation.topViewController?.view as? UIScrollView) + XCTAssertFalse(scroll.topEdgeEffect.isHidden, "Returning to rest retains the native edge") + XCTAssertEqual(scroll.topEdgeEffect.style, .soft) + XCTAssertLessThan(scroll.contentOffset.y, 0) } } } diff --git a/mobile/lib/features/activity/activity_page.dart b/mobile/lib/features/activity/activity_page.dart index 098ea05813..8bddff508b 100644 --- a/mobile/lib/features/activity/activity_page.dart +++ b/mobile/lib/features/activity/activity_page.dart @@ -472,8 +472,7 @@ class ActivityPage extends HookConsumerWidget { ], automaticallyImplyLeading: false, horizontalInset: Grid.gutter, - showBottomDivider: true, - bottomDividerOpacity: 0.07, + title: Text('Inbox', style: headerTitleStyle), titleStyle: headerTitleStyle, actions: [ diff --git a/mobile/lib/features/agents/agents_page.dart b/mobile/lib/features/agents/agents_page.dart index 20d192e453..9e4a542f8f 100644 --- a/mobile/lib/features/agents/agents_page.dart +++ b/mobile/lib/features/agents/agents_page.dart @@ -285,8 +285,7 @@ class AgentsPage extends HookConsumerWidget { onPressed: onClose, ), horizontalInset: Grid.gutter, - showBottomDivider: true, - bottomDividerOpacity: 0.07, + title: Text('Agents', style: headerStyle), titleStyle: headerStyle, bottomHeight: Grid.xxs, diff --git a/mobile/lib/features/channels/channel_detail_page/placement_route.dart b/mobile/lib/features/channels/channel_detail_page/placement_route.dart index 66f74a1721..7f8e5664ed 100644 --- a/mobile/lib/features/channels/channel_detail_page/placement_route.dart +++ b/mobile/lib/features/channels/channel_detail_page/placement_route.dart @@ -41,8 +41,8 @@ class ChannelDetailPage extends ConsumerWidget { placement != ChannelRoutePlacement.ordinary && groups == null && lookup.isLoading) { - return Scaffold( - appBar: AppBar(title: Text(channel.name)), + return FrostedScaffold( + appBar: FrostedAppBar(title: Text(channel.name)), body: const Center(child: BuzzLoadingIndicator()), ); } diff --git a/mobile/lib/features/channels/channel_details_page.dart b/mobile/lib/features/channels/channel_details_page.dart index 83f6e68095..3b87018123 100644 --- a/mobile/lib/features/channels/channel_details_page.dart +++ b/mobile/lib/features/channels/channel_details_page.dart @@ -2,7 +2,6 @@ part of 'channel_actions_sheet.dart'; const _channelMemberPreviewLimit = 5; const _channelDetailsHeaderFrostScrollDistance = Grid.xxl; -const _channelDetailsHeaderFrostMaxBlurSigma = 20.0; const _channelDetailsSectionPadding = Grid.twelve; /// Opens the combined mobile channel settings page. @@ -294,11 +293,7 @@ class ChannelDetailsPage extends HookConsumerWidget { ), ], frosted: headerFrostProgress.value > 0, - frostedSurfaceOpacity: 0.5 * headerFrostProgress.value, - frostedBlurSigma: - _channelDetailsHeaderFrostMaxBlurSigma * headerFrostProgress.value, - showBottomDivider: headerFrostProgress.value > 0, - bottomDividerOpacity: 0.07 * headerFrostProgress.value, + title: AnimatedSwitcher( duration: reducedMotion ? Duration.zero diff --git a/mobile/lib/features/channels/channels_page.dart b/mobile/lib/features/channels/channels_page.dart index 03279c57c7..1c77cac363 100644 --- a/mobile/lib/features/channels/channels_page.dart +++ b/mobile/lib/features/channels/channels_page.dart @@ -39,7 +39,6 @@ import '../../shared/widgets/buzz_loading_indicator.dart'; import '../../shared/widgets/buzz_setting_menu.dart'; import '../../shared/widgets/concentric_sheet_surface.dart'; import '../../shared/widgets/frosted_app_bar.dart'; -import '../../shared/widgets/ios_navigation_bar.dart'; import '../../shared/widgets/frosted_scaffold.dart'; import '../../shared/widgets/mobile_tab_footer_backdrop.dart'; import '../../shared/widgets/modal_presentation.dart'; @@ -102,7 +101,6 @@ const double _kTopSectionBottomPadding = Grid.xxs; /// Inset for the community and profile avatar row. const double _kTopSectionInset = Grid.twelve; const double _kHeaderFrostScrollDistance = Grid.xxl; -const double _kHeaderFrostMaxBlurSigma = 23.12; class ChannelsPage extends HookConsumerWidget { const ChannelsPage({ @@ -618,17 +616,6 @@ class ChannelsPage extends HookConsumerWidget { !usesPinnedGradient || headerFrostProgress.value > 0, alwaysFrosted: messagesFilters != null, - frostedSurfaceOpacity: messagesFilters != null - ? 0.45 - : usesPinnedGradient - ? 0 - : 0.5, - frostedBlurSigma: messagesFilters != null - ? 20 - : usesPinnedGradient - ? _kHeaderFrostMaxBlurSigma * headerFrostProgress.value - : 20, - showBottomDivider: false, leading: messagesFilters != null ? null : _CommunityIndicator( @@ -642,14 +629,39 @@ class ChannelsPage extends HookConsumerWidget { automaticallyImplyLeading: messagesFilters == null, title: messagesFilters == null ? const SizedBox.shrink() - : ClipRect( - child: ExcludeSemantics( - excluding: headerCollapse.value >= filterContentHeight, - child: Opacity( - opacity: 1 - headerCollapse.value / filterContentHeight, - child: Transform.translate( - offset: Offset(0, -headerCollapse.value), - child: Text('Messages', style: headerTitleStyle), + : ExcludeSemantics( + excluding: headerCollapse.value >= filterContentHeight, + child: ShaderMask( + blendMode: BlendMode.dstIn, + shaderCallback: (bounds) => LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + headerCollapse.value == 0 + ? Colors.white + : Colors.transparent, + Colors.white, + ], + stops: [ + 0, + (headerCollapse.value.clamp(0.0, Grid.sm) / bounds.height) + .clamp(0.0, 1.0), + ], + ).createShader(bounds), + // Keep the original upward motion, but fade the glyphs at + // status-area boundary instead of the text’s own tight bounds. + child: ClipRect( + child: Opacity( + opacity: 1 - headerCollapse.value / filterContentHeight, + child: SizedBox.expand( + child: Align( + alignment: Alignment.centerLeft, + child: Transform.translate( + offset: Offset(0, -headerCollapse.value), + child: Text('Messages', style: headerTitleStyle), + ), + ), + ), ), ), ), diff --git a/mobile/lib/features/channels/channels_page/community_switcher.dart b/mobile/lib/features/channels/channels_page/community_switcher.dart index 6877563e69..fb20771f35 100644 --- a/mobile/lib/features/channels/channels_page/community_switcher.dart +++ b/mobile/lib/features/channels/channels_page/community_switcher.dart @@ -261,47 +261,37 @@ class CommunitySwitcherPage extends HookConsumerWidget { ); } - final ios = defaultTargetPlatform == TargetPlatform.iOS; - final header = ios - ? SizedBox( - height: frostedAppBarHeight(context), - child: IosNavigationBar( - title: '', - leading: IosNavigationAction( - label: 'Close community switcher', - symbol: 'xmark', - onPressed: () => Navigator.of(context).pop(), - ), - actions: [ - IosNavigationAction( - label: isEditing.value ? 'Done' : 'Edit', - onPressed: () => isEditing.value = !isEditing.value, - ), - ], - ), - ) - : Padding( - padding: const EdgeInsets.all(Grid.xxs), - child: Row( - children: [ - IconButton( - tooltip: 'Close community switcher', - onPressed: () => Navigator.of(context).pop(), - icon: const Icon(BuzzIcons.x), - ), - const Spacer(), - TextButton( - key: const Key('community-switcher-edit'), - onPressed: () => isEditing.value = !isEditing.value, - child: Text(isEditing.value ? 'Done' : 'Edit'), - ), - ], - ), - ); + final header = FrostedAppBar( + nativeTitle: '', + automaticallyImplyLeading: false, + nativeLeading: IosNavigationAction( + label: 'Close community switcher', + symbol: 'xmark', + onPressed: () => Navigator.of(context).pop(), + ), + nativeActions: [ + IosNavigationAction( + label: isEditing.value ? 'Done' : 'Edit', + onPressed: () => isEditing.value = !isEditing.value, + ), + ], + leading: IconButton( + tooltip: 'Close community switcher', + onPressed: () => Navigator.of(context).pop(), + icon: const Icon(BuzzIcons.x), + ), + actions: [ + TextButton( + key: const Key('community-switcher-edit'), + onPressed: () => isEditing.value = !isEditing.value, + child: Text(isEditing.value ? 'Done' : 'Edit'), + ), + ], + ); final body = SingleChildScrollView( - padding: const EdgeInsets.fromLTRB( + padding: EdgeInsets.fromLTRB( Grid.gutter, - Grid.xs, + frostedAppBarHeight(context) + Grid.xs, Grid.gutter, Grid.md, ), @@ -381,31 +371,10 @@ class CommunitySwitcherPage extends HookConsumerWidget { ), ), ); - final surface = Material( + final surface = FrostedScaffold( key: const Key('community-switcher-page'), - color: context.colors.surface, - child: SafeArea( - top: !ios, - child: ios - ? Stack( - children: [ - Positioned.fill( - top: frostedAppBarHeight(context), - child: body, - ), - // Paint the native bar last, as in FrostedScaffold. Painting - // Flutter content after a UIKit view can hide that content - // during this route's opacity/scale composition on iOS. - Positioned(top: 0, left: 0, right: 0, child: header), - ], - ) - : Column( - children: [ - header, - Expanded(child: body), - ], - ), - ), + appBar: header, + body: SafeArea(top: false, child: body), ); return PopScope( diff --git a/mobile/lib/features/channels/me/me_page.dart b/mobile/lib/features/channels/me/me_page.dart index 542c54eab8..261d7bb414 100644 --- a/mobile/lib/features/channels/me/me_page.dart +++ b/mobile/lib/features/channels/me/me_page.dart @@ -335,8 +335,7 @@ class MePage extends HookConsumerWidget { ), ], horizontalInset: Grid.gutter, - showBottomDivider: true, - bottomDividerOpacity: 0.07, + title: Text('Solo', style: headerTitleStyle), titleStyle: headerTitleStyle, actions: [ diff --git a/mobile/lib/features/channels/media_viewer_page.dart b/mobile/lib/features/channels/media_viewer_page.dart index d4b7aa4827..9928f0d9f5 100644 --- a/mobile/lib/features/channels/media_viewer_page.dart +++ b/mobile/lib/features/channels/media_viewer_page.dart @@ -21,6 +21,7 @@ import '../../shared/widgets/concentric_sheet_surface.dart'; import '../../shared/widgets/page_indicator.dart'; import '../../shared/widgets/ios_glass_navigation_button.dart'; import '../../shared/widgets/ios_navigation_bar.dart'; +import '../../shared/widgets/navigation_backdrop.dart'; import 'media_viewer_hero.dart'; export 'media_viewer_hero.dart'; @@ -628,16 +629,33 @@ class MediaImageViewerPage extends HookConsumerWidget { ), ) else - PositionedDirectional( + Positioned( top: 0, - end: Grid.sm, + left: 0, + right: 0, child: Opacity( opacity: chromeOpacity, - child: SafeArea( - child: _MediaViewerCloseButton( - key: const ValueKey('message-media-image-viewer-close'), - tooltip: 'Close image viewer', - onPressed: () => unawaited(dismiss()), + child: Theme( + data: ThemeData.dark(), + child: NavigationBackdrop( + child: SafeArea( + bottom: false, + child: Align( + alignment: AlignmentDirectional.centerEnd, + child: Padding( + padding: const EdgeInsetsDirectional.only( + end: Grid.sm, + ), + child: _MediaViewerCloseButton( + key: const ValueKey( + 'message-media-image-viewer-close', + ), + tooltip: 'Close image viewer', + onPressed: () => unawaited(dismiss()), + ), + ), + ), + ), ), ), ), diff --git a/mobile/lib/features/channels/media_viewer_page/video_viewer.dart b/mobile/lib/features/channels/media_viewer_page/video_viewer.dart index d3f7f41f88..214c551ecb 100644 --- a/mobile/lib/features/channels/media_viewer_page/video_viewer.dart +++ b/mobile/lib/features/channels/media_viewer_page/video_viewer.dart @@ -390,17 +390,35 @@ class MediaVideoViewerPage extends HookConsumerWidget { ), ) else - PositionedDirectional( - top: Grid.sm, - end: Grid.sm, + Positioned( + top: 0, + left: 0, + right: 0, child: _VideoViewerChrome( visible: controls.visible, dragOpacity: chromeOpacity, - child: SafeArea( - child: _MediaViewerCloseButton( - key: const ValueKey('message-media-video-viewer-close'), - tooltip: 'Close video viewer', - onPressed: () => Navigator.of(context).maybePop(), + child: Theme( + data: ThemeData.dark(), + child: NavigationBackdrop( + child: SafeArea( + bottom: false, + child: Align( + alignment: AlignmentDirectional.centerEnd, + child: Padding( + padding: const EdgeInsetsDirectional.only( + top: Grid.sm, + end: Grid.sm, + ), + child: _MediaViewerCloseButton( + key: const ValueKey( + 'message-media-video-viewer-close', + ), + tooltip: 'Close video viewer', + onPressed: () => Navigator.of(context).maybePop(), + ), + ), + ), + ), ), ), ), diff --git a/mobile/lib/features/pairing/pairing_page.dart b/mobile/lib/features/pairing/pairing_page.dart index efab52ea37..d0815f3b95 100644 --- a/mobile/lib/features/pairing/pairing_page.dart +++ b/mobile/lib/features/pairing/pairing_page.dart @@ -206,7 +206,7 @@ class PairingPage extends HookConsumerWidget { ? 'Send to Desktop' : '', frosted: false, - showBottomDivider: false, + iconColor: context._onboardingInk, title: identityRecoveryOnly @@ -216,42 +216,27 @@ class PairingPage extends HookConsumerWidget { ], ), ) - : AppBar( - backgroundColor: Colors.transparent, - surfaceTintColor: Colors.transparent, - elevation: 0, - scrolledUnderElevation: 0, - foregroundColor: context._onboardingInk, - systemOverlayStyle: onboardingSystemOverlayStyle, - leadingWidth: Theme.of(context).platform == TargetPlatform.iOS - ? Grid.quarter + iosGlassChannelHeaderLeadingWidth - : null, - leading: Theme.of(context).platform == TargetPlatform.iOS - ? Padding( - padding: const EdgeInsets.only(left: Grid.quarter), - child: IosGlassNavigationButton( - key: const ValueKey('pairing-ios-glass-back'), - icon: IosGlassNavigationIcon.back, - semanticLabel: 'Back', - onPressed: () => Navigator.of(context).maybePop(), - width: iosGlassChannelHeaderLeadingWidth, - buttonCenterX: iosGlassChannelHeaderButtonCenterX, - foregroundColor: context._onboardingInk, - ), - ) - : IconButton( - icon: const Icon(BuzzIcons.arrowLeft), + : PreferredSize( + preferredSize: Size.fromHeight( + frostedAppBarHeight(context) - + MediaQuery.paddingOf(context).top, + ), + child: Stack( + children: [ + FrostedAppBar( + alwaysFrosted: true, + leading: IconButton( tooltip: 'Back', + icon: const Icon(BuzzIcons.arrowLeft), onPressed: () => Navigator.of(context).maybePop(), ), - title: identityRecoveryOnly - ? Text( - 'Send to Desktop', - style: context.textTheme.titleMedium?.copyWith( - color: context._onboardingInk, - ), - ) - : null, + iconColor: context._onboardingInk, + title: identityRecoveryOnly + ? const Text('Send to Desktop') + : null, + ), + ], + ), ) : null; diff --git a/mobile/lib/features/settings/settings_page.dart b/mobile/lib/features/settings/settings_page.dart index 15d0bb8dae..8eef2f7be5 100644 --- a/mobile/lib/features/settings/settings_page.dart +++ b/mobile/lib/features/settings/settings_page.dart @@ -92,7 +92,7 @@ class SettingsPage extends HookConsumerWidget { ), automaticallyImplyLeading: false, horizontalInset: Grid.gutter, - showBottomDivider: false, + leading: embedded ? null : Theme.of(context).platform == TargetPlatform.iOS diff --git a/mobile/lib/features/settings/theme_picker_page/theme_preview_sheet.dart b/mobile/lib/features/settings/theme_picker_page/theme_preview_sheet.dart index 0dfe750849..5828ed8996 100644 --- a/mobile/lib/features/settings/theme_picker_page/theme_preview_sheet.dart +++ b/mobile/lib/features/settings/theme_picker_page/theme_preview_sheet.dart @@ -58,7 +58,7 @@ class _ThemePreviewExperience extends HookConsumerWidget { appBar: FrostedAppBar( automaticallyImplyLeading: false, centerTitle: true, - showBottomDivider: false, + nativeLeading: IosNavigationAction( label: 'Close', symbol: 'xmark', diff --git a/mobile/lib/shared/widgets/frosted_app_bar.dart b/mobile/lib/shared/widgets/frosted_app_bar.dart index a410f6e238..b17b84ad07 100644 --- a/mobile/lib/shared/widgets/frosted_app_bar.dart +++ b/mobile/lib/shared/widgets/frosted_app_bar.dart @@ -1,5 +1,3 @@ -import 'dart:ui'; - import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import 'package:buzz/shared/theme/buzz_icons.dart'; @@ -11,11 +9,11 @@ import 'frosted_scroll_under_scope.dart'; import 'ios_glass_navigation_button.dart'; import 'ios_glass_navigation_action.dart'; import 'ios_navigation_bar.dart'; +import 'navigation_backdrop.dart'; export 'ios_navigation_bar.dart' show IosNavigationAction; /// Minimum height of the frosted app bar content area below the safe area. const _kBarContentMinHeight = buzzNavigationRowHeight; -const _kBottomBorderWidth = 1.0; TextStyle _effectiveTitleStyle(BuildContext context, TextStyle? titleStyle) { final baseStyle = @@ -82,8 +80,7 @@ double frostedAppBarHeight( } return MediaQuery.paddingOf(context).top + _barContentHeight(context, titleStyle, titleContentHeight) + - bottomHeight + - _kBottomBorderWidth; + bottomHeight; } /// A frosted-glass floating app bar designed to sit inside a [Stack]. @@ -134,11 +131,6 @@ class FrostedAppBar extends StatelessWidget { /// Color applied to icons in the app bar. final Color? iconColor; - /// Paints over the frosted fill instead of the default translucent surface. - /// Used by the Buzz themes to carry their branded gradient across the app's - /// top section — see [buzzTopSectionGradient]. - final Gradient? gradient; - /// Whether to apply the translucent blur treatment behind the app bar. /// /// The backdrop stays clear at rest. This enables the treatment when the @@ -149,18 +141,6 @@ class FrostedAppBar extends StatelessWidget { /// Conversation headers use this while their timeline and composer resize. final bool alwaysFrosted; - /// Opacity of the frosted surface above the blurred backdrop. - final double frostedSurfaceOpacity; - - /// Blur strength of the frosted backdrop. - final double frostedBlurSigma; - - /// Whether to draw a divider below the app bar. - final bool showBottomDivider; - - /// Opacity of the divider below the app bar. - final double bottomDividerOpacity; - /// Explicit UIKit title for headers whose Flutter title is a custom widget. final String? nativeTitle; @@ -181,7 +161,8 @@ class FrostedAppBar extends StatelessWidget { /// Whether UIKit should expand the title at the top of the page. final bool nativeLargeTitle; - /// Use the composable frosted header for custom title and filter layouts. + /// Whether UIKit owns the title and actions. Custom Flutter layouts still + /// use the native soft backdrop on iOS. final bool useNativeNavigation; /// Duration for coordinated native header and overlapping control movement. @@ -227,18 +208,11 @@ class FrostedAppBar extends StatelessWidget { this.actions = const [], this.horizontalInset = Grid.xxs, this.iconColor, - this.gradient, this.frosted = true, this.alwaysFrosted = false, - this.frostedSurfaceOpacity = 0.5, - this.frostedBlurSigma = 20, - this.showBottomDivider = true, - this.bottomDividerOpacity = 0.05, }) : assert(bottom == null || bottomHeight + bottomOverlap > 0), assert(bottomOverlap >= 0), - assert(bottom != null || bottomOverlap == 0), - assert(frostedBlurSigma >= 0), - assert(bottomDividerOpacity >= 0 && bottomDividerOpacity <= 1); + assert(bottom != null || bottomOverlap == 0); @override Widget build(BuildContext context) { @@ -346,7 +320,6 @@ class FrostedAppBar extends StatelessWidget { final isScrolledUnder = alwaysFrosted || (scrollUnder?.isScrolledUnder ?? false); final paintsFrost = frosted && isScrolledUnder; - final paintsBottomDivider = showBottomDivider && isScrolledUnder; final canPop = Navigator.canPop(context); final effectiveTitleStyle = _effectiveTitleStyle(context, titleStyle); final barContentHeight = _barContentHeight( @@ -458,37 +431,14 @@ class FrostedAppBar extends StatelessWidget { final background = Container( key: const ValueKey('frosted-app-bar-background'), padding: EdgeInsets.only(top: topPadding), - decoration: BoxDecoration( - color: gradient != null - ? null - : paintsFrost - ? context.colors.surface.withValues(alpha: frostedSurfaceOpacity) - : Colors.transparent, - gradient: gradient, - border: showBottomDivider - ? Border( - bottom: BorderSide( - color: paintsBottomDivider - ? navigationDivider(context, bottomDividerOpacity) - : Colors.transparent, - width: _kBottomBorderWidth, - ), - ) - : null, - ), + decoration: const BoxDecoration(), child: content, ); - final child = ClipRect( - child: paintsFrost - ? BackdropFilter( - filter: ImageFilter.blur( - sigmaX: frostedBlurSigma, - sigmaY: frostedBlurSigma, - ), - child: background, - ) - : background, + final child = NavigationBackdrop( + active: paintsFrost, + suppressNativeView: nativeSuppressed, + child: background, ); return Positioned(top: 0, left: 0, right: 0, child: child); diff --git a/mobile/lib/shared/widgets/ios_navigation_bar.dart b/mobile/lib/shared/widgets/ios_navigation_bar.dart index ef438468e9..86223a2a10 100644 --- a/mobile/lib/shared/widgets/ios_navigation_bar.dart +++ b/mobile/lib/shared/widgets/ios_navigation_bar.dart @@ -133,6 +133,7 @@ class IosNavigationBar extends HookConsumerWidget { this.onTitlePressed, this.largeTitle = false, this.alwaysFrosted = false, + this.backdropOnly = false, this.leading, this.actions = const [], this.onBack, @@ -155,6 +156,9 @@ class IosNavigationBar extends HookConsumerWidget { /// Keeps the navigation backdrop visible before the first scroll update. final bool alwaysFrosted; + + /// Paints only the native edge beneath custom Flutter header controls. + final bool backdropOnly; final IosNavigationAction? leading; final List actions; final VoidCallback? onBack; @@ -319,6 +323,7 @@ class IosNavigationBar extends HookConsumerWidget { 'titleEnabled': onTitlePressed != null, 'largeTitle': largeTitle, 'alwaysFrosted': alwaysFrosted, + 'backdropOnly': backdropOnly, 'back': onBack != null, 'leading': leading == null ? null : encodeAction(leading!, 'leading'), 'actions': [ diff --git a/mobile/lib/shared/widgets/navigation_backdrop.dart b/mobile/lib/shared/widgets/navigation_backdrop.dart new file mode 100644 index 0000000000..0820ef38cf --- /dev/null +++ b/mobile/lib/shared/widgets/navigation_backdrop.dart @@ -0,0 +1,63 @@ +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +import '../theme/theme.dart'; +import 'ios_navigation_bar.dart'; + +/// The shared top-edge treatment, independent of a header's controls. +/// +/// iOS uses the same native soft edge as [IosNavigationBar]. Other platforms +/// use Home's translucent Flutter blur. The child remains interactive and +/// supplies its own safe-area padding. +class NavigationBackdrop extends StatelessWidget { + const NavigationBackdrop({ + super.key, + required this.child, + this.active = true, + this.suppressNativeView = false, + }); + + final Widget child; + + /// Activates the Flutter blur; UIKit owns native scroll-edge visibility. + final bool active; + + /// Flutter backdrop transitions cannot composite over a native platform view. + final bool suppressNativeView; + + @override + Widget build(BuildContext context) { + if (defaultTargetPlatform == TargetPlatform.iOS && !suppressNativeView) { + return Stack( + children: [ + Positioned.fill( + child: IgnorePointer( + child: ExcludeSemantics( + child: IosNavigationBar( + title: '', + backdropOnly: true, + alwaysFrosted: true, + ), + ), + ), + ), + child, + ], + ); + } + return ClipRect( + child: BackdropFilter( + enabled: active, + filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20), + child: ColoredBox( + color: active + ? context.colors.surface.withValues(alpha: 0.45) + : Colors.transparent, + child: child, + ), + ), + ); + } +} diff --git a/mobile/lib/shared/widgets/onboarding_step_page.dart b/mobile/lib/shared/widgets/onboarding_step_page.dart index 17df866ca3..e1a58a44a8 100644 --- a/mobile/lib/shared/widgets/onboarding_step_page.dart +++ b/mobile/lib/shared/widgets/onboarding_step_page.dart @@ -5,6 +5,7 @@ import 'package:flutter/semantics.dart'; import '../theme/theme.dart'; import 'ios_navigation_bar.dart'; +import 'navigation_backdrop.dart'; /// Opaque onboarding chrome shared by account setup and identity import. /// A scrollable minimum-height body keeps actions at the bottom without @@ -106,16 +107,18 @@ class OnboardingStepPage extends StatelessWidget { ), ) else if (onBack != null) - Align( - alignment: AlignmentDirectional.centerStart, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: Grid.xxs, - ), - child: IconButton( - tooltip: 'Back', - onPressed: onBack, - icon: const BackButtonIcon(), + NavigationBackdrop( + child: Align( + alignment: AlignmentDirectional.centerStart, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: Grid.xxs, + ), + child: IconButton( + tooltip: 'Back', + onPressed: onBack, + icon: const BackButtonIcon(), + ), ), ), ), diff --git a/mobile/lib/shared/widgets/profile_avatar_crop_page.dart b/mobile/lib/shared/widgets/profile_avatar_crop_page.dart index 0b26c05c00..76c06afcfd 100644 --- a/mobile/lib/shared/widgets/profile_avatar_crop_page.dart +++ b/mobile/lib/shared/widgets/profile_avatar_crop_page.dart @@ -9,6 +9,8 @@ import 'package:image/image.dart' as image; import '../theme/theme.dart'; import 'buzz_loading_indicator.dart'; +import 'frosted_app_bar.dart'; +import 'frosted_scaffold.dart'; const _cropOutputSize = 512; @@ -95,246 +97,259 @@ class ProfileAvatarCropPage extends HookWidget { return () => disposed = true; }, [imageBytes]); - return Scaffold( - backgroundColor: Colors.black, - appBar: AppBar( + return Theme( + data: AppTheme.dark(), + child: FrostedScaffold( backgroundColor: Colors.black, - foregroundColor: Colors.white, - centerTitle: true, - titleSpacing: 0, - title: Text( - 'Position Photo', - maxLines: 1, - style: context.textTheme.titleSmall?.copyWith( - color: Colors.white, - fontWeight: FontWeight.w600, - ), - ), - leadingWidth: 120, - leading: Padding( - padding: const EdgeInsets.only(left: Grid.gutter), - child: Align( - alignment: Alignment.centerLeft, - child: _CropHeaderButton( - label: 'Back', - onPressed: isCropping.value ? null : () => Navigator.pop(context), + appBar: FrostedAppBar( + useNativeNavigation: false, + horizontalInset: 0, + alwaysFrosted: true, + iconColor: Colors.white, + centerTitle: true, + title: Text( + 'Position Photo', + maxLines: 1, + style: context.textTheme.titleSmall?.copyWith( + color: Colors.white, + fontWeight: FontWeight.w600, ), ), - ), - actions: [ - Padding( - padding: const EdgeInsets.only(right: Grid.gutter), - child: _CropHeaderButton( - key: const ValueKey('avatar-crop-use-photo'), - label: 'Done', - loading: isCropping.value, - onPressed: - isCropping.value || - preparedBytes.value == null || - dimensions == null - ? null - : () async { - isCropping.value = true; - unawaited(HapticFeedback.lightImpact()); - try { - if (!context.mounted) return; - final geometry = cropGeometry.value; - if (geometry == null) return; - final cropped = await compute( - _cropAvatar, - _CropRequest( - bytes: preparedBytes.value!, - sourceWidth: dimensions.width, - sourceHeight: dimensions.height, - canvasWidth: geometry.canvasWidth, - canvasHeight: geometry.canvasHeight, - cropDiameter: geometry.cropDiameter, - transform: List.from( - controller.value.storage, + leading: Padding( + padding: const EdgeInsets.only(left: Grid.gutter), + child: Align( + widthFactor: 1, + alignment: Alignment.centerLeft, + child: _CropHeaderButton( + label: 'Back', + onPressed: isCropping.value + ? null + : () => Navigator.pop(context), + ), + ), + ), + actions: [ + Padding( + padding: const EdgeInsets.only(right: Grid.gutter), + child: _CropHeaderButton( + key: const ValueKey('avatar-crop-use-photo'), + label: 'Done', + loading: isCropping.value, + onPressed: + isCropping.value || + preparedBytes.value == null || + dimensions == null + ? null + : () async { + isCropping.value = true; + unawaited(HapticFeedback.lightImpact()); + try { + if (!context.mounted) return; + final geometry = cropGeometry.value; + if (geometry == null) return; + final cropped = await compute( + _cropAvatar, + _CropRequest( + bytes: preparedBytes.value!, + sourceWidth: dimensions.width, + sourceHeight: dimensions.height, + canvasWidth: geometry.canvasWidth, + canvasHeight: geometry.canvasHeight, + cropDiameter: geometry.cropDiameter, + transform: List.from( + controller.value.storage, + ), ), - ), - ); - if (context.mounted) Navigator.pop(context, cropped); - } finally { - if (context.mounted) isCropping.value = false; - } - }, + ); + if (context.mounted) Navigator.pop(context, cropped); + } finally { + if (context.mounted) isCropping.value = false; + } + }, + ), ), + ], + ), + body: Padding( + padding: EdgeInsets.only( + top: frostedAppBarHeight(context, useNativeNavigation: false), ), - ], - ), - body: loadError.value || dimensionsSnapshot.hasError - ? const Center( - child: Text( - "We couldn't prepare that photo.", - style: TextStyle(color: Colors.white), - ), - ) - : preparedBytes.value == null || dimensions == null - ? const Center( - child: BuzzLoadingIndicator( - color: Colors.white, - semanticLabel: 'Preparing photo', - ), - ) - : LayoutBuilder( - builder: (context, constraints) { - final canvasWidth = constraints.maxWidth; - final canvasHeight = math.max(1.0, constraints.maxHeight); - final cropDiameter = math.min(canvasWidth, canvasHeight); - cropGeometry.value = _CropGeometry( - canvasWidth: canvasWidth, - canvasHeight: canvasHeight, - cropDiameter: cropDiameter, - ); - final aspect = dimensions.width / dimensions.height; - final displayWidth = aspect >= 1 - ? cropDiameter * aspect - : cropDiameter; - final displayHeight = aspect >= 1 - ? cropDiameter - : cropDiameter / aspect; - displaySize.value = Size(displayWidth, displayHeight); - final canvasSize = Size(canvasWidth, canvasHeight); - if (initializedForSize.value != canvasSize) { - initializedForSize.value = canvasSize; - controller.value = Matrix4.identity() - ..translateByDouble( - (canvasWidth - displayWidth) / 2, - (canvasHeight - displayHeight) / 2, - 0, - 1, + child: loadError.value || dimensionsSnapshot.hasError + ? const Center( + child: Text( + "We couldn't prepare that photo.", + style: TextStyle(color: Colors.white), + ), + ) + : preparedBytes.value == null || dimensions == null + ? const Center( + child: BuzzLoadingIndicator( + color: Colors.white, + semanticLabel: 'Preparing photo', + ), + ) + : LayoutBuilder( + builder: (context, constraints) { + final canvasWidth = constraints.maxWidth; + final canvasHeight = math.max(1.0, constraints.maxHeight); + final cropDiameter = math.min(canvasWidth, canvasHeight); + cropGeometry.value = _CropGeometry( + canvasWidth: canvasWidth, + canvasHeight: canvasHeight, + cropDiameter: cropDiameter, ); - } - void movePhoto(Offset delta) { - unawaited(HapticFeedback.selectionClick()); - final matrix = controller.value.clone(); - matrix.storage[12] += delta.dx; - matrix.storage[13] += delta.dy; - controller.value = matrix; - } + final aspect = dimensions.width / dimensions.height; + final displayWidth = aspect >= 1 + ? cropDiameter * aspect + : cropDiameter; + final displayHeight = aspect >= 1 + ? cropDiameter + : cropDiameter / aspect; + displaySize.value = Size(displayWidth, displayHeight); + final canvasSize = Size(canvasWidth, canvasHeight); + if (initializedForSize.value != canvasSize) { + initializedForSize.value = canvasSize; + controller.value = Matrix4.identity() + ..translateByDouble( + (canvasWidth - displayWidth) / 2, + (canvasHeight - displayHeight) / 2, + 0, + 1, + ); + } + void movePhoto(Offset delta) { + unawaited(HapticFeedback.selectionClick()); + final matrix = controller.value.clone(); + matrix.storage[12] += delta.dx; + matrix.storage[13] += delta.dy; + controller.value = matrix; + } - void zoomPhoto(double factor) { - unawaited(HapticFeedback.selectionClick()); - final matrix = controller.value.clone(); - final currentScale = matrix.getMaxScaleOnAxis(); - final nextScale = (currentScale * factor) - .clamp(1.0, 5.0) - .toDouble(); - final appliedFactor = nextScale / currentScale; - final center = Offset(canvasWidth / 2, canvasHeight / 2); - matrix.storage[12] = - center.dx - - (center.dx - matrix.storage[12]) * appliedFactor; - matrix.storage[13] = - center.dy - - (center.dy - matrix.storage[13]) * appliedFactor; - matrix.storage[0] *= appliedFactor; - matrix.storage[5] *= appliedFactor; - matrix.storage[10] *= appliedFactor; - controller.value = matrix; - cropScale.value = nextScale; - } + void zoomPhoto(double factor) { + unawaited(HapticFeedback.selectionClick()); + final matrix = controller.value.clone(); + final currentScale = matrix.getMaxScaleOnAxis(); + final nextScale = (currentScale * factor) + .clamp(1.0, 5.0) + .toDouble(); + final appliedFactor = nextScale / currentScale; + final center = Offset(canvasWidth / 2, canvasHeight / 2); + matrix.storage[12] = + center.dx - + (center.dx - matrix.storage[12]) * appliedFactor; + matrix.storage[13] = + center.dy - + (center.dy - matrix.storage[13]) * appliedFactor; + matrix.storage[0] *= appliedFactor; + matrix.storage[5] *= appliedFactor; + matrix.storage[10] *= appliedFactor; + controller.value = matrix; + cropScale.value = nextScale; + } - final currentScale = cropScale.value; - final maskBottom = (canvasHeight + cropDiameter) / 2; - return Stack( - children: [ - SizedBox( - width: canvasWidth, - height: canvasHeight, - child: Stack( - fit: StackFit.expand, - children: [ - ClipRect( - child: Semantics( - label: 'Photo crop', - value: '${(currentScale * 100).round()}% zoom', - customSemanticsActions: { - const CustomSemanticsAction( - label: 'Move left', - ): () => - movePhoto(const Offset(-24, 0)), - const CustomSemanticsAction( - label: 'Move right', - ): () => - movePhoto(const Offset(24, 0)), - const CustomSemanticsAction( - label: 'Move up', - ): () => - movePhoto(const Offset(0, -24)), - const CustomSemanticsAction( - label: 'Move down', - ): () => - movePhoto(const Offset(0, 24)), - if (currentScale < 5) - const CustomSemanticsAction( - label: 'Zoom in', - ): () => - zoomPhoto(1.1), - if (currentScale > 1) - const CustomSemanticsAction( - label: 'Zoom out', - ): () => - zoomPhoto(1 / 1.1), - }, - child: ExcludeSemantics( - child: InteractiveViewer( - key: const ValueKey('avatar-crop-viewer'), - transformationController: controller, - constrained: false, - panEnabled: true, - scaleEnabled: true, - minScale: 1, - maxScale: 5, - onInteractionUpdate: (_) { - final nextScale = controller.value - .getMaxScaleOnAxis(); - if ((cropScale.value - nextScale).abs() > - 0.001) { - cropScale.value = nextScale; - } + final currentScale = cropScale.value; + final maskBottom = (canvasHeight + cropDiameter) / 2; + return Stack( + children: [ + SizedBox( + width: canvasWidth, + height: canvasHeight, + child: Stack( + fit: StackFit.expand, + children: [ + ClipRect( + child: Semantics( + label: 'Photo crop', + value: + '${(currentScale * 100).round()}% zoom', + customSemanticsActions: { + const CustomSemanticsAction( + label: 'Move left', + ): () => + movePhoto(const Offset(-24, 0)), + const CustomSemanticsAction( + label: 'Move right', + ): () => + movePhoto(const Offset(24, 0)), + const CustomSemanticsAction( + label: 'Move up', + ): () => + movePhoto(const Offset(0, -24)), + const CustomSemanticsAction( + label: 'Move down', + ): () => + movePhoto(const Offset(0, 24)), + if (currentScale < 5) + const CustomSemanticsAction( + label: 'Zoom in', + ): () => + zoomPhoto(1.1), + if (currentScale > 1) + const CustomSemanticsAction( + label: 'Zoom out', + ): () => + zoomPhoto(1 / 1.1), }, - boundaryMargin: EdgeInsets.all( - math.max(canvasWidth, canvasHeight), - ), - child: Image.memory( - preparedBytes.value!, - width: displayWidth, - height: displayHeight, - fit: BoxFit.fill, - gaplessPlayback: true, + child: ExcludeSemantics( + child: InteractiveViewer( + key: const ValueKey('avatar-crop-viewer'), + transformationController: controller, + constrained: false, + panEnabled: true, + scaleEnabled: true, + minScale: 1, + maxScale: 5, + onInteractionUpdate: (_) { + final nextScale = controller.value + .getMaxScaleOnAxis(); + if ((cropScale.value - nextScale) + .abs() > + 0.001) { + cropScale.value = nextScale; + } + }, + boundaryMargin: EdgeInsets.all( + math.max(canvasWidth, canvasHeight), + ), + child: Image.memory( + preparedBytes.value!, + width: displayWidth, + height: displayHeight, + fit: BoxFit.fill, + gaplessPlayback: true, + ), + ), ), ), ), - ), + IgnorePointer( + child: CustomPaint( + painter: _CropMaskPainter(cropDiameter), + ), + ), + ], ), - IgnorePointer( - child: CustomPaint( - painter: _CropMaskPainter(cropDiameter), - ), - ), - ], - ), - ), - Positioned( - left: 0, - right: 0, - top: math.min( - maskBottom + Grid.twelve, - canvasHeight - 24, - ), - child: const Center( - child: Text( - 'Move and scale', - style: TextStyle(color: Colors.white70), ), - ), - ), - ], - ); - }, - ), + Positioned( + left: 0, + right: 0, + top: math.min( + maskBottom + Grid.twelve, + canvasHeight - 24, + ), + child: const Center( + child: Text( + 'Move and scale', + style: TextStyle(color: Colors.white70), + ), + ), + ), + ], + ); + }, + ), + ), + ), ); } } diff --git a/mobile/test/features/activity/activity_page_test.dart b/mobile/test/features/activity/activity_page_test.dart index 383c94ab50..1dfb850c70 100644 --- a/mobile/test/features/activity/activity_page_test.dart +++ b/mobile/test/features/activity/activity_page_test.dart @@ -208,9 +208,8 @@ void main() { expect(appBar.nativeLeading?.symbol, 'xmark'); expect(appBar.nativeLeading?.label, 'Close inbox'); expect(appBar.nativeTitle, 'Inbox'); - expect(appBar.gradient, isNull); expect(appBar.frosted, isTrue); - expect(appBar.showBottomDivider, isTrue); + expect(appBar.bottomHeight, Grid.xxs); expect(appBar.centerTitle, isFalse); expect(find.byTooltip('Back'), findsNothing); diff --git a/mobile/test/features/channels/channel_detail_page_test.dart b/mobile/test/features/channels/channel_detail_page_test.dart index 49f11430f0..e3ae0978a6 100644 --- a/mobile/test/features/channels/channel_detail_page_test.dart +++ b/mobile/test/features/channels/channel_detail_page_test.dart @@ -12546,9 +12546,7 @@ void main() { find.byType(FrostedAppBar).last, ); expect(detailsAppBar.frosted, isFalse); - expect(detailsAppBar.frostedSurfaceOpacity, 0); - expect(detailsAppBar.frostedBlurSigma, 0); - expect(detailsAppBar.showBottomDivider, isFalse); + expect(detailsAppBar.centerTitle, isTrue); final descriptionBottom = tester @@ -12601,10 +12599,7 @@ void main() { find.byType(FrostedAppBar).last, ); expect(detailsAppBar.frosted, isTrue); - expect(detailsAppBar.frostedSurfaceOpacity, 0.5); - expect(detailsAppBar.frostedBlurSigma, 20); - expect(detailsAppBar.showBottomDivider, isTrue); - expect(detailsAppBar.bottomDividerOpacity, 0.07); + expect( tester .widget( diff --git a/mobile/test/features/channels/channels_page_test.dart b/mobile/test/features/channels/channels_page_test.dart index 4417d39945..2c091d5875 100644 --- a/mobile/test/features/channels/channels_page_test.dart +++ b/mobile/test/features/channels/channels_page_test.dart @@ -647,11 +647,10 @@ void main() { .height, closeTo( frostedAppBarHeight( - tester.element(find.byType(FrostedAppBar).last), - titleStyle: titleStyle, - bottomHeight: appBar.bottomHeight, - ) - - 1, + tester.element(find.byType(FrostedAppBar).last), + titleStyle: titleStyle, + bottomHeight: appBar.bottomHeight, + ), 0.01, ), ); @@ -768,9 +767,7 @@ void main() { find.byType(FrostedAppBar).last, ); expect(appBar.frosted, isFalse); - expect(appBar.frostedSurfaceOpacity, 0); - expect(appBar.frostedBlurSigma, 0); - expect(appBar.showBottomDivider, isFalse); + expect(appBar.bottomHeight, Grid.xxs); }); @@ -806,14 +803,11 @@ void main() { await tester.pump(); var appBar = tester.widget(find.byType(FrostedAppBar).last); expect(appBar.frosted, isTrue); - expect(appBar.frostedSurfaceOpacity, 0); - expect(appBar.frostedBlurSigma, closeTo(8.67, 0.001)); scrollable.position.jumpTo(Grid.xxl); await tester.pump(); appBar = tester.widget(find.byType(FrostedAppBar).last); - expect(appBar.frostedSurfaceOpacity, 0); - expect(appBar.frostedBlurSigma, 23.12); + expect(appBar.frosted, isTrue); }); testWidgets('Home keeps header blur after returning from search', ( @@ -2221,7 +2215,11 @@ void main() { if (nativeHeader) { destinationRect = const Rect.fromLTWH(16, 68, 36, 36); final bar = tester.widget( - find.byType(FrostedAppBar), + find.byWidgetPredicate( + (widget) => + widget is FrostedAppBar && + widget.onNativeReadyChanged != null, + ), ); bar.nativeLeading!.onAvatarBoundsChanged!(destinationRect); bar.nativeLeading!.onPressed!(); @@ -2274,7 +2272,13 @@ void main() { if (nativeHeader) { expect( tester - .widget(find.byType(FrostedAppBar)) + .widget( + find.byWidgetPredicate( + (widget) => + widget is FrostedAppBar && + widget.onNativeReadyChanged != null, + ), + ) .nativeLeading! .avatarHidden, isTrue, @@ -2389,7 +2393,11 @@ void main() { // hold, and use fresh bounds rather than the old community's slot. expect(tester.getCenter(flyingAvatar), const Offset(195, 422)); final header = tester.widget( - find.byType(FrostedAppBar), + find.byWidgetPredicate( + (widget) => + widget is FrostedAppBar && + widget.onNativeReadyChanged != null, + ), ); header.nativeLeading!.onAvatarBoundsChanged!( const Rect.fromLTWH(24, 76, 36, 36), @@ -2483,7 +2491,11 @@ void main() { ); if (nativeHeader) { final bar = tester.widget( - find.byType(FrostedAppBar), + find.byWidgetPredicate( + (widget) => + widget is FrostedAppBar && + widget.onNativeReadyChanged != null, + ), ); expect(bar.nativeTitle, ''); expect(bar.nativeLargeTitle, isFalse); diff --git a/mobile/test/features/home/home_page_test.dart b/mobile/test/features/home/home_page_test.dart index af17ae6914..254fd2c92c 100644 --- a/mobile/test/features/home/home_page_test.dart +++ b/mobile/test/features/home/home_page_test.dart @@ -194,6 +194,41 @@ void main() { ), ); await tester.pumpAndSettle(); + final title = find.text('Messages'); + final titleTop = tester.getTopLeft(title).dy; + final scroll = tester + .widget(find.byType(CustomScrollView).first) + .controller!; + final expandedHeader = tester.widget( + find.byType(FrostedAppBar), + ); + scroll.jumpTo(expandedHeader.bottomHeight / 4); + await tester.pump(); + expect( + tester.getTopLeft(title).dy, + titleTop - expandedHeader.bottomHeight / 4, + ); + expect( + tester + .widget( + find.ancestor(of: title, matching: find.byType(Opacity)).first, + ) + .opacity, + closeTo(0.75, 0.01), + ); + scroll.jumpTo(expandedHeader.bottomHeight); + await tester.pump(); + expect( + tester + .widget( + find.ancestor(of: title, matching: find.byType(Opacity)).first, + ) + .opacity, + 0, + ); + scroll.jumpTo(0); + await tester.pump(); + expect(tester.getTopLeft(title).dy, titleTop); await tester.drag( find.byType(CustomScrollView).first, const Offset(0, -2000), diff --git a/mobile/test/features/pairing/pairing_page_test.dart b/mobile/test/features/pairing/pairing_page_test.dart index 5ea050a6b9..7bc93e5e62 100644 --- a/mobile/test/features/pairing/pairing_page_test.dart +++ b/mobile/test/features/pairing/pairing_page_test.dart @@ -14,6 +14,7 @@ import 'package:buzz/features/pairing/pairing_provider.dart'; import 'package:buzz/shared/community/community.dart'; import 'package:buzz/shared/security/sensitive_action_authorizer.dart'; import 'package:buzz/shared/theme/theme.dart'; +import 'package:buzz/shared/widgets/frosted_app_bar.dart'; import 'package:buzz/shared/widgets/buzz_loading_indicator.dart'; import '../../helpers/widget_helpers.dart'; @@ -381,21 +382,16 @@ void main() { expect(notifier.denied, isTrue); }); - testWidgets('keeps only Back on the clear add-community header', ( - tester, - ) async { + testWidgets('uses the shared frosted add-community header', (tester) async { await tester.pumpWidget( WidgetHelpers.testable(child: const PairingPage(addingCommunity: true)), ); - - expect(find.byType(AppBar), findsOneWidget); + expect(find.byType(AppBar), findsNothing); + expect(find.byType(FrostedAppBar), findsOneWidget); expect(find.text('Add Community'), findsNothing); - final appBar = tester.widget(find.byType(AppBar)); - expect(appBar.backgroundColor, Colors.transparent); - expect(appBar.surfaceTintColor, Colors.transparent); - expect(appBar.elevation, 0); - expect(appBar.scrolledUnderElevation, 0); - expect(find.byIcon(BuzzIcons.arrowLeft), findsOneWidget); + final appBar = tester.widget(find.byType(FrostedAppBar)); + expect(appBar.alwaysFrosted, isTrue); + expect(find.byTooltip('Back'), findsOneWidget); }); testWidgets('uses the native navigation bar on iOS', (tester) async { diff --git a/mobile/test/features/profile/profile_edit_page_test.dart b/mobile/test/features/profile/profile_edit_page_test.dart index 219bab5ff5..c5df9f3874 100644 --- a/mobile/test/features/profile/profile_edit_page_test.dart +++ b/mobile/test/features/profile/profile_edit_page_test.dart @@ -426,6 +426,7 @@ void main() { await tester.tap(find.text('Photo Library')); await _waitForAvatarCropToLoad(tester); expect(find.text('Position Photo'), findsOneWidget); + expect(tester.getSize(find.text('Position Photo')).width, greaterThan(0)); final cancelButton = find.ancestor( of: find.text('Back'), matching: find.byType(TextButton), diff --git a/mobile/test/shared/theme/buzz_theme_test.dart b/mobile/test/shared/theme/buzz_theme_test.dart index 4f41e56511..806b8fbb9e 100644 --- a/mobile/test/shared/theme/buzz_theme_test.dart +++ b/mobile/test/shared/theme/buzz_theme_test.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:buzz/shared/theme/theme.dart'; import 'package:buzz/shared/widgets/frosted_app_bar.dart'; +import 'package:buzz/shared/widgets/frosted_scaffold.dart'; +import 'package:buzz/shared/widgets/navigation_backdrop.dart'; void main() { group('Buzz theme catalog entries', () { @@ -146,28 +148,13 @@ void main() { }); group('theme threading', () { - BoxDecoration barDecoration(WidgetTester tester) { - final container = tester - .widgetList( - find.descendant( - of: find.byType(FrostedAppBar), - matching: find.byType(Container), - ), - ) - .first; - return container.decoration! as BoxDecoration; - } - Widget harness(ThemeData theme) => MaterialApp( theme: theme, home: Builder( - builder: (context) => Stack( - children: [ - FrostedAppBar( - gradient: context.appColors.topSectionGradient, - title: const Text('Home'), - ), - ], + builder: (context) => FrostedScaffold( + backgroundGradient: context.appColors.topSectionGradient, + appBar: const FrostedAppBar(title: Text('Home'), alwaysFrosted: true), + body: const SizedBox.expand(), ), ), ); @@ -186,10 +173,11 @@ void main() { ), ); - final decoration = barDecoration(tester); - expect(decoration.gradient, isNotNull); - // A BoxDecoration cannot paint a color and a gradient at once. - expect(decoration.color, isNull); + final background = tester.widget( + find.byKey(const ValueKey('frosted-scaffold-pinned-gradient')), + ); + expect((background.decoration as BoxDecoration).gradient, isNotNull); + expect(find.byType(NavigationBackdrop), findsOneWidget); }); testWidgets('non-Buzz themes keep the frosted surface fill', ( @@ -197,9 +185,11 @@ void main() { ) async { await tester.pumpWidget(harness(AppTheme.light())); - final decoration = barDecoration(tester); - expect(decoration.gradient, isNull); - expect(decoration.color, isNotNull); + expect( + find.byKey(const ValueKey('frosted-scaffold-pinned-gradient')), + findsNothing, + ); + expect(find.byType(NavigationBackdrop), findsOneWidget); }); testWidgets('Buzz section labels use 80% neutral foreground', ( diff --git a/mobile/test/shared/widgets/frosted_app_bar_test.dart b/mobile/test/shared/widgets/frosted_app_bar_test.dart index e8c558d472..ff7e4d36be 100644 --- a/mobile/test/shared/widgets/frosted_app_bar_test.dart +++ b/mobile/test/shared/widgets/frosted_app_bar_test.dart @@ -162,7 +162,7 @@ void main() { matching: find.byType(ClipRect), ); expect(tester.getSize(clip).height, closeTo(reportedHeight, 0.01)); - expect(reportedHeight, closeTo(titleContentHeight + Grid.xs + 1, 0.01)); + expect(reportedHeight, closeTo(titleContentHeight + Grid.xs, 0.01)); expect(tester.takeException(), isNull); }); diff --git a/mobile/test/shared/widgets/frosted_scaffold_test.dart b/mobile/test/shared/widgets/frosted_scaffold_test.dart index 6398516843..b3a7c056df 100644 --- a/mobile/test/shared/widgets/frosted_scaffold_test.dart +++ b/mobile/test/shared/widgets/frosted_scaffold_test.dart @@ -177,7 +177,12 @@ void main() { ), ); await tester.pumpAndSettle(); - expect(find.byType(BackdropFilter), findsOneWidget); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsOneWidget, + ); await tester.tap(find.byType(TextField)); tester.view.viewInsets = const FakeViewPadding(bottom: 300); await tester.enterText( @@ -185,65 +190,98 @@ void main() { 'One\nTwo\nThree\nFour\nFive', ); await tester.pumpAndSettle(); - expect(find.byType(BackdropFilter), findsOneWidget); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsOneWidget, + ); await tester.enterText(find.byType(TextField), ''); await tester.pumpAndSettle(); - expect(find.byType(BackdropFilter), findsOneWidget); - expect(_appBarBorder(tester)?.bottom.color.a, greaterThan(0)); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsOneWidget, + ); + expect(_appBarBorder(tester), isNull); timeline.jumpTo(reverse ? timeline.position.maxScrollExtent : 0); await tester.pumpAndSettle(); - expect(find.byType(BackdropFilter), findsNothing); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsNothing, + ); await tester.enterText( find.byType(TextField), 'One\nTwo\nThree\nFour\nFive', ); await tester.pumpAndSettle(); - expect(find.byType(BackdropFilter), findsNothing); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsNothing, + ); }, ); } - testWidgets( - 'page frost and divider appear only while content scrolls under header', - (tester) async { - await tester.pumpWidget( - MaterialApp( - theme: AppTheme.light(), - home: FrostedScaffold( - appBar: const FrostedAppBar(title: Text('Theme')), - body: ListView.builder( - key: const ValueKey('page-scroll-view'), - padding: const EdgeInsets.only(top: 57), - itemCount: 40, - itemBuilder: (_, index) => - SizedBox(height: 48, child: Text('Theme option $index')), - ), + testWidgets('page frost follows scrolling without a dividing line', ( + tester, + ) async { + await tester.pumpWidget( + MaterialApp( + theme: AppTheme.light(), + home: FrostedScaffold( + appBar: const FrostedAppBar(title: Text('Theme')), + body: ListView.builder( + key: const ValueKey('page-scroll-view'), + padding: const EdgeInsets.only(top: 57), + itemCount: 40, + itemBuilder: (_, index) => + SizedBox(height: 48, child: Text('Theme option $index')), ), ), - ); + ), + ); - expect(_appBarBorder(tester)?.bottom.color.a, 0); - expect(find.byType(BackdropFilter), findsNothing); + expect(_appBarBorder(tester), isNull); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsNothing, + ); - await tester.drag( - find.byKey(const ValueKey('page-scroll-view')), - const Offset(0, -120), - ); - await tester.pumpAndSettle(); + await tester.drag( + find.byKey(const ValueKey('page-scroll-view')), + const Offset(0, -120), + ); + await tester.pumpAndSettle(); - final border = _appBarBorder(tester); - expect(border, isNotNull); - expect(border!.bottom.color.a, greaterThan(0)); - expect(find.byType(BackdropFilter), findsOneWidget); + final border = _appBarBorder(tester); + expect(border, isNull); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsOneWidget, + ); - await tester.drag( - find.byKey(const ValueKey('page-scroll-view')), - const Offset(0, 500), - ); - await tester.pumpAndSettle(); + await tester.drag( + find.byKey(const ValueKey('page-scroll-view')), + const Offset(0, 500), + ); + await tester.pumpAndSettle(); - expect(_appBarBorder(tester)?.bottom.color.a, 0); - expect(find.byType(BackdropFilter), findsNothing); - }, - ); + expect(_appBarBorder(tester), isNull); + expect( + find.byWidgetPredicate( + (widget) => widget is BackdropFilter && widget.enabled, + ), + findsNothing, + ); + }); } diff --git a/mobile/test/shared/widgets/navigation_backdrop_test.dart b/mobile/test/shared/widgets/navigation_backdrop_test.dart new file mode 100644 index 0000000000..66b6ef8c8e --- /dev/null +++ b/mobile/test/shared/widgets/navigation_backdrop_test.dart @@ -0,0 +1,97 @@ +import 'dart:ui' as ui; + +import 'package:buzz/shared/theme/theme.dart'; +import 'package:buzz/shared/widgets/frosted_app_bar.dart'; +import 'package:buzz/shared/widgets/navigation_backdrop.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +void main() { + testWidgets('Android headers share Home blur and surface without a divider', ( + tester, + ) async { + debugDefaultTargetPlatformOverride = TargetPlatform.android; + addTearDown(() => debugDefaultTargetPlatformOverride = null); + await tester.pumpWidget( + MaterialApp( + theme: AppTheme.light(), + home: const Stack( + children: [ + FrostedAppBar(title: Text('Settings'), alwaysFrosted: true), + ], + ), + ), + ); + final backdrop = find.byType(NavigationBackdrop); + final blur = tester.widget( + find.descendant(of: backdrop, matching: find.byType(BackdropFilter)), + ); + expect(blur.enabled, isTrue); + expect(blur.filter, ui.ImageFilter.blur(sigmaX: 20, sigmaY: 20)); + final tint = tester.widget( + find.descendant(of: backdrop, matching: find.byType(ColoredBox)), + ); + expect( + tint.color, + AppTheme.light().colorScheme.surface.withValues(alpha: 0.45), + ); + expect(find.byType(UiKitView), findsNothing); + debugDefaultTargetPlatformOverride = null; + }); + + testWidgets( + 'custom iOS header keeps controls over a decorative native edge', + (tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + addTearDown(() => debugDefaultTargetPlatformOverride = null); + var taps = 0; + await tester.pumpWidget( + ProviderScope( + child: MaterialApp( + theme: AppTheme.light(), + home: Stack( + children: [ + FrostedAppBar( + useNativeNavigation: false, + automaticallyImplyLeading: false, + alwaysFrosted: true, + title: const Text('Messages'), + actions: [ + TextButton( + onPressed: () => taps++, + child: const Text('Search'), + ), + ], + bottomHeight: 40, + bottom: const Text('Filters'), + ), + ], + ), + ), + ), + ); + final native = find.byType(UiKitView); + final view = tester.widget(native); + expect(view.creationParams, containsPair('backdropOnly', true)); + expect(view.creationParams, containsPair('alwaysFrosted', true)); + expect( + find.ancestor(of: native, matching: find.byType(ExcludeSemantics)), + findsWidgets, + ); + expect( + find.ancestor(of: native, matching: find.byType(IgnorePointer)), + findsWidgets, + ); + expect(find.text('Messages'), findsOneWidget); + expect(find.text('Filters'), findsOneWidget); + await tester.tap(find.text('Search')); + expect(taps, 1); + expect(find.byType(BackdropFilter), findsNothing); + expect(tester.takeException(), isNull); + await tester.pumpWidget(const SizedBox()); + debugDefaultTargetPlatformOverride = null; + }, + ); +} diff --git a/scripts/test-mobile-me-agent-accessibility.sh b/scripts/test-mobile-me-agent-accessibility.sh index 6fd75eb013..d1477b3373 100755 --- a/scripts/test-mobile-me-agent-accessibility.sh +++ b/scripts/test-mobile-me-agent-accessibility.sh @@ -9,6 +9,7 @@ fixture=$(mktemp -d) trap 'rm -r "$fixture"' EXIT # Compile in one file to exercise the private production controller directly. cat "$repo_root/mobile/ios/Runner/MeAvatarLoader.swift" \ + "$repo_root/mobile/ios/Runner/NavigationTopEdge.swift" \ "$repo_root/mobile/ios/Runner/NativeProfileTextEditor.swift" \ "$repo_root/mobile/ios/NativeControlTests/MeAgentAccessibilityTests.swift" > "$fixture/test.swift" xcrun --sdk iphonesimulator swiftc -parse-as-library \ diff --git a/scripts/test-mobile-member-picker.sh b/scripts/test-mobile-member-picker.sh index 74b13b4abc..4e34b9c27d 100644 --- a/scripts/test-mobile-member-picker.sh +++ b/scripts/test-mobile-member-picker.sh @@ -12,6 +12,7 @@ xcrun --sdk iphonesimulator swiftc \ -target "$(uname -m)-apple-ios16.0-simulator" \ -F "$frameworks" -framework Flutter \ -Xlinker -rpath -Xlinker "$frameworks" \ + "$repo_root/mobile/ios/Runner/NavigationTopEdge.swift" \ "$repo_root/mobile/ios/Runner/NativeAddMembersSheet.swift" \ "$repo_root/mobile/ios/NativeControlTests/AddMembersIdentityTests.swift" \ -o "$fixture/member-picker-tests"