Improve file image gestures

This commit is contained in:
2026-11-07 22:01:10 +00:00
parent 6e4e11aca2
commit 5917827bc5
6 changed files with 175 additions and 13 deletions
@@ -115,6 +115,48 @@ void main() {
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.byType(Image), findsWidgets);
});
testWidgets('image opened from Files owns pinch and pan until reset', (
tester,
) async {
await pump(
tester,
viewer: FilesViewer(
fetch: (_) async => ArtifactFetchResult(
status: 200,
bytes: base64Decode(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==',
),
),
),
);
await tester.tap(find.text('picture.png'));
await tester.pumpAndSettle();
final viewport = tester.getRect(
find.byKey(const Key('artifact-image-zoom')),
);
final center = viewport.center;
final one = await tester.startGesture(
center + const Offset(-24, 0),
pointer: 1,
);
final two = await tester.startGesture(
center + const Offset(24, 0),
pointer: 2,
);
await one.moveTo(center + const Offset(-96, 0));
await two.moveTo(center + const Offset(96, 0));
await tester.pump();
await one.up();
await two.up();
await tester.pumpAndSettle();
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsOneWidget);
await tester.tap(find.byKey(const Key('artifact-image-reset-zoom')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsNothing);
});
testWidgets('unknown file has metadata and a working download', (
tester,
) async {