545291e04a
- Run rows show a failed run's reason (else its diagnostic's first line, full text in a tooltip) or a short result preview; the Summary leads with "Why it failed". - Run again for succeeded/canceled/interrupted runs opens the New run form pre-filled (prompt, workspace, report format) at the latest version with the original offered. - Run detail and stage tabs show their names; touch shows captions on the Runs header and artifact viewer actions (desktop keeps tooltips). - ErrorNotice maps not connected / server too old / permission / timeout to what to do, raw detail behind Details (Schedules, create chat, Runs, Pipelines banners). - Settings has no Back arrow; Schedules keeps the rail on wide windows; phone Settings leads with Connection and Notifications and has a Jump to topic menu. - Walkthrough: Open Connection (skipped when connected), labelled Copy. - Pluralised counts; no duplicate status/rail names for screen readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
271 lines
7.8 KiB
Dart
271 lines
7.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/glass_bar.dart';
|
|
import '../domain/artifact_record.dart';
|
|
import '../domain/artifact_url.dart';
|
|
import '../ui/artifact_viewer_fetch.dart';
|
|
import 'artifact_file.dart';
|
|
import 'artifact_file_bridge.dart';
|
|
import 'artifact_file_controller.dart';
|
|
import '../../../ui/navigation/labelled_icon_button.dart';
|
|
|
|
/// Download and Share for one selected artifact, backed by its exact bytes.
|
|
///
|
|
/// The controls are standard native buttons. Download creates a named file;
|
|
/// Share passes a named file to the host share sheet and never falls back to
|
|
/// the artifact url. A host without a capability shows a disabled control and
|
|
/// the exact reason, while the other action keeps working. One tap starts at
|
|
/// most one transfer; a slow fetch shows progress and can be cancelled.
|
|
class ArtifactFileActions extends StatefulWidget {
|
|
const ArtifactFileActions({
|
|
super.key,
|
|
required this.artifact,
|
|
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;
|
|
final ArtifactFileBridge bridge;
|
|
|
|
@override
|
|
State<ArtifactFileActions> createState() => _ArtifactFileActionsState();
|
|
}
|
|
|
|
class _ArtifactFileActionsState extends State<ArtifactFileActions> {
|
|
late ArtifactFileActionsController _controller;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = _create();
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(covariant ArtifactFileActions oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (oldWidget.resolved.url != widget.resolved.url ||
|
|
oldWidget.artifact.url != widget.artifact.url ||
|
|
oldWidget.artifact.name != widget.artifact.name ||
|
|
oldWidget.artifact.contentType != widget.artifact.contentType ||
|
|
oldWidget.fetch != widget.fetch ||
|
|
oldWidget.bridge != widget.bridge) {
|
|
_controller.dispose();
|
|
_controller = _create();
|
|
}
|
|
}
|
|
|
|
ArtifactFileActionsController _create() => ArtifactFileActionsController(
|
|
artifact: widget.artifact,
|
|
resolved: widget.resolved,
|
|
fetch: widget.fetch,
|
|
bridge: widget.bridge,
|
|
);
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListenableBuilder(
|
|
listenable: _controller,
|
|
builder: (context, _) => widget.compact
|
|
? _IconActions(controller: _controller)
|
|
: _ActionBar(controller: _controller),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ActionBar extends StatelessWidget {
|
|
const _ActionBar({required this.controller});
|
|
|
|
final ArtifactFileActionsController controller;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final status = controller.status;
|
|
final notice = artifactFileRecordingNotice(
|
|
controller.artifact,
|
|
controller.resolved.uri,
|
|
);
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Wrap(
|
|
spacing: 8,
|
|
runSpacing: 4,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
children: [
|
|
_button(
|
|
label: 'Download',
|
|
icon: Icons.download_outlined,
|
|
onPressed: controller.canDownload && !controller.busy
|
|
? controller.download
|
|
: null,
|
|
),
|
|
_button(
|
|
label: 'Share',
|
|
icon: Icons.ios_share,
|
|
onPressed: controller.canShare && !controller.busy
|
|
? controller.share
|
|
: null,
|
|
),
|
|
if (controller.canCancel)
|
|
_button(
|
|
label: 'Cancel',
|
|
icon: Icons.close,
|
|
onPressed: controller.cancel,
|
|
),
|
|
],
|
|
),
|
|
if (controller.busy && status != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 6),
|
|
child: Semantics(
|
|
liveRegion: true,
|
|
container: true,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const SizedBox(
|
|
width: 14,
|
|
height: 14,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Flexible(child: Text(status)),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
else if (status != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 6),
|
|
child: Semantics(liveRegion: true, child: Text(status)),
|
|
),
|
|
if (!controller.canDownload)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 6),
|
|
child: Text(controller.bridge.downloadUnavailableMessage),
|
|
),
|
|
if (!controller.canShare)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 6),
|
|
child: Text(controller.bridge.shareUnavailableMessage),
|
|
),
|
|
if (notice != null)
|
|
Padding(padding: const EdgeInsets.only(top: 6), child: Text(notice)),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _button({
|
|
required String label,
|
|
required IconData icon,
|
|
required VoidCallback? onPressed,
|
|
}) {
|
|
return TextButton.icon(
|
|
onPressed: onPressed,
|
|
icon: Icon(icon, size: 18),
|
|
label: Text(label),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 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,
|
|
busy: busy,
|
|
onPressed: busy ? null : controller.download,
|
|
),
|
|
if (controller.canShare)
|
|
ArtifactIconAction(
|
|
key: const Key('artifact-share'),
|
|
label: 'Share',
|
|
icon: Icons.share_outlined,
|
|
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.onPressed,
|
|
this.busy = false,
|
|
this.caption,
|
|
});
|
|
|
|
final String label;
|
|
|
|
/// The short visible word on touch; defaults to [label].
|
|
final String? caption;
|
|
final IconData icon;
|
|
|
|
final VoidCallback? onPressed;
|
|
final bool busy;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (showsActionCaptions(context)) {
|
|
// Touch has no hover tooltip: the action is captioned.
|
|
return LabelledIconButton(
|
|
icon: icon,
|
|
label: label,
|
|
caption: caption,
|
|
onPressed: onPressed,
|
|
child: busy
|
|
? const SizedBox(
|
|
width: 18,
|
|
height: 18,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
)
|
|
: null,
|
|
);
|
|
}
|
|
return IconButton(
|
|
tooltip: label,
|
|
constraints: GlassBarMetrics.materialConstraints(),
|
|
padding: EdgeInsets.zero,
|
|
onPressed: onPressed,
|
|
icon: busy
|
|
? const SizedBox(
|
|
width: 18,
|
|
height: 18,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
)
|
|
: Icon(icon, size: GlassBarMetrics.iconSize()),
|
|
);
|
|
}
|
|
}
|