feat(app): collapsibles keep their titles pinned; stage facts are coloured and grouped; input and output copy

This commit is contained in:
2026-10-23 20:22:41 +01:00
parent 94139dfd34
commit f9e03da133
10 changed files with 569 additions and 324 deletions
@@ -1,10 +1,9 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/artifact_groups.dart';
import '../../../ui/layout/sticky_section.dart';
import 'artifact_document_section.dart';
import 'artifact_record_row.dart';
import 'artifact_tile.dart';
@@ -83,7 +82,8 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
if (widget.groups.isEmpty) return _NoArtifacts(header: header);
final slivers = <Widget>[
if (header != null) SliverToBoxAdapter(child: header),
SliverToBoxAdapter(child: _modeSwitch(context)),
// The grid/list switch stays reachable while the gallery scrolls.
StickyBar(child: _modeSwitch(context)),
];
for (final group in widget.groups) {
final identity = '${group.stageKey}\u0000${group.visit}';
@@ -130,27 +130,19 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
required String title,
required int count,
required Widget body,
}) {
final open = !_closed.contains(key);
final scale = MediaQuery.textScalerOf(context).scale(16);
return SliverMainAxisGroup(
key: ValueKey<String>('artifact-section:$key'),
slivers: [
PinnedHeaderSliver(
child: SizedBox(
height: math.max(44, scale + 28),
child: _SectionTitle(
title: title,
count: count,
open: open,
onTap: () => _toggle(key),
),
),
),
if (open) SliverToBoxAdapter(child: body),
],
);
}
}) => StickySection(
key: ValueKey<String>('artifact-section:$key'),
title: title,
open: !_closed.contains(key),
onToggle: () => _toggle(key),
trailing: [
Padding(
padding: const EdgeInsetsDirectional.only(start: 6, end: 8),
child: Text('$count'),
),
],
body: body,
);
Widget _modeSwitch(BuildContext context) {
final cupertino = usesCupertinoHost(context);
@@ -266,83 +258,6 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
);
}
/// A section's pinned title bar: its name, how many items, and the chevron.
class _SectionTitle extends StatelessWidget {
const _SectionTitle({
required this.title,
required this.count,
required this.open,
required this.onTap,
});
final String title;
final int count;
final bool open;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final background = cupertino
? CupertinoColors.systemGroupedBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surface;
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final style = TextStyle(
fontWeight: FontWeight.w600,
color: cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface,
);
// `container` keeps the heading a separate semantics node.
return Semantics(
container: true,
header: true,
button: true,
expanded: open,
label: title,
value: '$count',
excludeSemantics: true,
onTap: onTap,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: ColoredBox(
color: background,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Expanded(
child: Text(
title,
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
Text('$count', style: TextStyle(color: muted)),
const SizedBox(width: 6),
Icon(
open
? (cupertino
? CupertinoIcons.chevron_up
: Icons.expand_less)
: (cupertino
? CupertinoIcons.chevron_down
: Icons.expand_more),
color: muted,
),
],
),
),
),
),
);
}
}
class _NoArtifacts extends StatelessWidget {
const _NoArtifacts({this.header});