Skip to content

Commit a14107a

Browse files
authored
fix(mobile): refine iOS navigation and conversation details (#8075)
Fix iOS navigation title taps and truncation, theme-aware blur (including chats opened at the newest message), and the search focus animation with a plain, correctly spaced Cancel button. Simplify DM details and header actions, move profile descriptions below names, and remove redundant Settings/Add Community titles and unnecessary “See all” links. Validation: mobile analysis, formatting, file-size checks, and the full mobile test suite passed in pre-push hooks; Release iOS build installed and launched on a physical iPhone. Full `just ci` was stopped during unrelated desktop compilation due to low disk space. Native XCTest additions have not been run locally. Signed-off-by: kenny lopez <[email protected]>
1 parent e982f70 commit a14107a

17 files changed

Lines changed: 815 additions & 434 deletions

‎mobile/ios/Runner/IosNavigationBar.swift‎

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ final class IosNavigationBarFactory: NSObject, FlutterPlatformViewFactory {
2222
}
2323
}
2424

25-
private final class NavigationTitleView: UIView, UIGestureRecognizerDelegate {
25+
final class NavigationTitleView: UIView, UIGestureRecognizerDelegate {
26+
var maximumWidth: CGFloat = 240 {
27+
didSet { if maximumWidth != oldValue { invalidateIntrinsicContentSize() } }
28+
}
2629
var onActivate: (() -> Void)?
2730
var onExpiryPressed: ((String) -> Void)?
2831
private let titleLabel = UILabel()
2932
private let subtitleLabel = UILabel()
3033
private var avatarView: UIImageView?
3134
private var presenceView: UIView?
35+
private var subtitlePresenceView: UIView?
3236
private var expiryView: UIButton?
3337

3438
init(title: String?, subtitle: String, color: UIColor) {
@@ -45,6 +49,9 @@ private final class NavigationTitleView: UIView, UIGestureRecognizerDelegate {
4549
label.adjustsFontForContentSizeCategory = false
4650
addSubview(label)
4751
}
52+
// Flutter creates platform views with a zero frame. Keep a nonzero
53+
// intrinsic width and let UINavigationBar compress it between its items.
54+
setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
4855
isAccessibilityElement = true
4956
accessibilityTraits = .button
5057
let tap = UITapGestureRecognizer(target: self, action: #selector(activate))
@@ -71,6 +78,17 @@ private final class NavigationTitleView: UIView, UIGestureRecognizerDelegate {
7178
}
7279
}
7380

81+
func setSubtitlePresence(_ color: UIColor) {
82+
let dot = UIView()
83+
dot.backgroundColor = color
84+
dot.layer.cornerRadius = 3
85+
dot.isAccessibilityElement = false
86+
dot.accessibilityIdentifier = "dm-navigation-status-dot"
87+
addSubview(dot)
88+
subtitlePresenceView = dot
89+
invalidateIntrinsicContentSize()
90+
}
91+
7492
func setEphemeralStatus(_ label: String) {
7593
let clock = UIButton(type: .custom)
7694
clock.setImage(UIImage(systemName: "clock"), for: .normal)
@@ -86,8 +104,14 @@ private final class NavigationTitleView: UIView, UIGestureRecognizerDelegate {
86104
}
87105

88106
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
89-
var touched = touch.view
90-
while let view = touched {
107+
acceptsTitleTouch(in: touch.view)
108+
}
109+
110+
// UIKit can wrap titleView in a UIControl. Only controls inside our title
111+
// (such as the retention disclosure) should consume the title tap.
112+
func acceptsTitleTouch(in touchedView: UIView?) -> Bool {
113+
var touched = touchedView
114+
while let view = touched, view !== self {
91115
if view is UIControl { return false }
92116
touched = view.superview
93117
}
@@ -105,7 +129,7 @@ private final class NavigationTitleView: UIView, UIGestureRecognizerDelegate {
105129
}
106130

107131
override var intrinsicContentSize: CGSize {
108-
CGSize(width: max(titleLabel.intrinsicContentSize.width, subtitleLabel.intrinsicContentSize.width) + 16 + (avatarView == nil ? 0 : 40) + (expiryView == nil ? 0 : 44),
132+
CGSize(width: min(maximumWidth, max(titleLabel.intrinsicContentSize.width, subtitleLabel.intrinsicContentSize.width + (subtitlePresenceView == nil ? 0 : 12)) + 16 + (avatarView == nil ? 0 : 40) + (expiryView == nil ? 0 : 44)),
109133
height: max(44, titleLabel.intrinsicContentSize.height + subtitleLabel.intrinsicContentSize.height))
110134
}
111135

@@ -131,6 +155,14 @@ private final class NavigationTitleView: UIView, UIGestureRecognizerDelegate {
131155
y: 0, width: 44, height: bounds.height)
132156
titleLabel.frame = CGRect(x: textX, y: top, width: textWidth, height: titleHeight)
133157
subtitleLabel.frame = CGRect(x: textX, y: top + titleHeight, width: textWidth, height: subtitleHeight)
158+
if let dot = subtitlePresenceView {
159+
let labelWidth = min(subtitleLabel.intrinsicContentSize.width, max(0, textWidth - 12))
160+
let groupX = textX + (textWidth - labelWidth - 12) / 2
161+
dot.frame = CGRect(x: rtl ? groupX + labelWidth + 6 : groupX,
162+
y: top + titleHeight + (subtitleHeight - 6) / 2, width: 6, height: 6)
163+
subtitleLabel.frame = CGRect(x: rtl ? groupX : groupX + 12,
164+
y: top + titleHeight, width: labelWidth, height: subtitleHeight)
165+
}
134166
let avatarX: CGFloat = rtl ? bounds.width - 40 : 8
135167
avatarView?.frame = CGRect(x: avatarX, y: (bounds.height - 32) / 2, width: 32, height: 32)
136168
presenceView?.frame = CGRect(x: avatarX + (rtl ? 0 : 24), y: (bounds.height - 32) / 2 + 24, width: 8, height: 8)
@@ -232,6 +264,9 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
232264
private func configure(_ args: [String: Any]) {
233265
navigation.overrideUserInterfaceStyle = args["dark"] as? Bool == true ? .dark : .light
234266
material.overrideUserInterfaceStyle = navigation.overrideUserInterfaceStyle
267+
// Refresh the system material tint whenever the Flutter theme changes.
268+
material.contentView.backgroundColor = args["background"] is NSNumber
269+
? Self.color(args["background"]).withAlphaComponent(0.25) : .clear
235270
let bar = navigation.navigationBar
236271
let color = Self.color(args["foreground"])
237272
bar.tintColor = color
@@ -248,9 +283,9 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
248283
let largeTitle = args["largeTitle"] as? Bool == true
249284
if bar.prefersLargeTitles != largeTitle { measuredWidth = 0 }
250285
bar.prefersLargeTitles = largeTitle
251-
// Compact chat headers can open over a bottom-anchored timeline before
252-
// Flutter emits any scroll notification. Keep their title readable at rest.
253-
material.alpha = largeTitle ? min(1, offset / 12) : 1
286+
// A title alone does not need a backdrop. Reveal material only as the
287+
// page scrolls beneath the navigation controls, for every title size.
288+
material.alpha = min(1, offset / 12)
254289
// Use the same ultra-thin material and soft lower edge on every page.
255290
// Compact titles have a member-count line, so begin their fade below it
256291
// rather than washing out the subtitle or ending in a hard rectangle.
@@ -279,6 +314,9 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
279314
button.setAvatar(makeItem(avatar).image,
280315
presence: args["titlePresenceColor"] is NSNumber ? Self.color(args["titlePresenceColor"]) : nil)
281316
}
317+
if args["titleAvatar"] as? [String: Any] == nil, args["titlePresenceColor"] is NSNumber {
318+
button.setSubtitlePresence(Self.color(args["titlePresenceColor"]))
319+
}
282320
if let label = args["ephemeralLabel"] as? String {
283321
button.setEphemeralStatus(label)
284322
}
@@ -338,7 +376,7 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
338376

339377
private func setScrollOffset(_ value: CGFloat) {
340378
offset = max(0, value)
341-
material.alpha = navigation.navigationBar.prefersLargeTitles ? min(1, offset / 12) : 1
379+
material.alpha = min(1, offset / 12)
342380
applyScroll()
343381
}
344382

@@ -376,6 +414,9 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView {
376414
? UIBarButtonItem(primaryAction: action)
377415
: UIBarButtonItem(title: action.title, image: action.image, primaryAction: nil,
378416
menu: UIMenu(children: children.map(makeAction)))
417+
if #available(iOS 26.0, *) {
418+
item.hidesSharedBackground = data["plain"] as? Bool == true
419+
}
379420
item.accessibilityLabel = data["label"] as? String
380421
item.isEnabled = data["enabled"] as? Bool == true
381422
if data["avatarInitial"] is String { item.title = nil }

‎mobile/ios/RunnerTests/RunnerTests.swift‎

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,64 @@ import XCTest
88

99
class RunnerTests: XCTestCase {
1010

11+
@MainActor
12+
func testConversationTitleHasWidthBeforePlatformViewLayout() throws {
13+
let parent = UIViewController()
14+
let factory = IosNavigationBarFactory(messenger: NavigationTestMessenger(), parent: parent)
15+
let bar = factory.create(withFrame: .zero, viewIdentifier: 999991,
16+
arguments: ["title": "Alice, Bob", "subtitle": "3 members", "titleEnabled": true])
17+
let navigation = try XCTUnwrap(parent.children.first as? UINavigationController)
18+
let title = try XCTUnwrap(navigation.topViewController?.navigationItem.titleView)
19+
XCTAssertGreaterThan(title.frame.width, 0)
20+
XCTAssertGreaterThan(title.intrinsicContentSize.width, 0)
21+
XCTAssertLessThanOrEqual(title.intrinsicContentSize.width, 240)
22+
_ = bar.view()
23+
}
24+
25+
@MainActor
26+
func testLongGroupTitleIsCappedAndTruncates() {
27+
let title = NavigationTitleView(title: String(repeating: "Long participant name, ", count: 12), subtitle: "12 members", color: .label)
28+
title.maximumWidth = 180
29+
XCTAssertEqual(title.intrinsicContentSize.width, 180)
30+
title.frame = CGRect(origin: .zero, size: title.intrinsicContentSize)
31+
title.layoutIfNeeded()
32+
for label in title.subviews.compactMap({ $0 as? UILabel }) {
33+
XCTAssertEqual(label.lineBreakMode, .byTruncatingTail)
34+
XCTAssertTrue(title.bounds.contains(label.frame))
35+
}
36+
}
37+
38+
@MainActor
39+
func testPresenceDotSitsBesideCenteredSubtitle() throws {
40+
let title = NavigationTitleView(title: "Alice", subtitle: "Offline", color: .label)
41+
title.setSubtitlePresence(.gray)
42+
title.frame = CGRect(x: 0, y: 0, width: 180, height: 44)
43+
title.layoutIfNeeded()
44+
let dot = try XCTUnwrap(title.subviews.first { $0.accessibilityIdentifier == "dm-navigation-status-dot" })
45+
let label = try XCTUnwrap(title.subviews.compactMap { $0 as? UILabel }.first { $0.text == "Offline" })
46+
XCTAssertEqual(label.frame.minX - dot.frame.maxX, 6, accuracy: 0.1)
47+
XCTAssertEqual(label.frame.midY, dot.frame.midY, accuracy: 0.1)
48+
XCTAssertEqual((dot.frame.minX + label.frame.maxX) / 2, title.bounds.midX, accuracy: 0.1)
49+
}
50+
51+
@MainActor
52+
func testTitleTapIgnoresUIKitControlWrapperButPreservesDisclosure() {
53+
let wrapper = UIControl()
54+
let title = NavigationTitleView(title: "general", subtitle: "36 members", color: .label)
55+
wrapper.addSubview(title)
56+
let label = UILabel()
57+
title.addSubview(label)
58+
XCTAssertTrue(title.acceptsTitleTouch(in: label))
59+
XCTAssertTrue(title.acceptsTitleTouch(in: title))
60+
let disclosure = UIButton(type: .custom)
61+
title.addSubview(disclosure)
62+
XCTAssertFalse(title.acceptsTitleTouch(in: disclosure))
63+
var activated = false
64+
title.onActivate = { activated = true }
65+
XCTAssertTrue(title.accessibilityActivate())
66+
XCTAssertTrue(activated)
67+
}
68+
1169
@MainActor
1270
func testCompactConversationLabelsFitAccessibilityXXXL() async throws {
1371
guard #available(iOS 17.0, *) else { return }
@@ -186,7 +244,7 @@ class RunnerTests: XCTestCase {
186244
}
187245

188246
@MainActor
189-
func testCompactChannelMaterialPersistsAtTimelineBottom() async throws {
247+
func testCompactMaterialOnlyAppearsAfterScrolling() async throws {
190248
let messenger = NavigationTestMessenger()
191249
let parent = UIViewController()
192250
let window = UIWindow(frame: UIScreen.main.bounds)
@@ -202,9 +260,9 @@ class RunnerTests: XCTestCase {
202260
parent.view.addSubview(bar.view())
203261
parent.view.layoutIfNeeded()
204262
let material = try XCTUnwrap(bar.view().subviews.first as? UIVisualEffectView)
205-
// Reversed timelines reach their newest message at zero, then overscroll
206-
// into negative offsets. Neither state should clear the compact material.
207-
for offset in [0.0, 52.0, 12.0, 0.0, -20.0, 0.0] {
263+
// At rest and during top-edge overscroll the bar is clear; positive
264+
// scroll gradually introduces the backdrop.
265+
for offset in [0.0, 6.0, 52.0, 12.0, 0.0, -20.0, 0.0] {
208266
messenger.scroll(to: offset)
209267
bar.view().setNeedsLayout()
210268
bar.view().layoutIfNeeded()
@@ -215,7 +273,7 @@ class RunnerTests: XCTestCase {
215273
XCTAssertEqual(locations.first?.doubleValue, 0)
216274
XCTAssertEqual(locations.last?.doubleValue, 1)
217275
XCTAssertLessThan(locations[1].doubleValue, 1, "Compact material needs a soft lower edge")
218-
XCTAssertEqual(material.alpha, 1, "Channel material cleared at offset \(offset)")
276+
XCTAssertEqual(material.alpha, min(1, max(0, offset) / 12), accuracy: 0.01)
219277
XCTAssertEqual(material.frame, bar.view().bounds)
220278
if #available(iOS 26.0, *) {
221279
let navigation = try XCTUnwrap(parent.children.first as? UINavigationController)

‎mobile/lib/features/channels/channel_actions_sheet.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
77
import 'package:lucide_icons_flutter/lucide_icons.dart';
88

99
import '../../shared/clipboard_utils.dart';
10+
import '../../shared/identity_names/identity_names_provider.dart';
11+
import 'dm_channel_labels.dart';
1012
import '../../shared/mentions/agent_identity_provider.dart';
1113
import '../../shared/theme/theme.dart';
1214
import '../../shared/widgets/app_list.dart';

‎mobile/lib/features/channels/channel_detail_page.dart‎

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,6 @@ class ChannelDetailPage extends HookConsumerWidget {
577577
resolvedChannel.isDm && defaultTargetPlatform == TargetPlatform.iOS
578578
? _watchDmHeader(ref, resolvedChannel, currentPubkey)
579579
: null;
580-
final nativeMembersWorking =
581-
defaultTargetPlatform == TargetPlatform.iOS &&
582-
resolvedChannel.isDm &&
583-
_showsMembersAction(resolvedChannel) &&
584-
ref.watch(workingBotPubkeysProvider(resolvedChannel.id)).isNotEmpty;
585580
final nativeMembers = ref.watch(channelMembersProvider(resolvedChannel.id));
586581
final nativeMemberCount =
587582
nativeMembers.value?.length ?? resolvedChannel.memberCount;
@@ -621,70 +616,24 @@ class ChannelDetailPage extends HookConsumerWidget {
621616
resolvedChannel,
622617
currentPubkey: currentPubkey,
623618
),
624-
nativeSubtitle: resolvedChannel.isDm
619+
nativeSubtitle: isOneToOneDm
625620
? nativeDm?.presenceLabel
626621
: nativeMemberLabel,
627-
nativeTitleAvatar: nativeDm == null
628-
? null
629-
: IosNavigationAction(
630-
label: nativeDm.label,
631-
avatarIdentity: nativeDm.pubkey,
632-
avatarIsAgent: nativeDm.isAgent,
633-
avatarInitial: nativeDm.initial,
634-
imageUrl: nativeDm.avatarUrl,
635-
),
636-
nativeTitlePresenceColor: nativeDm?.presence == null
637-
? null
638-
: switch (nativeDm!.presence) {
639-
'online' => context.appColors.success,
640-
'away' => context.appColors.warning,
641-
_ => context.colors.outline,
642-
},
643-
onNativeTitlePressed: resolvedChannel.isDm ? null : openChannelDetails,
622+
nativeTitlePresenceColor: switch (isOneToOneDm
623+
? nativeDm?.presence
624+
: null) {
625+
'online' => context.appColors.success,
626+
'away' => context.appColors.warning,
627+
'offline' => context.colors.outline,
628+
_ => null,
629+
},
630+
onNativeTitlePressed: openChannelDetails,
644631
nativeActions: [
645632
if (resolvedChannel.isDm ? showsHuddleAction : showsComposer)
646633
_huddleNavigationAction(context, ref, resolvedChannel, [
647634
...messagesState.value ?? const [],
648635
...huddleLifecycle,
649636
]),
650-
if (resolvedChannel.isDm && _showsMembersAction(resolvedChannel))
651-
IosNavigationAction(
652-
label: 'View members',
653-
symbol: 'person.2',
654-
activityColor: nativeMembersWorking
655-
? context.appColors.success
656-
: null,
657-
activityLabel: nativeMembersWorking ? 'Agent working' : null,
658-
onPressed: () => showBuzzModalBottomSheet<void>(
659-
context: context,
660-
title: 'Members',
661-
isScrollControlled: true,
662-
showDragHandle: true,
663-
builder: (_) => MembersSheet(
664-
channel: resolvedChannel,
665-
currentPubkey: currentPubkey,
666-
),
667-
),
668-
),
669-
if (resolvedChannel.isDm)
670-
IosNavigationAction(
671-
label: 'Channel actions',
672-
symbol: 'ellipsis',
673-
onPressed: () async {
674-
final shouldClose = await showChannelActionsSheet(
675-
context: context,
676-
channel: resolvedChannel,
677-
isUnread: false,
678-
sectionId: ref
679-
.read(channelSectionsProvider)
680-
.store
681-
.assignments[resolvedChannel.id],
682-
);
683-
if (shouldClose == true && context.mounted) {
684-
Navigator.of(context).pop();
685-
}
686-
},
687-
),
688637
],
689638
iconColor: context.colors.primary,
690639
titleContentHeight: appBarTitleContentHeight,

0 commit comments

Comments
 (0)