Files
buzz/mobile/lib/features/channels/message_content/bubble_segments.dart
klopez4212 231a469de5 Refresh mobile message bubbles, reactions, and activity cards (#8281)
## Summary

Refresh mobile conversations with left-aligned grouped bubbles without
tails, tighter consecutive-message spacing, distinct sender colors,
theme-aware incoming backgrounds, and compact overlapping reaction
trays. Attach reply counts beside reactions with up to three participant
avatars; keep outgoing mentions and links readable in both themes.
Coordinate a 500 ms composer-to-message transition with spring
contraction and an anchored avatar. Message ownership follows the
signing identity so profile reloads cannot recolor outgoing bubbles.

Center channel activities without timestamps or icons, keep names
tappable, and show two affected members plus a **See all** sheet. Hide
legacy purpose activities, match media corners to bubble groups, and add
iOS status-bar scroll-to-top. This is an independent mobile PR; no
desktop changes or color picker.

## Validation

- Full `just mobile-check` passed; `just mobile-test` passed 3,275 tests
with 4 skips, plus 3 unconfigured-gateway checks.
- Fixed message-widget lint warnings and a stale notification fixture
that blocked analysis. Made the video-controller disposal test wait for
lifecycle events instead of fixed delays. Mobile pre-push checks are
enabled.
- Physical iPhone previews were installed throughout development. The
latest bubble, reply-avatar, contrast, and spacing updates were
installed and launched on the physical iPhone. Final motion and
status-bar behavior still need device visual verification; Android has
automated coverage but no physical-device verification.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
2026-10-14 16:35:26 -04:00

59 lines
1.9 KiB
Dart

import '../message_media.dart';
/// Splits top-level media from text without breaking Markdown blocks.
/// Fenced code, lists and quotes retain their nested content.
List<({String text, bool attachment})> messageBubbleSegments(
String content,
Map<String, ImetaEntry> imeta,
) {
final result = <({String text, bool attachment})>[];
final lines = <String>[];
bool? attachment;
String? fence;
var nestedBlock = false;
final embed = RegExp(r'^!?\[[^\]]*\]\((https?://[^)\s]+)\)$');
void flush() {
final text = lines.join('\n').trimRight();
if (text.trim().isNotEmpty) {
result.add((text: text, attachment: attachment ?? false));
}
lines.clear();
}
for (final line in content.split('\n')) {
final trimmed = line.trimLeft();
final marker = RegExp(r'^(`{3,}|~{3,})').firstMatch(trimmed)?.group(1);
final inFence = fence != null || marker != null || line.startsWith(' ');
if (marker != null) {
if (fence == null) {
fence = marker;
} else if (marker[0] == fence[0] && marker.length >= fence.length) {
fence = null;
}
}
if (trimmed.isEmpty) {
nestedBlock = false;
} else if (RegExp(r'^(?:>|[-+*]\s|\d+[.)]\s)').hasMatch(trimmed)) {
nestedBlock = true;
}
// Indented embeds belong to a list, quote or code block. Lazy block
// continuations also stay together until a blank line ends the block.
final topLevel = line == trimmed && !nestedBlock;
final match = inFence || !topLevel
? null
: embed.firstMatch(line.trimRight());
final isAttachment =
match != null &&
(line.trim().startsWith('!') || imeta.containsKey(match.group(1)));
if (attachment != null &&
isAttachment != attachment &&
line.trim().isNotEmpty) {
flush();
}
if (line.trim().isNotEmpty) attachment = isAttachment;
lines.add(line);
}
flush();
return result;
}