mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
Mobile mentions now use the desktop chip treatment: neutral rounded pills for other identities, the chat accent for mentions of the viewer, and a contrasting inset fill inside outgoing messages. This applies to message bodies and compact previews, while preserving profile taps and resolving self-highlights by public key. The change reuses the existing chat palette and keeps it stable across parent rebuilds, so unchanged messages retain their parsed Markdown. Mention routing and composer behavior are unchanged. Validation: `just mobile-check mobile-test` passed (5,118 Flutter tests, 71 skipped, plus 27 crypto-package tests). Coverage includes light/dark themes, 2× text, profile taps, live identity switching, outgoing contrast, and Markdown reuse; removing self-highlighting makes the regression fail. A signed iOS build was installed and checked on a physical device, then approved for PR preparation. ### Snapshots Actual Flutter component renders with synthetic identities and the bundled app font. Each shows received/own messages, compact previews, and enlarged text. | Light | Dark | | --- | --- | |  |  | buzz-review-completed Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
149 lines
5.0 KiB
Dart
149 lines
5.0 KiB
Dart
part of '../message_content.dart';
|
|
|
|
List<InlinePattern> _useMessageInlinePatterns({
|
|
required bool ownBubble,
|
|
required String content,
|
|
required String finalContent,
|
|
required Map<String, String> mentionNames,
|
|
required Map<String, String> mentionLabels,
|
|
required Map<String, Set<String>> bindings,
|
|
required Set<String> agentPubkeys,
|
|
required Map<String, String> channelNames,
|
|
required List<CustomEmoji> customEmoji,
|
|
required double emojiSize,
|
|
required List<List<String>> tags,
|
|
required bool hasMediaReply,
|
|
required bool hasMediaMore,
|
|
required void Function(String)? onMentionTap,
|
|
required void Function(String) onChannelTap,
|
|
}) {
|
|
// Parsed spans retain these callbacks. Forward to the current handlers without
|
|
// invalidating the parser for a new closure from an otherwise unchanged row.
|
|
final mentionHandler = useRef(onMentionTap)..value = onMentionTap;
|
|
final channelHandler = useRef(onChannelTap)..value = onChannelTap;
|
|
final mentionTap = useMemoized(
|
|
() =>
|
|
(String pubkey) => mentionHandler.value?.call(pubkey),
|
|
const [],
|
|
);
|
|
final channelTap = useMemoized(
|
|
() =>
|
|
(String channelId) => channelHandler.value(channelId),
|
|
const [],
|
|
);
|
|
final inputs = _InlineComponentInputs(
|
|
content: content,
|
|
finalContent: finalContent,
|
|
mentionNames: mentionNames,
|
|
mentionLabels: mentionLabels,
|
|
bindings: bindings,
|
|
agentPubkeys: agentPubkeys,
|
|
channelNames: channelNames,
|
|
customEmoji: customEmoji,
|
|
emojiSize: emojiSize,
|
|
tags: tags,
|
|
hasMediaReply: hasMediaReply,
|
|
hasMediaMore: hasMediaMore,
|
|
hasMentionHandler: onMentionTap != null,
|
|
);
|
|
|
|
// gpt_markdown compares patterns by identity. Recreating them on every
|
|
// parent rebuild reparses unchanged message bodies on the UI isolate.
|
|
return useMemoized(
|
|
() => [
|
|
_MentionMd(
|
|
ownBubble: ownBubble,
|
|
mentionNames: inputs.mentionNames,
|
|
mentionLabels: inputs.mentionLabels,
|
|
bindings: inputs.bindings,
|
|
displayLabels: {
|
|
for (final range in mentionOccurrences(content, bindings.keys))
|
|
range.label: content.substring(range.start + 1, range.end),
|
|
},
|
|
agentMentionPubkeys: inputs.agentPubkeys,
|
|
onMentionTap: inputs.hasMentionHandler ? mentionTap : null,
|
|
).pattern,
|
|
CustomEmojiMd(
|
|
inputs.customEmoji,
|
|
content: finalContent,
|
|
size: emojiSize,
|
|
).pattern,
|
|
_ChannelLinkMd(
|
|
channelNames: inputs.channelNames,
|
|
onChannelTap: channelTap,
|
|
).pattern,
|
|
],
|
|
[inputs, ownBubble],
|
|
);
|
|
}
|
|
|
|
class _InlineComponentInputs {
|
|
final String content;
|
|
final String finalContent;
|
|
final Map<String, String> mentionNames;
|
|
final Map<String, String> mentionLabels;
|
|
final Map<String, Set<String>> bindings;
|
|
final Set<String> agentPubkeys;
|
|
final Map<String, String> channelNames;
|
|
final List<CustomEmoji> customEmoji;
|
|
final double emojiSize;
|
|
final bool hasMentionHandler;
|
|
final List<List<String>> tags;
|
|
final bool hasMediaReply;
|
|
final bool hasMediaMore;
|
|
|
|
_InlineComponentInputs({
|
|
required this.content,
|
|
required this.finalContent,
|
|
required Map<String, String> mentionNames,
|
|
required Map<String, String> mentionLabels,
|
|
required Map<String, Set<String>> bindings,
|
|
required Set<String> agentPubkeys,
|
|
required Map<String, String> channelNames,
|
|
required List<CustomEmoji> customEmoji,
|
|
required this.emojiSize,
|
|
required this.hasMentionHandler,
|
|
required List<List<String>> tags,
|
|
required this.hasMediaReply,
|
|
required this.hasMediaMore,
|
|
}) : tags = List.unmodifiable(
|
|
tags.map((tag) => List<String>.unmodifiable(tag)),
|
|
),
|
|
mentionNames = Map.unmodifiable(mentionNames),
|
|
mentionLabels = Map.unmodifiable(mentionLabels),
|
|
bindings = Map.unmodifiable({
|
|
for (final entry in bindings.entries)
|
|
entry.key: Set<String>.unmodifiable(entry.value),
|
|
}),
|
|
agentPubkeys = Set.unmodifiable(agentPubkeys),
|
|
channelNames = Map.unmodifiable(channelNames),
|
|
customEmoji = List.unmodifiable(customEmoji);
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
other is _InlineComponentInputs &&
|
|
content == other.content &&
|
|
finalContent == other.finalContent &&
|
|
emojiSize == other.emojiSize &&
|
|
hasMentionHandler == other.hasMentionHandler &&
|
|
hasMediaReply == other.hasMediaReply &&
|
|
hasMediaMore == other.hasMediaMore &&
|
|
tags.length == other.tags.length &&
|
|
tags.indexed.every(
|
|
(entry) => listEquals(entry.$2, other.tags[entry.$1]),
|
|
) &&
|
|
mapEquals(mentionNames, other.mentionNames) &&
|
|
mapEquals(mentionLabels, other.mentionLabels) &&
|
|
mapEquals(channelNames, other.channelNames) &&
|
|
setEquals(agentPubkeys, other.agentPubkeys) &&
|
|
listEquals(customEmoji, other.customEmoji) &&
|
|
bindings.length == other.bindings.length &&
|
|
bindings.entries.every(
|
|
(entry) => setEquals(entry.value, other.bindings[entry.key]),
|
|
);
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(content, finalContent, emojiSize, hasMentionHandler);
|
|
}
|