9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
55 lines
1.9 KiB
Dart
55 lines
1.9 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
import '../../../../core/api_gateway.dart';
|
|
import '../../data/chat_attachment_images.dart';
|
|
import '../../domain/chat_attachment_image.dart';
|
|
import 'chat_attachment_thumbnail.dart';
|
|
|
|
/// Whether a file part draws as a thumbnail: a raster image whose bytes the
|
|
/// client can reach (inline, the server's attachment store or a fresh upload).
|
|
bool chatPartIsThumbnail(JsonMap part) =>
|
|
chatPartImageMime(part) != null &&
|
|
chatImageSourceOf('${part['uri'] ?? ''}'.trim()) != null;
|
|
|
|
/// The operator's attached images above their message, end-aligned like the
|
|
/// turn itself, wrapping onto further lines on a narrow pane.
|
|
class ChatAttachmentGallery extends StatelessWidget {
|
|
const ChatAttachmentGallery({
|
|
super.key,
|
|
required this.parts,
|
|
required this.images,
|
|
});
|
|
|
|
/// File parts for which [chatPartIsThumbnail] holds.
|
|
final List<JsonMap> parts;
|
|
final ChatAttachmentImages images;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Wrap(
|
|
key: const Key('chat-attachment-gallery'),
|
|
alignment: WrapAlignment.end,
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: [
|
|
for (final (index, part) in parts.indexed)
|
|
ChatAttachmentThumbnail(
|
|
key: ValueKey<String>('chat-attachment-image-$index'),
|
|
name: chatAttachmentPartName(part),
|
|
uri: '${part['uri'] ?? ''}'.trim(),
|
|
images: images,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// The web's attachment name rule: its own name, else the URI basename, else
|
|
/// `file`. A `data:` URI has no useful basename, so it reads `image`.
|
|
String chatAttachmentPartName(JsonMap part) {
|
|
final name = '${part['name'] ?? ''}'.trim();
|
|
if (name.isNotEmpty) return name;
|
|
final uri = '${part['uri'] ?? ''}'.trim();
|
|
if (uri.startsWith('data:')) return 'image';
|
|
final basename = uri.split('/').last.trim();
|
|
return basename.isEmpty ? 'file' : basename;
|
|
}
|