diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml
index dce5eb9a..53f7c6c9 100644
--- a/app/android/app/src/main/AndroidManifest.xml
+++ b/app/android/app/src/main/AndroidManifest.xml
@@ -56,5 +56,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/lib/features/artifacts/actions/artifact_file_actions.dart b/app/lib/features/artifacts/actions/artifact_file_actions.dart
index 39fa72b7..1000980a 100644
--- a/app/lib/features/artifacts/actions/artifact_file_actions.dart
+++ b/app/lib/features/artifacts/actions/artifact_file_actions.dart
@@ -23,8 +23,12 @@ class ArtifactFileActions extends StatefulWidget {
required this.resolved,
this.fetch = fetchArtifact,
this.bridge = const ArtifactFileBridge(),
+ this.compact = false,
});
+ /// Icon buttons only (a viewer's bottom bar): no labels and no notices.
+ final bool compact;
+
final ArtifactRecord artifact;
final ResolvedArtifactUrl resolved;
final ArtifactFetch fetch;
@@ -74,10 +78,12 @@ class _ArtifactFileActionsState extends State {
Widget build(BuildContext context) {
return ListenableBuilder(
listenable: _controller,
- builder: (context, _) => _ActionBar(
- controller: _controller,
- cupertino: usesCupertinoHost(context),
- ),
+ builder: (context, _) => widget.compact
+ ? _IconActions(controller: _controller)
+ : _ActionBar(
+ controller: _controller,
+ cupertino: usesCupertinoHost(context),
+ ),
);
}
}
@@ -185,3 +191,85 @@ class _ActionBar extends StatelessWidget {
);
}
}
+
+/// Download and Share as icon buttons; a spinner stands in for the one in
+/// progress. A host that cannot download or share simply has no button.
+class _IconActions extends StatelessWidget {
+ const _IconActions({required this.controller});
+
+ final ArtifactFileActionsController controller;
+
+ @override
+ Widget build(BuildContext context) {
+ final busy = controller.busy;
+ return Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (controller.canDownload)
+ ArtifactIconAction(
+ key: const Key('artifact-download'),
+ label: 'Download',
+ icon: Icons.download_outlined,
+ cupertinoIcon: CupertinoIcons.arrow_down_to_line,
+ busy: busy,
+ onPressed: busy ? null : controller.download,
+ ),
+ if (controller.canShare)
+ ArtifactIconAction(
+ key: const Key('artifact-share'),
+ label: 'Share',
+ icon: Icons.share_outlined,
+ cupertinoIcon: CupertinoIcons.share,
+ onPressed: busy ? null : controller.share,
+ ),
+ ],
+ );
+ }
+}
+
+/// One icon-only viewer action with its name as tooltip and accessible label.
+class ArtifactIconAction extends StatelessWidget {
+ const ArtifactIconAction({
+ super.key,
+ required this.label,
+ required this.icon,
+ required this.cupertinoIcon,
+ required this.onPressed,
+ this.busy = false,
+ });
+
+ final String label;
+ final IconData icon;
+ final IconData cupertinoIcon;
+ final VoidCallback? onPressed;
+ final bool busy;
+
+ @override
+ Widget build(BuildContext context) {
+ if (usesCupertinoHost(context)) {
+ return Semantics(
+ button: true,
+ label: label,
+ child: CupertinoButton(
+ padding: const EdgeInsets.all(8),
+ onPressed: onPressed,
+ child: busy
+ ? const CupertinoActivityIndicator(radius: 9)
+ : Icon(cupertinoIcon),
+ ),
+ );
+ }
+ return IconButton(
+ tooltip: label,
+ visualDensity: VisualDensity.compact,
+ onPressed: onPressed,
+ icon: busy
+ ? const SizedBox(
+ width: 18,
+ height: 18,
+ child: CircularProgressIndicator(strokeWidth: 2),
+ )
+ : Icon(icon),
+ );
+ }
+}
diff --git a/app/lib/features/artifacts/actions/artifact_transfer.dart b/app/lib/features/artifacts/actions/artifact_transfer.dart
index bc99bbf3..f27d65c1 100644
--- a/app/lib/features/artifacts/actions/artifact_transfer.dart
+++ b/app/lib/features/artifacts/actions/artifact_transfer.dart
@@ -1,6 +1,7 @@
import 'artifact_file.dart';
import 'artifact_transfer_stub.dart'
if (dart.library.js_interop) 'artifact_transfer_web.dart'
+ if (dart.library.io) 'artifact_transfer_io.dart'
as impl;
/// The outcome of a host file transfer.
diff --git a/app/lib/features/artifacts/actions/artifact_transfer_io.dart b/app/lib/features/artifacts/actions/artifact_transfer_io.dart
new file mode 100644
index 00000000..5fb3ccb9
--- /dev/null
+++ b/app/lib/features/artifacts/actions/artifact_transfer_io.dart
@@ -0,0 +1,56 @@
+import 'package:file_picker/file_picker.dart';
+import 'package:share_plus/share_plus.dart';
+
+import 'artifact_file.dart';
+import 'artifact_transfer.dart';
+
+/// Phones and desktops: Download asks where to save the exact bytes (the
+/// system "Save as"), Share hands the named file to the share sheet.
+bool get artifactDownloadSupported => true;
+
+bool get artifactShareSupported => true;
+
+String get artifactDownloadUnsupportedMessage => '';
+
+String get artifactShareUnsupportedMessage => '';
+
+Future saveArtifactFile(ArtifactFile file) async {
+ try {
+ final saved = await FilePicker.saveFile(
+ fileName: file.name,
+ bytes: file.bytes,
+ mimeType: file.mimeType,
+ );
+ if (saved == null) {
+ return const ArtifactTransferResult(ArtifactTransferState.canceled, '');
+ }
+ return ArtifactTransferResult(
+ ArtifactTransferState.saved,
+ 'Saved ${file.name}.',
+ );
+ } catch (error) {
+ return ArtifactTransferResult(
+ ArtifactTransferState.failed,
+ 'Could not save ${file.name}: $error',
+ );
+ }
+}
+
+Future shareArtifactFile(ArtifactFile file) async {
+ try {
+ final result = await SharePlus.instance.share(
+ ShareParams(
+ files: [XFile.fromData(file.bytes, mimeType: file.mimeType)],
+ fileNameOverrides: [file.name],
+ ),
+ );
+ return result.status == ShareResultStatus.dismissed
+ ? const ArtifactTransferResult(ArtifactTransferState.canceled, '')
+ : const ArtifactTransferResult(ArtifactTransferState.shared, '');
+ } catch (error) {
+ return ArtifactTransferResult(
+ ArtifactTransferState.failed,
+ 'Could not share ${file.name}: $error',
+ );
+ }
+}
diff --git a/app/lib/features/artifacts/ui/artifact_external_open.dart b/app/lib/features/artifacts/ui/artifact_external_open.dart
index 15ae4180..4a4a4f81 100644
--- a/app/lib/features/artifacts/ui/artifact_external_open.dart
+++ b/app/lib/features/artifacts/ui/artifact_external_open.dart
@@ -1,6 +1,7 @@
import '../domain/artifact_url.dart';
import 'artifact_external_open_stub.dart'
if (dart.library.js_interop) 'artifact_external_open_web.dart'
+ if (dart.library.io) 'artifact_external_open_io.dart'
as impl;
/// Opens an already validated artifact url with the host's external handler.
diff --git a/app/lib/features/artifacts/ui/artifact_external_open_io.dart b/app/lib/features/artifacts/ui/artifact_external_open_io.dart
new file mode 100644
index 00000000..88a8a0d3
--- /dev/null
+++ b/app/lib/features/artifacts/ui/artifact_external_open_io.dart
@@ -0,0 +1,11 @@
+import 'package:url_launcher/url_launcher.dart';
+
+/// Phones and desktops: the link opens in the system browser, which renders
+/// what it can and offers to download the rest.
+Future openArtifactExternally(Uri uri) async {
+ try {
+ return await launchUrl(uri, mode: LaunchMode.externalApplication);
+ } catch (_) {
+ return false;
+ }
+}
diff --git a/app/lib/features/artifacts/ui/artifact_viewer_body.dart b/app/lib/features/artifacts/ui/artifact_viewer_body.dart
index f2fc1922..3772f4cb 100644
--- a/app/lib/features/artifacts/ui/artifact_viewer_body.dart
+++ b/app/lib/features/artifacts/ui/artifact_viewer_body.dart
@@ -62,27 +62,10 @@ class ArtifactViewerBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
final resolved = plan.resolved;
- final controls = [
- if (resolved != null && !resolved.external)
- ArtifactFileActions(
- key: ValueKey(
- 'viewer-files-${page.group.stageKey}\u0000'
- '${page.group.visit}\u0000${page.artifact.url}',
- ),
- artifact: page.artifact,
- resolved: resolved,
- fetch: fetch,
- bridge: fileBridge,
- ),
- if (resolved != null)
- _Actions(resolved: resolved, onOpen: onOpen, onCopy: onCopy),
- ];
final content = SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- // Room for the controls bar, so it never covers the first line.
- if (controls.isNotEmpty) const SizedBox(height: 56),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
child: ArtifactSelectionFacts(
@@ -102,11 +85,6 @@ class ArtifactViewerBody extends StatelessWidget {
),
),
),
- if (status != null)
- Padding(
- padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 4),
- child: Semantics(liveRegion: true, child: Text(status!)),
- ),
ArtifactPreviewBody(
plan: plan,
loading: loading,
@@ -118,23 +96,60 @@ class ArtifactViewerBody extends StatelessWidget {
],
),
);
+ final hasPrevious = pagedIndex(index, -1, count) != index;
+ final hasNext = pagedIndex(index, 1, count) != index;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
- child: controls.isEmpty
- ? content
- : ArtifactControlsOverlay(
- key: ValueKey('viewer-overlay-${page.artifact.url}'),
- controls: controls,
- child: content,
- ),
+ // A horizontal swipe moves to the previous or next artifact.
+ child: GestureDetector(
+ key: const Key('artifact-viewer-swipe'),
+ behavior: HitTestBehavior.translucent,
+ onHorizontalDragEnd: (details) {
+ final velocity = details.primaryVelocity ?? 0;
+ if (velocity < -250 && hasNext) onNext();
+ if (velocity > 250 && hasPrevious) onPrevious();
+ },
+ child: content,
+ ),
),
- _Pager(
- index: index,
- count: count,
- onPrevious: onPrevious,
- onNext: onNext,
+ // Every action as an icon at the bottom, beside the pager.
+ SafeArea(
+ top: false,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 4),
+ child: Row(
+ key: const Key('artifact-viewer-actions'),
+ children: [
+ if (resolved != null && !resolved.external)
+ ArtifactFileActions(
+ key: ValueKey(
+ 'viewer-files-${page.group.stageKey}\u0000'
+ '${page.group.visit}\u0000${page.artifact.url}',
+ ),
+ artifact: page.artifact,
+ resolved: resolved,
+ fetch: fetch,
+ bridge: fileBridge,
+ compact: true,
+ ),
+ if (resolved != null)
+ _Actions(resolved: resolved, onOpen: onOpen, onCopy: onCopy),
+ Expanded(
+ child: Align(
+ alignment: AlignmentDirectional.centerEnd,
+ child: _Pager(
+ index: index,
+ count: count,
+ onPrevious: onPrevious,
+ onNext: onNext,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
),
],
);
@@ -263,40 +278,25 @@ class _Actions extends StatelessWidget {
final VoidCallback onCopy;
@override
- Widget build(BuildContext context) {
- if (usesCupertinoHost(context)) {
- return SafeArea(
- top: false,
- child: Wrap(
- alignment: WrapAlignment.center,
- spacing: 8,
- children: [
- CupertinoButton(onPressed: onOpen, child: const Text('Open')),
- CupertinoButton(onPressed: onCopy, child: const Text('Copy link')),
- ],
- ),
- );
- }
- return SafeArea(
- top: false,
- child: Wrap(
- alignment: WrapAlignment.center,
- spacing: 8,
- children: [
- TextButton.icon(
- onPressed: onOpen,
- icon: const Icon(Icons.open_in_new),
- label: const Text('Open'),
- ),
- TextButton.icon(
- onPressed: onCopy,
- icon: const Icon(Icons.content_copy),
- label: const Text('Copy link'),
- ),
- ],
+ Widget build(BuildContext context) => Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ ArtifactIconAction(
+ key: const Key('artifact-open'),
+ label: 'Open',
+ icon: Icons.open_in_new,
+ cupertinoIcon: CupertinoIcons.arrow_up_right_square,
+ onPressed: onOpen,
),
- );
- }
+ ArtifactIconAction(
+ key: const Key('artifact-copy-link'),
+ label: 'Copy link',
+ icon: Icons.link,
+ cupertinoIcon: CupertinoIcons.link,
+ onPressed: onCopy,
+ ),
+ ],
+ );
}
const artifactPreviousKey = ValueKey('artifact-previous');
@@ -320,18 +320,15 @@ class _Pager extends StatelessWidget {
if (count <= 1) return const SizedBox.shrink();
final hasPrevious = pagedIndex(index, -1, count) != index;
final hasNext = pagedIndex(index, 1, count) != index;
- return SafeArea(
- top: false,
- child: ChevronPager(
- index: index,
- count: count,
- previousLabel: 'Previous artifact',
- nextLabel: 'Next artifact',
- previousKey: artifactPreviousKey,
- nextKey: artifactNextKey,
- onPrevious: hasPrevious ? onPrevious : null,
- onNext: hasNext ? onNext : null,
- ),
+ return ChevronPager(
+ index: index,
+ count: count,
+ previousLabel: 'Previous artifact',
+ nextLabel: 'Next artifact',
+ previousKey: artifactPreviousKey,
+ nextKey: artifactNextKey,
+ onPrevious: hasPrevious ? onPrevious : null,
+ onNext: hasNext ? onNext : null,
);
}
}
diff --git a/app/pubspec.lock b/app/pubspec.lock
index 9d7f55c5..ed2a34ae 100644
--- a/app/pubspec.lock
+++ b/app/pubspec.lock
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
+ android_file_picker:
+ dependency: transitive
+ description:
+ name: android_file_picker
+ sha256: e94229cc41c4bb5fb6a2254146340a8b650664c99b5c93b9001f66c3375d0060
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.1"
args:
dependency: transitive
description:
@@ -57,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
+ cross_file:
+ dependency: transitive
+ description:
+ name: cross_file
+ sha256: f141ea4f277af142a0356955707f6556f37b03947d39d55585981a06ca437bd6
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.3.5+5"
crypto:
dependency: transitive
description:
@@ -121,6 +137,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.1"
+ file_picker:
+ dependency: "direct main"
+ description:
+ name: file_picker
+ sha256: "98c0b156b6380ba55bc767a14e2e6b3feb246e713ad40092424596fa79005bea"
+ url: "https://pub.dev"
+ source: hosted
+ version: "13.1.0"
+ file_picker_darwin:
+ dependency: transitive
+ description:
+ name: file_picker_darwin
+ sha256: ca2918264c453400c80ef0d69ca3f8b816f894db6144bebac73064ad64927e0e
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.3.3"
+ file_picker_linux:
+ dependency: transitive
+ description:
+ name: file_picker_linux
+ sha256: c6562fc7d426db2fb85ea66fe2627953d2709932df5584ceaacf0aa5e39cf4da
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.2"
+ file_picker_platform_interface:
+ dependency: transitive
+ description:
+ name: file_picker_platform_interface
+ sha256: "336e7168306834a2b68e6168ed768e00d3fabeac23154d5793e277ca9f97cf20"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.2.0"
+ file_picker_web:
+ dependency: transitive
+ description:
+ name: file_picker_web
+ sha256: a2288008280aabe371aff029466b3405e60838e0a1d714767488c59b926c8b8c
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.2.0"
+ fixnum:
+ dependency: transitive
+ description:
+ name: fixnum
+ sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.1"
flutter:
dependency: "direct main"
description: flutter
@@ -304,6 +368,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
+ mime:
+ dependency: transitive
+ description:
+ name: mime
+ sha256: bd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.0"
objective_c:
dependency: transitive
description:
@@ -440,6 +512,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.0"
+ share_plus:
+ dependency: "direct main"
+ description:
+ name: share_plus
+ sha256: db40767f130189d53f3ae8a6393c217ff4a492da1baff718a9873679c0c00224
+ url: "https://pub.dev"
+ source: hosted
+ version: "13.3.1"
+ share_plus_platform_interface:
+ dependency: transitive
+ description:
+ name: share_plus_platform_interface
+ sha256: "365ef7379fc22507256adda3385152942ffce08935452bc972c2e52a0bebae41"
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.2.0"
shared_preferences:
dependency: "direct main"
description:
@@ -565,6 +653,78 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
+ url_launcher:
+ dependency: "direct main"
+ description:
+ name: url_launcher
+ sha256: e8cc955c97e06df9879140a1fe301f3d493f01b7c62dec7f46834be31d7e9fda
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.3.3"
+ url_launcher_android:
+ dependency: transitive
+ description:
+ name: url_launcher_android
+ sha256: "611e87fb320b70d1dd721dc46af89c98aceccea9b31fde49e084591414e0c610"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.3.33"
+ url_launcher_ios:
+ dependency: transitive
+ description:
+ name: url_launcher_ios
+ sha256: "8faa1aab294f1ab4040b43660c887b0418d5fa4f0cffef76a484e6aa1092eb4a"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.4.2"
+ url_launcher_linux:
+ dependency: transitive
+ description:
+ name: url_launcher_linux
+ sha256: "10f86fef4c2c43563fa6c211ff9cf757adf4d3ab762c56bd430664a947d70cd0"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.2.3"
+ url_launcher_macos:
+ dependency: transitive
+ description:
+ name: url_launcher_macos
+ sha256: "5e835a3b869c2d70325349c81c5a45c28e20791265b67b2669da6b08c5cd5201"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.2.6"
+ url_launcher_platform_interface:
+ dependency: transitive
+ description:
+ name: url_launcher_platform_interface
+ sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.3.2"
+ url_launcher_web:
+ dependency: transitive
+ description:
+ name: url_launcher_web
+ sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.4.3"
+ url_launcher_windows:
+ dependency: transitive
+ description:
+ name: url_launcher_windows
+ sha256: "6c5ad3f22cd4c38e089b81963b3cd7bb83b111b2df5dce008bb066162f42e429"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.1.6"
+ uuid:
+ dependency: transitive
+ description:
+ name: uuid
+ sha256: "9b129329f58692f6e6578329498a8fe9fbe98f090beb764ffbb8ee2eadd01dcd"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.6.0"
vector_math:
dependency: transitive
description:
@@ -685,6 +845,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.4.0"
+ windows_file_picker:
+ dependency: transitive
+ description:
+ name: windows_file_picker
+ sha256: "18452aa293de3b6961c6d05b0e71b4be7bb90c67635abdd3aa5c4e75dd875072"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.1"
xdg_directories:
dependency: transitive
description:
diff --git a/app/pubspec.yaml b/app/pubspec.yaml
index b10798d7..1afec5e9 100644
--- a/app/pubspec.yaml
+++ b/app/pubspec.yaml
@@ -45,6 +45,9 @@ dependencies:
package_info_plus: ^10.2.2
path_provider: ^2.1.6
open_filex: ^5.0.0
+ share_plus: ^13.3.1
+ file_picker: ^13.1.0
+ url_launcher: ^6.3.3
dev_dependencies:
flutter_test:
diff --git a/app/test/features/artifacts/actions/artifact_file_actions_test.dart b/app/test/features/artifacts/actions/artifact_file_actions_test.dart
index 27b48ccd..83360640 100644
--- a/app/test/features/artifacts/actions/artifact_file_actions_test.dart
+++ b/app/test/features/artifacts/actions/artifact_file_actions_test.dart
@@ -223,7 +223,11 @@ void main() {
stage: 'review',
visit: 1,
artifacts: [
- artifact('report.zip', contentType: 'application/zip', sizeBytes: 3),
+ artifact(
+ 'report.zip',
+ contentType: 'application/zip',
+ sizeBytes: 3,
+ ),
],
),
],
@@ -262,6 +266,14 @@ void main() {
artifact: _record,
resolved: resolveArtifactUrl(_endpoint, _record.url)!,
fetch: _fetch,
+ bridge: const ArtifactFileBridge(
+ downloadSupported: false,
+ shareSupported: false,
+ downloadUnsupportedMessage:
+ 'Downloading files is not supported on this platform yet.',
+ shareUnsupportedMessage:
+ 'File sharing is not supported on this platform yet.',
+ ),
),
),
),
@@ -374,8 +386,8 @@ void main() {
);
await tester.pumpAndSettle();
- expect(find.text('Download'), findsOneWidget);
- expect(find.text('Share'), findsOneWidget);
+ expect(find.byKey(const Key('artifact-download')), findsOneWidget);
+ expect(find.byKey(const Key('artifact-share')), findsOneWidget);
final externalGroup = visitGroup(artifacts: [external]);
await tester.pumpWidget(
@@ -395,9 +407,9 @@ void main() {
);
await tester.pumpAndSettle();
- expect(find.text('Download'), findsNothing);
- expect(find.text('Share'), findsNothing);
- expect(find.text('Open'), findsOneWidget);
+ expect(find.byKey(const Key('artifact-download')), findsNothing);
+ expect(find.byKey(const Key('artifact-share')), findsNothing);
+ expect(find.byKey(const Key('artifact-open')), findsOneWidget);
},
);
}
diff --git a/app/test/features/artifacts/ui/artifact_gallery_page_test.dart b/app/test/features/artifacts/ui/artifact_gallery_page_test.dart
index 88778988..4cdb0030 100644
--- a/app/test/features/artifacts/ui/artifact_gallery_page_test.dart
+++ b/app/test/features/artifacts/ui/artifact_gallery_page_test.dart
@@ -466,7 +466,10 @@ void main() {
);
expect(tester.takeException(), isNull);
- expect(tester.getSize(find.byType(CustomScrollView)).height, greaterThan(0));
+ expect(
+ tester.getSize(find.byType(CustomScrollView)).height,
+ greaterThan(0),
+ );
expect(
find.text('12 files excluded from artifact capture.'),
findsOneWidget,
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 6c14d079..2a9110de 100644
--- a/app/test/features/artifacts/ui/artifact_viewer_page_test.dart
+++ b/app/test/features/artifacts/ui/artifact_viewer_page_test.dart
@@ -150,10 +150,9 @@ void main() {
expect(find.byType(ArtifactViewerPage), findsOneWidget);
// The gallery's thumbnail and the viewer read the same recorded file.
expect(fetched, isNotEmpty);
- expect(
- fetched.toSet(),
- {Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png')},
- );
+ expect(fetched.toSet(), {
+ Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png'),
+ });
expect(find.byType(Image), findsOneWidget);
expect(find.text('1 of 1 · image/png'), findsOneWidget);
expect(find.text('image/png · 1.0\u00a0KiB'), findsOneWidget);
@@ -247,7 +246,7 @@ void main() {
);
expect(fetched, isEmpty);
expect(find.byType(Image), findsNothing);
- await tester.tap(find.text('Open'));
+ await tester.tap(find.byKey(const Key('artifact-open')));
await tester.pumpAndSettle();
expect(opened, [Uri.parse('https://elsewhere.test/shot.png')]);
});
@@ -320,8 +319,8 @@ void main() {
// The player streams the url itself; the viewer never fetches its bytes.
expect(find.byType(ArtifactVideoPlayer), findsOneWidget);
expect(find.text('This file type cannot be previewed here.'), findsNothing);
- expect(find.text('Open'), findsOneWidget);
- expect(find.text('Copy link'), findsOneWidget);
+ expect(find.byKey(const Key('artifact-open')), findsOneWidget);
+ expect(find.byKey(const Key('artifact-copy-link')), findsOneWidget);
expect(fetches, 0);
});
@@ -523,6 +522,37 @@ void main() {
expect(find.byType(Material), findsNothing);
});
+ testWidgets('a swipe moves to the next and previous artifact', (
+ 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 swipe = find.byKey(const Key('artifact-viewer-swipe'));
+ await tester.fling(swipe, const Offset(-300, 0), 1000);
+ await tester.pumpAndSettle();
+ expect(find.textContaining('2 of 2'), findsWidgets);
+ await tester.fling(swipe, const Offset(300, 0), 1000);
+ await tester.pumpAndSettle();
+ expect(find.textContaining('1 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;