Merge branch 'main' into run/artifacts-split
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/// The viewer's words for a preview that could not be fetched.
|
||||
///
|
||||
/// The operator sees what happened in plain language and can retry; the raw
|
||||
/// exception text (`TypeError: Failed to fetch`) and bare status lines
|
||||
/// (`The server answered 404.`) never reach the screen. [status] is the HTTP
|
||||
/// status the server answered, or null when no answer arrived at all.
|
||||
String artifactPreviewFailureMessage({int? status}) {
|
||||
if (status == null) {
|
||||
return 'The preview could not be loaded. Check the connection and try '
|
||||
'again.';
|
||||
}
|
||||
if (status == 404 || status == 410) {
|
||||
return 'This file is no longer on the server.';
|
||||
}
|
||||
if (status == 401 || status == 403) {
|
||||
return 'The server did not allow this file to be opened.';
|
||||
}
|
||||
if (status >= 500) {
|
||||
return 'The server could not send this file right now.';
|
||||
}
|
||||
return 'The preview could not be loaded (status $status).';
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import '../../../ui/layout/section_heading.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -41,18 +41,10 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
children: rows,
|
||||
);
|
||||
}
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
header: Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
child: const Text('Turn documents'),
|
||||
),
|
||||
hasLeading: false,
|
||||
children: rows,
|
||||
);
|
||||
}
|
||||
// Flat rows under a quiet label on both hosts: the section sits inside
|
||||
// the visit's Session page, which is itself flat, so a Cupertino inset
|
||||
// group here would be a group nested in a group.
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -61,7 +53,10 @@ class ArtifactDocumentSection extends StatelessWidget {
|
||||
child: Semantics(
|
||||
container: true,
|
||||
header: true,
|
||||
child: const Text('Turn documents'),
|
||||
child: Text(
|
||||
'Turn documents',
|
||||
style: cupertino ? SectionHeadingStyle.of(context).title : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
...rows,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -496,10 +495,9 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
|
||||
);
|
||||
if (widget.embedded) return body;
|
||||
if (usesCupertinoHost(context)) {
|
||||
// Flat sections on the page colour, as in the run and stage details;
|
||||
// their pinned headings take the same colour.
|
||||
return CupertinoPageScaffold(
|
||||
// Sections paint the grouped background; the page must match it or a
|
||||
// white seam shows below the last section in light mode.
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
navigationBar: const SegmentedBar(
|
||||
cupertino: true,
|
||||
title: artifactGalleryTitle,
|
||||
|
||||
@@ -41,8 +41,12 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
this.bytes,
|
||||
this.error,
|
||||
this.status,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Loads the current page's preview again after a failure.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final PagedArtifact page;
|
||||
final ArtifactPreviewPlan plan;
|
||||
final int index;
|
||||
@@ -76,6 +80,7 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
text: text,
|
||||
bytes: bytes,
|
||||
error: error,
|
||||
onRetry: onRetry,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
import '../domain/artifact_preview.dart';
|
||||
import 'artifact_html_view.dart';
|
||||
import 'artifact_table_view.dart';
|
||||
@@ -35,8 +38,12 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
this.error,
|
||||
this.videoControllerFactory = defaultArtifactVideoController,
|
||||
this.htmlBuilder = defaultArtifactHtml,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Offered under a fetch failure; absent, the message stands alone.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final ArtifactPreviewPlan plan;
|
||||
final bool loading;
|
||||
final ArtifactMarkdownBuilder markdownBuilder;
|
||||
@@ -60,7 +67,7 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
return const _Loading();
|
||||
}
|
||||
if (error != null) {
|
||||
return _Message(error!);
|
||||
return _Message(error!, onRetry: onRetry);
|
||||
}
|
||||
switch (plan.kind) {
|
||||
case ArtifactPreviewKind.image:
|
||||
@@ -201,17 +208,42 @@ class _PreviewPadding extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const artifactPreviewRetryKey = Key('artifact-preview-retry');
|
||||
|
||||
class _Message extends StatelessWidget {
|
||||
const _Message(this.message);
|
||||
const _Message(this.message, {this.onRetry});
|
||||
|
||||
final String message;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final retry = onRetry;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(message, textAlign: TextAlign.center),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(message, textAlign: TextAlign.center),
|
||||
if (retry != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
cupertino
|
||||
? CupertinoButton.tinted(
|
||||
key: artifactPreviewRetryKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: artifactPreviewRetryKey,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'artifact_selection_facts.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_preview.dart';
|
||||
import '../domain/artifact_preview_failure.dart';
|
||||
import '../domain/artifact_url.dart';
|
||||
import '../domain/gallery_navigation.dart';
|
||||
import 'artifact_external_open.dart';
|
||||
@@ -157,7 +158,7 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
if (!result.ok) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'The server answered ${result.status}.';
|
||||
_error = artifactPreviewFailureMessage(status: result.status);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -168,11 +169,11 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
_fetched = fetched;
|
||||
});
|
||||
},
|
||||
onError: (Object error) {
|
||||
onError: (Object _) {
|
||||
if (!mounted || generation != _generation) return;
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'Could not load preview: $error';
|
||||
_error = artifactPreviewFailureMessage();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -259,6 +260,8 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
fileBridge: widget.fileBridge,
|
||||
onPrevious: () => _step(-1),
|
||||
onNext: () => _step(1),
|
||||
// A failure is never cached, so loading again fetches afresh.
|
||||
onRetry: _beginLoad,
|
||||
onOpen: plan.resolved == null ? () {} : () => _open(plan.resolved!),
|
||||
onCopy: plan.resolved == null ? () {} : () => _copy(plan.resolved!),
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../../../ui/layout/section_heading.dart';
|
||||
import '../../../ui/layout/sticky_section.dart';
|
||||
import 'artifact_document_section.dart';
|
||||
import 'artifact_record_row.dart';
|
||||
@@ -104,7 +105,14 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
|
||||
final slivers = <Widget>[
|
||||
if (header != null) SliverToBoxAdapter(child: header),
|
||||
// The grid/list switch stays reachable while the gallery scrolls.
|
||||
StickyBar(child: _modeSwitch(context)),
|
||||
PinnedHeaderSliver(
|
||||
// On the page colour (that of the pinned section headings), not a
|
||||
// grouped band.
|
||||
child: ColoredBox(
|
||||
color: SectionHeadingStyle.of(context).background,
|
||||
child: _modeSwitch(context),
|
||||
),
|
||||
),
|
||||
];
|
||||
for (final group in widget.groups) {
|
||||
final identity = '${group.stageKey}\u0000${group.visit}';
|
||||
|
||||
Reference in New Issue
Block a user