mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
## Summary Replace bubble photo carousels with swipeable, overlapping photo stacks, with distinct sent/received layouts and a stationary photo count. Opening and closing the gallery preserves the selected photo. Photo frames follow the active theme. Add an opt-in iOS 18+ native zoom gallery (`BUZZ_NATIVE_PHOTO_ZOOM=true`) with paging, continuous dot scrubbing, preview-backed loading, Reply/More actions, and Liquid Glass controls on iOS 26+. The existing gallery remains the fallback. UIKit’s late corner settling and brief return-transition input lockout remain known preview limitations. ### Related issue None found. ### Testing Validation: full mobile pre-push checks/tests passed on `2b5bac3075`; light/dark sent/received widget renders verified. Earlier native simulator checks covered paging, scrubbing, downward close, and Reply. Snapshots below are actual Flutter widget renders with sample photos (not device screenshots). | Before: carousel | After: sent | After: received | | --- | --- | --- | |  |  |  | | Dark mode: sent | Dark mode: received | | --- | --- | |  |  | --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
79 lines
2.3 KiB
Dart
79 lines
2.3 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
|
|
import 'message_media.dart';
|
|
import 'message_content/link_normalizer.dart';
|
|
import 'message_content/markdown_escapes.dart';
|
|
|
|
/// Image metadata shared by carousel rendering and loading projection.
|
|
@immutable
|
|
class MessageGalleryItem {
|
|
final String url;
|
|
final String semanticLabel;
|
|
final double? aspectRatio;
|
|
|
|
/// Declared media type, used to keep potentially animated images in Flutter.
|
|
final String? mimeType;
|
|
|
|
const MessageGalleryItem({
|
|
required this.url,
|
|
required this.semanticLabel,
|
|
required this.aspectRatio,
|
|
this.mimeType,
|
|
});
|
|
}
|
|
|
|
/// A trailing run of image embeds and its preceding message text.
|
|
@immutable
|
|
class TrailingImageGallery {
|
|
final String content;
|
|
final List<MessageGalleryItem> items;
|
|
|
|
const TrailingImageGallery({required this.content, required this.items});
|
|
}
|
|
|
|
/// Groups trailing image lines using the production carousel policy.
|
|
TrailingImageGallery? extractTrailingImageGallery(
|
|
String content,
|
|
Map<String, ImetaEntry> imetaByUrl,
|
|
) {
|
|
final lines = content.split('\n');
|
|
var cursor = lines.length - 1;
|
|
while (cursor >= 0 && lines[cursor].trim().isEmpty) {
|
|
cursor -= 1;
|
|
}
|
|
|
|
final items = <MessageGalleryItem>[];
|
|
final imagePattern = RegExp(r'^!\[([^\]]*)\]\((https?://[^)\s]+)\)$');
|
|
while (cursor >= 0) {
|
|
final match = imagePattern.firstMatch(lines[cursor].trim());
|
|
if (match == null) break;
|
|
// CommonMark unescapes link destinations, as it does labels below.
|
|
final url = unshieldMarkdownEscapes(shieldMarkdownEscapes(match.group(2)!));
|
|
final imeta = imetaByUrl[url];
|
|
final mediaKind = classifyMediaUrl(url, imeta: imeta);
|
|
if (mediaKind != MessageMediaKind.image) {
|
|
break;
|
|
}
|
|
final markdownLabel = decodeMarkdownLabelSyntax(
|
|
unshieldMarkdownEscapes(shieldMarkdownEscapes(match.group(1)!)),
|
|
).trim();
|
|
items.add(
|
|
MessageGalleryItem(
|
|
url: url,
|
|
semanticLabel:
|
|
imeta?.alt ??
|
|
(markdownLabel.isNotEmpty ? markdownLabel : 'Message image'),
|
|
aspectRatio: imeta?.aspectRatio,
|
|
mimeType: imeta?.mimeType,
|
|
),
|
|
);
|
|
cursor -= 1;
|
|
}
|
|
|
|
if (items.length < 2) return null;
|
|
return TrailingImageGallery(
|
|
content: lines.take(cursor + 1).join('\n').trimRight(),
|
|
items: items.reversed.toList(),
|
|
);
|
|
}
|