Files
alan 9551eceaed Complete Material-only APIs and fixtures
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.
2026-11-11 21:55:39 +00:00

70 lines
2.0 KiB
Dart

import '../../../../ui/adaptive/segmented_bar.dart';
import 'dart:typed_data';
import 'package:flutter/material.dart';
/// The accessible name and visible label of the viewer's close control.
const String chatImageViewerClose = 'Close';
/// One attached image full screen: pinch or scroll to zoom, drag to pan once
/// zoomed, and the host's own close control in the navigation bar.
class ChatImageViewer extends StatelessWidget {
const ChatImageViewer({super.key, required this.name, required this.bytes});
final String name;
final Uint8List bytes;
@override
Widget build(BuildContext context) {
final body = InteractiveViewer(
key: const Key('chat-image-viewer-zoom'),
maxScale: 8,
child: Center(
child: Semantics(
image: true,
label: name,
child: Image.memory(
bytes,
key: const Key('chat-image-viewer-image'),
fit: BoxFit.contain,
gaplessPlayback: true,
errorBuilder: (context, _, _) =>
const Icon(Icons.broken_image_outlined),
),
),
),
);
void close() => Navigator.of(context).maybePop();
return Scaffold(
extendBodyBehindAppBar: true,
backgroundColor: Colors.black,
appBar: SegmentedBar(
automaticallyImplyLeading: false,
leading: IconButton(
key: const Key('chat-image-viewer-close'),
tooltip: chatImageViewerClose,
onPressed: close,
icon: const Icon(Icons.close),
),
title: name,
backgroundColor: Colors.black,
pillColor: Colors.white24,
foregroundColor: Colors.white,
),
body: body,
);
}
}
/// Pushes [ChatImageViewer] with the host's full-screen dialog transition.
Future<void> openChatImageViewer(
BuildContext context, {
required String name,
required Uint8List bytes,
}) {
final page = ChatImageViewer(name: name, bytes: bytes);
return Navigator.of(
context,
).push(MaterialPageRoute<void>(fullscreenDialog: true, builder: (_) => page));
}