fbe1928f59
Keep the existing Material transcript path while preserving public Cupertino parameters for callers. Narrow transcript tests to the Material-only behavior and remove Cupertino-only fixtures.
78 lines
2.2 KiB
Dart
78 lines
2.2 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,
|
|
required this.cupertino,
|
|
});
|
|
|
|
final String name;
|
|
final Uint8List bytes;
|
|
final bool cupertino;
|
|
|
|
@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(
|
|
cupertino: false,
|
|
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,
|
|
required bool cupertino,
|
|
}) {
|
|
final page = ChatImageViewer(name: name, bytes: bytes, cupertino: cupertino);
|
|
return Navigator.of(
|
|
context,
|
|
).push(MaterialPageRoute<void>(fullscreenDialog: true, builder: (_) => page));
|
|
}
|