Skip to content

Commit 8cc7e94

Browse files
klopez4212Terp
andauthored
Refine mobile Messages sections, Duo navigation, and chat typography (#9885)
## Summary - Organize mobile Messages into configurable flat sections. See All keeps the list and its search position when opening a conversation, and supports side-by-side browsing on an unfolded Duo. - Use the same 16-point Messages gutter in booklet and open Duo layouts. The regular iPhone uses 20 points. Align navigation actions and use native inline titles on See All. - Update mobile typography and spacing across chat rows, message bubbles, drafts, and the composer. Render code proportionally to the 17-point message body. ## Device review Compare the leading edges of the section headings and channel icons in Messages on the open Duo and in booklet mode. Open See All and check that its rows follow the same column. --------- Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
1 parent a8cc77a commit 8cc7e94

117 files changed

Lines changed: 5066 additions & 1660 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎mobile/ios/Runner/IosNavigationBar.swift‎

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
171171
private var paneTitle: UIView?
172172
private var titleInsetLeft: CGFloat = 0
173173
private var titleInsetRight: CGFloat = 0
174+
private var leadingTitleRowTop: CGFloat?
175+
private var leadingTitleTopPadding: CGFloat = 24
174176
private var alignCollapsedTitleToLeading = false
175177
private var alwaysFrosted = false
176178
private var backdropOnly = false
@@ -180,6 +182,7 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
180182
private let compactTitle = UILabel()
181183
private let compactTitleContainer = UIStackView()
182184
private let compactTitleMask = CALayer()
185+
private var externalExpandedTitle = false
183186
private var titleColor = UIColor.label
184187
private var largeTitleOpacity: CGFloat = -1
185188
private var measuredWidth: CGFloat = 0
@@ -241,7 +244,11 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
241244
}
242245
result(nil)
243246
}
244-
configure(args as? [String: Any] ?? [:])
247+
let initial = args as? [String: Any] ?? [:]
248+
if let depth = initial["initialScrollOffset"] as? NSNumber, depth.doubleValue.isFinite {
249+
offset = min(max(0, depth.doubleValue), Self.maxTrackedDepth)
250+
}
251+
configure(initial)
245252
#if canImport(UIKit, _version: 9127.0.85)
246253
if #available(iOS 27.1, *), standaloneControl || floatingTitle != nil || backdropOnly {
247254
container.addInteraction(UIHingeInteraction { [weak self] _, _ in
@@ -305,8 +312,8 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
305312
// controls live in the side rail. Flutter still reserves a 44-point row
306313
// plus 24 points of breathing room. Give expanded titles that same space.
307314
let compact = (metrics?["compactHeight"] as? CGFloat) ?? 44
308-
let paneTitleClearance = alignCollapsedTitleToLeading
309-
? max(44, compact) + 24 - compact : 0
315+
let paneTitleClearance = alignCollapsedTitleToLeading && leadingTitleRowTop == nil
316+
? max(44, compact) + leadingTitleTopPadding - compact : 0
310317
// UIKit can place controls beside Duo's corner status region. Applying
311318
// Flutter's full-width top inset here pushes them down a second row.
312319
let requiredTop = portraitHeader != nil
@@ -369,9 +376,10 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
369376
title.frame = CGRect(x: alignCollapsedTitleToLeading
370377
? navigation.navigationBar.layoutMargins.left
371378
: center - size.width / 2,
372-
y: alignCollapsedTitleToLeading
373-
? flutterSafeTop + 24 + (44 - size.height) / 2
374-
: (container.bounds.height - size.height) / 2,
379+
y: leadingTitleRowTop.map { $0 + (44 - size.height) / 2 }
380+
?? (alignCollapsedTitleToLeading
381+
? flutterSafeTop + leadingTitleTopPadding + (44 - size.height) / 2
382+
: (container.bounds.height - size.height) / 2),
375383
width: size.width, height: size.height)
376384
title.layoutIfNeeded()
377385
}
@@ -518,6 +526,8 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
518526
portraitTopPadding = CGFloat((args["portraitTopPadding"] as? NSNumber)?.doubleValue ?? 0)
519527
paneTitle?.removeFromSuperview()
520528
paneTitle = nil
529+
leadingTitleRowTop = args["leadingTitleRowTop"] as? CGFloat
530+
leadingTitleTopPadding = (args["leadingTitleTopPadding"] as? NSNumber)?.doubleValue ?? 24
521531
alignCollapsedTitleToLeading = args["alignCollapsedTitleToLeading"] as? Bool == true
522532
headerLeading?.removeFromSuperview()
523533
headerTrailing?.removeFromSuperview()
@@ -572,7 +582,9 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
572582
navigation.view.accessibilityElementsHidden = backdropOnly
573583
let largeTitle = args["largeTitle"] as? Bool == true
574584
alwaysFrosted = args["alwaysFrosted"] as? Bool == true
585+
let prefersSoftTopEdge = args["prefersSoftTopEdge"] as? Bool == true
575586
if #available(iOS 26.0, *) {
587+
usesSystemScrollEdge = prefersSoftTopEdge
576588
if #available(iOS 27.0, *) {
577589
// All headers use the same native soft scroll edge. Custom titles
578590
// also retain material, like large titles, when embedding clips it.
@@ -586,23 +598,23 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
586598
// edge while the large-title inset is collapsing.
587599
// Keep the graduated material throughout that transition so partial
588600
// scrolling never leaves the title and status area unprotected.
589-
// Explicitly positioned controls hide the navigation view, including
590-
// UIKit's scroll edge. Keep our graduated blur behind those controls.
591-
material.isHidden = usesSystemScrollEdge && !largeTitle && !inlinePortrait
592-
&& args["centerTitleInPane"] as? Bool != true && !backdropOnly
601+
material.isHidden = usesSystemScrollEdge && !inlinePortrait && (prefersSoftTopEdge ||
602+
(!largeTitle && args["centerTitleInPane"] as? Bool != true && !backdropOnly))
593603
// Let the native fade extend past the bar without enlarging its hit area.
594604
// The mirrored content is transparent and the bottom edge is hidden.
595605
container.clipsToBounds = !usesSystemScrollEdge
596606
// Title, avatar and loading updates must not reset the blur appearance.
597-
if appearanceColor != color || appearanceUsesSystemScrollEdge != usesSystemScrollEdge {
607+
let externalTitle = args["externalExpandedTitle"] as? Bool == true
608+
if appearanceColor != color || appearanceUsesSystemScrollEdge != usesSystemScrollEdge || externalExpandedTitle != externalTitle {
609+
externalExpandedTitle = externalTitle
598610
let appearance = UINavigationBarAppearance()
599611
if usesSystemScrollEdge {
600612
appearance.configureWithDefaultBackground()
601613
} else {
602614
appearance.configureWithTransparentBackground()
603615
}
604616
appearance.titleTextAttributes = [.foregroundColor: color]
605-
appearance.largeTitleTextAttributes = [.foregroundColor: color]
617+
appearance.largeTitleTextAttributes = [.foregroundColor: externalTitle ? UIColor.clear : color]
606618
bar.standardAppearance = appearance
607619
bar.scrollEdgeAppearance = appearance
608620
bar.compactAppearance = appearance
@@ -620,7 +632,10 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
620632
floatingTitle?.removeFromSuperview()
621633
floatingTitle = nil
622634
let item = content.navigationItem
623-
item.title = args["title"] as? String
635+
let title = args["title"] as? String
636+
// Keep the actual title for UIKit's layout and the compact label.
637+
// The external expanded label owns the visible ink while at rest.
638+
item.title = largeTitle && (alignCollapsedTitleToLeading || leadingTitleRowTop != nil) && titleIsCollapsed == true ? "" : title
624639
if let subtitle = args["subtitle"] as? String {
625640
let button = NavigationTitleView(title: item.title, subtitle: subtitle, color: color, maximumWidth: titleMaxWidth)
626641
button.accessibilityIdentifier = "channel-navigation-title"
@@ -660,7 +675,7 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
660675
}
661676
refreshBar.setRefreshing(args["titleRefreshing"] as? Bool == true)
662677
} else if largeTitle {
663-
compactTitle.text = item.title
678+
compactTitle.text = title
664679
compactTitle.font = .preferredFont(forTextStyle: .headline)
665680
compactTitle.adjustsFontForContentSizeCategory = true
666681
compactTitle.textColor = color
@@ -670,10 +685,22 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
670685
compactTitle.layer.mask = compactTitleMask
671686
if compactTitle.superview == nil { compactTitleContainer.addArrangedSubview(compactTitle) }
672687
compactTitleContainer.frame.size = compactTitle.intrinsicContentSize
673-
if alignCollapsedTitleToLeading {
688+
if alignCollapsedTitleToLeading || leadingTitleRowTop != nil {
674689
// Duo's list title fades in place: the compact label uses the same
675690
// leading margin as UIKit's expanded title, rather than recentering.
676-
item.titleView = UIView()
691+
if leadingTitleRowTop != nil {
692+
// Reserve the cover's native control row while its visible label
693+
// sits beside the Flutter actions. An empty view collapses the row.
694+
let spacer = UILabel()
695+
spacer.text = title
696+
spacer.font = compactTitle.font
697+
spacer.textColor = .clear
698+
spacer.isAccessibilityElement = false
699+
spacer.sizeToFit()
700+
item.titleView = spacer
701+
} else {
702+
item.titleView = UIView()
703+
}
677704
compactTitleContainer.translatesAutoresizingMaskIntoConstraints = true
678705
paneTitle = compactTitleContainer
679706
container.addSubview(compactTitleContainer)
@@ -702,6 +729,14 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
702729
item.title = nil
703730
if let paneTitle { container.addSubview(paneTitle) }
704731
}
732+
if #available(iOS 26.0, *), prefersSoftTopEdge,
733+
let edgeTitle = floatingTitle ?? paneTitle ?? item.titleView,
734+
!edgeTitle.interactions.contains(where: { $0 is UIScrollEdgeElementContainerInteraction }) {
735+
let interaction = UIScrollEdgeElementContainerInteraction()
736+
interaction.scrollView = content.scrollView
737+
interaction.edge = .top
738+
edgeTitle.addInteraction(interaction)
739+
}
705740
item.largeTitleDisplayMode = bar.prefersLargeTitles ? .always : .never
706741
trackedAvatar = nil
707742
reportedAvatarFrame = nil
@@ -828,11 +863,18 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
828863
titleIsCollapsed = collapsed
829864
UIView.performWithoutAnimation {
830865
if navigation.navigationBar.prefersLargeTitles {
866+
if alignCollapsedTitleToLeading || leadingTitleRowTop != nil {
867+
// UIKit can reveal its expanded label while a sheet changes the
868+
// presenting view's safe area. Keep its line height for measurement,
869+
// but give the compact label sole ownership of the collapsed text.
870+
let title = collapsed ? "" : compactTitle.text
871+
if content.navigationItem.title != title { content.navigationItem.title = title }
872+
}
831873
// Fade the actual text throughout the last part of the gesture. A
832874
// snapshot transition of the platform view gets clipped by Flutter's
833875
// shrinking header and can still look like a one-frame title switch.
834876
let progress = min(1, max(0, (offset - collapseRange * 0.35) / (collapseRange * 0.65)))
835-
let opacity = 1 - progress
877+
let opacity: CGFloat = externalExpandedTitle ? 0 : 1 - progress
836878
if abs(largeTitleOpacity - opacity) > 0.001 {
837879
largeTitleOpacity = opacity
838880
for appearance in [navigation.navigationBar.standardAppearance,

‎mobile/ios/Runner/JumpToLatestGlassButton.swift‎

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,31 @@ private final class JumpToLatestGlassButton: UIButton {
4141
}
4242

4343
final class NavigationGlassButton: UIButton {
44+
var consumeOutsideTap = false
45+
private weak var menuBackdrop: UIControl?
46+
47+
override func didMoveToWindow() {
48+
super.didMoveToWindow()
49+
if window == nil { menuBackdrop?.removeFromSuperview() }
50+
}
51+
52+
private func installMenuBackdrop() {
53+
guard consumeOutsideTap, let host = window?.rootViewController?.view,
54+
let parent = host.superview else { return }
55+
menuBackdrop?.removeFromSuperview()
56+
// Place the touch target above Flutter's sheet and its modal barrier,
57+
// beneath the UIKit menu presentation.
58+
let backdrop = UIControl(frame: host.frame)
59+
backdrop.autoresizingMask = [.flexibleWidth, .flexibleHeight]
60+
backdrop.accessibilityLabel = NSLocalizedString("Dismiss menu", comment: "")
61+
backdrop.accessibilityTraits = .button
62+
backdrop.addAction(UIAction { [weak self] _ in
63+
self?.contextMenuInteraction?.dismissMenu()
64+
}, for: .touchUpInside)
65+
parent.insertSubview(backdrop, aboveSubview: host)
66+
menuBackdrop = backdrop
67+
}
68+
4469
var opensMenuAbove = false
4570
var hitTargetInsets = UIEdgeInsets.zero
4671
private static weak var visibleMenuButton: NavigationGlassButton?
@@ -58,6 +83,7 @@ final class NavigationGlassButton: UIButton {
5883

5984
private func finishMenuDismissal() {
6085
if !menuVisible && Self.visibleMenuButton === self { Self.visibleMenuButton = nil }
86+
if !menuVisible { menuBackdrop?.removeFromSuperview() }
6187
menuDismissing = false
6288
let action = pendingMenuAction
6389
pendingMenuAction = nil
@@ -92,6 +118,7 @@ final class NavigationGlassButton: UIButton {
92118
if let previous = Self.visibleMenuButton, previous !== self, previous.window === window {
93119
previous.contextMenuInteraction?.dismissMenu()
94120
}
121+
installMenuBackdrop()
95122
Self.visibleMenuButton = self
96123
animateMenu?(true, animator)
97124
menuVisibilityChanged?(true)
@@ -286,6 +313,7 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
286313
containerView.backgroundColor = .clear
287314
containerView.isOpaque = false
288315
let arguments = args as? [String: Any]
316+
button.consumeOutsideTap = arguments?["consumeOutsideTap"] as? Bool == true
289317
let buttonCenterX =
290318
(arguments?["buttonCenterX"] as? NSNumber)?.doubleValue ?? 24
291319
let hitTargetWidth =
@@ -387,6 +415,7 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
387415

388416
if arguments?["mergingNavigation"] as? Bool == true {
389417
let glass = MergingNavigationGlass(frame: containerView.bounds)
418+
glass.diameter = controlSize
390419
glass.vertical = arguments?["verticalNavigation"] as? Bool ?? false
391420
glass.autoresizingMask = [.flexibleWidth, .flexibleHeight]
392421
containerView.addSubview(glass)
@@ -562,7 +591,8 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
562591
if let menu = arguments?["menu"] as? [[String: Any]] {
563592
// Keep creation actions and titled sections in reading order even above a bottom-bar trigger.
564593
let hasImages = menu.contains { !(($0["symbol"] as? String) ?? "").isEmpty }
565-
button.preferredMenuElementOrder = arguments?["fixedMenuOrder"] as? Bool == true || !hasImages || menu.contains { $0["sectionTitle"] is String } ? .fixed : .automatic
594+
let hasOrderedActions = menu.contains { $0["sectionTitle"] is String || $0["destructive"] as? Bool == true }
595+
button.preferredMenuElementOrder = arguments?["fixedMenuOrder"] as? Bool == true || !hasImages || hasOrderedActions ? .fixed : .automatic
566596
var groups: [[UIMenuElement]] = [[]]
567597
var groupTitles = [""]
568598
for item in menu {
@@ -623,7 +653,7 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
623653
case "moon": buttonIconName = "moon"
624654
case "trash": buttonIconName = "trash"
625655
case "bell": buttonIconName = "bell"
626-
case "more": buttonIconName = "ellipsis"
656+
case "more", "moreCircle": buttonIconName = "ellipsis"
627657
case "chevronDown": buttonIconName = "chevron.down"
628658
case "reply": buttonIconName = "arrowshape.turn.up.left"
629659
case "systemAppearance": buttonIconName = "circle.lefthalf.filled"
@@ -672,6 +702,8 @@ final class NavigationGlassButtonPlatformView: NSObject, FlutterPlatformView {
672702
UIColor.white.setFill()
673703
UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: pointSize, height: pointSize)).fill()
674704
}.withRenderingMode(.alwaysTemplate)
705+
} else if icon == "moreCircle" {
706+
buttonImage = UIImage(systemName: "ellipsis.circle", withConfiguration: UIImage.SymbolConfiguration(pointSize: pointSize))
675707
} else {
676708
buttonImage = NativeTabler.image(buttonIconName, size: pointSize)
677709
}
@@ -848,6 +880,7 @@ final class NativeSegmentedControlPlatformView: NSObject, FlutterPlatformView {
848880

849881
/// Three native glass elements share a compositor so their surfaces merge.
850882
final class MergingNavigationGlass: UIView {
883+
var diameter: CGFloat = 56
851884
var vertical = false
852885
let leftSurface: UIVisualEffectView
853886
let centerSurface: UIVisualEffectView
@@ -891,17 +924,17 @@ final class MergingNavigationGlass: UIView {
891924
override func layoutSubviews() {
892925
super.layoutSubviews()
893926
// Use bounds/center rather than frame: side views may be transformed.
894-
leftSurface.bounds = CGRect(x: 0, y: 0, width: 56, height: 56)
927+
leftSurface.bounds = CGRect(x: 0, y: 0, width: diameter, height: diameter)
895928
rightSurface.bounds = leftSurface.bounds
896-
centerSurface.bounds = CGRect(x: 0, y: 0, width: vertical ? 56 : 112, height: 56)
897-
leftSurface.center = vertical ? CGPoint(x: bounds.midX, y: 28) : CGPoint(x: 28, y: bounds.midY)
898-
rightSurface.center = vertical ? CGPoint(x: bounds.midX, y: bounds.height - 28) : CGPoint(x: bounds.width - 28, y: bounds.midY)
929+
centerSurface.bounds = CGRect(x: 0, y: 0, width: vertical ? diameter : 112, height: diameter)
930+
leftSurface.center = vertical ? CGPoint(x: bounds.midX, y: diameter / 2) : CGPoint(x: diameter / 2, y: bounds.midY)
931+
rightSurface.center = vertical ? CGPoint(x: bounds.midX, y: bounds.height - diameter / 2) : CGPoint(x: bounds.width - diameter / 2, y: bounds.midY)
899932
centerSurface.center = CGPoint(x: bounds.midX, y: bounds.midY)
900933
}
901934

902935
func setMenuOpen(_ open: Bool, animator: UIContextMenuInteractionAnimating?) {
903936
layoutIfNeeded()
904-
let movement = (vertical ? bounds.midY : bounds.midX) - 28
937+
let movement = (vertical ? bounds.midY : bounds.midX) - diameter / 2
905938
let dx = vertical ? 0 : movement
906939
let dy = vertical ? movement : 0
907940
let changes = { [weak self] in

0 commit comments

Comments
 (0)