diff --git a/app/lib/features/artifacts/ui/artifact_viewer_content.dart b/app/lib/features/artifacts/ui/artifact_viewer_content.dart index 9dc3e8bd..b7aba945 100644 --- a/app/lib/features/artifacts/ui/artifact_viewer_content.dart +++ b/app/lib/features/artifacts/ui/artifact_viewer_content.dart @@ -219,12 +219,24 @@ class _ZoomableImageState extends State<_ZoomableImage> { PositionedDirectional( top: 8, end: 8, - child: IconButton( - key: const Key('artifact-image-reset-zoom'), - tooltip: 'Reset image zoom', - onPressed: _reset, - icon: const Icon(Icons.zoom_out_map), - ), + child: usesCupertinoHost(context) + ? Tooltip( + message: 'Reset image zoom', + child: CupertinoButton( + key: const Key('artifact-image-reset-zoom'), + sizeStyle: CupertinoButtonSize.small, + onPressed: _reset, + child: const Icon( + CupertinoIcons.arrow_down_right_arrow_up_left, + ), + ), + ) + : IconButton( + key: const Key('artifact-image-reset-zoom'), + tooltip: 'Reset image zoom', + onPressed: _reset, + icon: const Icon(Icons.zoom_out_map), + ), ), ], ); diff --git a/app/test/features/artifacts/ui/artifact_viewer_page_test.dart b/app/test/features/artifacts/ui/artifact_viewer_page_test.dart index c9352d1b..800a9c1b 100644 --- a/app/test/features/artifacts/ui/artifact_viewer_page_test.dart +++ b/app/test/features/artifacts/ui/artifact_viewer_page_test.dart @@ -651,69 +651,83 @@ 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), - ); + for (final cupertino in [false, true]) { + testWidgets( + 'pinch owns image pan and native reset (Cupertino=$cupertino)', + (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, + cupertino: cupertino, + 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(); + 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); + expect( + find.byKey(const Key('artifact-image-reset-zoom')), + findsOneWidget, + ); + expect( + tester.widget(find.byKey(const Key('artifact-image-reset-zoom'))), + cupertino ? isA() : isA(), + ); + // 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.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); + }, ); - 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);