Improve file image gestures
This commit is contained in:
@@ -651,6 +651,70 @@ void main() {
|
||||
expect(find.textContaining('1 of 2'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('pinch owns the image gesture, pans while zoomed, and resets', (
|
||||
tester,
|
||||
) async {
|
||||
final first = recordedArtifact(
|
||||
'a.png',
|
||||
url: '/artifacts/1/1/a.png',
|
||||
contentType: 'image/png',
|
||||
);
|
||||
final second = recordedArtifact(
|
||||
'b.png',
|
||||
url: '/artifacts/1/2/b.png',
|
||||
contentType: 'image/png',
|
||||
);
|
||||
final groups = [
|
||||
_group([first], visit: 1),
|
||||
_group([second], visit: 2),
|
||||
];
|
||||
await _pumpViewer(
|
||||
tester,
|
||||
groups: groups,
|
||||
selected: artifactVisitIdentity(groups[0], first),
|
||||
);
|
||||
|
||||
final viewport = tester.getRect(
|
||||
find.byKey(const Key('artifact-image-zoom')),
|
||||
);
|
||||
final center = viewport.center;
|
||||
final one = await tester.startGesture(
|
||||
center + const Offset(-30, 0),
|
||||
pointer: 1,
|
||||
);
|
||||
final two = await tester.startGesture(
|
||||
center + const Offset(30, 0),
|
||||
pointer: 2,
|
||||
);
|
||||
await one.moveTo(center + const Offset(-110, 0));
|
||||
await two.moveTo(center + const Offset(110, 0));
|
||||
await tester.pump();
|
||||
await one.up();
|
||||
await two.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsOneWidget);
|
||||
// A one-finger drag now belongs to the zoomed image, not the gallery.
|
||||
await tester.fling(
|
||||
find.byKey(const Key('artifact-image-zoom')),
|
||||
const Offset(-300, 0),
|
||||
1000,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('1 of 2'), findsWidgets);
|
||||
|
||||
await tester.tap(find.byKey(const Key('artifact-image-reset-zoom')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsNothing);
|
||||
await tester.fling(
|
||||
find.byKey(const Key('artifact-viewer-swipe')),
|
||||
const Offset(-300, 0),
|
||||
1000,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('2 of 2'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('Material paging stays inside 320px at 2x text', (tester) async {
|
||||
tester.view.physicalSize = const Size(640, 1200);
|
||||
tester.view.devicePixelRatio = 2;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user