Files
pipelines/app/lib/features/runs/ui/run_detail_timeline.dart
T
alan c6c6dcfe18 fix(app): float content behind top bars and give each wide pane its own bar row
- Top-bar clearance helpers (withTopBarClearance, withBarClearance,
  SliverTopBarClearance, BelowTopBar, TopBarNotices); shell, DetailPane and
  the runs/pipelines/templates/artifacts/stage definition/filter/usage pages
  drop their top SafeArea and pad their own lists, pinned headers pin at the
  inset.
- Wide windows: the shell bar narrows to the list pane (ShellPaneSplit) and
  the open item's bar shares its row; item tabs float at the pane's top
  (PageTabsEdge) instead of stacking on the shell's tab bar; the floating
  tab pill no longer swells over leftover media padding.
- Pipeline detail is a DetailPane on wide too; Run/Runs move from FABs into
  the bar's actions; name and identity live in the title pill.
- Run detail title pill shows the real title with Run N, pipeline and
  version (the pill links to the pipeline); the body keeps only status,
  actions and notices; standalone detail draws the same segmented bar.
- One Runs tab badge: attention outranks running.
- Tests for content-behind-bar padding and the no-stacking wide layout;
  notes/app-chrome-fixes.md.
2026-10-31 03:36:22 +00:00

178 lines
5.3 KiB
Dart

import '../../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart';
import 'run_detail_content.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The Timeline tab's recorded visits, one native row per visit.
///
/// [onSelected] receives the row's index in [visits], so the caller opens
/// exactly the recorded step it was built from. [selectedSequence] highlights a
/// row when a selection is applied while the list is rendered; the current
/// flow replaces the rows with the pane, so it only matters for a defensive
/// host that keeps both visible. Only an actual recorded visit can match, so an
/// unvisited stage leaves every row unselected.
class RunTimelineList extends StatelessWidget {
const RunTimelineList({
super.key,
required this.visits,
required this.cupertino,
this.selectedSequence,
this.onSelected,
});
final List<DetailVisit> visits;
final bool cupertino;
final int? selectedSequence;
final ValueChanged<int>? onSelected;
@override
Widget build(BuildContext context) {
if (visits.isEmpty) {
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: withBarClearance(context, const EdgeInsets.all(16)),
children: const [Text('No visits recorded.')],
);
}
final rows = [
for (var index = 0; index < visits.length; index += 1)
RunTimelineRow(
key: ValueKey(
'run-timeline-visit-${visits[index].sequence ?? index}',
),
visit: visits[index],
selected: visits[index].sequence == selectedSequence,
cupertino: cupertino,
onTap: onSelected == null ? null : () => onSelected!(index),
),
];
if (cupertino) {
return ListView(
key: const Key('run-detail-tab-body-timeline'),
children: [
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
header: const Text('Timeline'),
children: rows,
),
],
);
}
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: withBarClearance(
context,
const EdgeInsets.symmetric(vertical: 8),
),
children: rows,
);
}
}
/// One recorded visit. [selected] marks the row an applied selection identifies;
/// the current flow opens the pane instead of leaving a highlighted row. It is
/// never true for a stage with no recorded visit.
class RunTimelineRow extends StatelessWidget {
const RunTimelineRow({
super.key,
required this.visit,
required this.selected,
required this.cupertino,
this.onTap,
});
final DetailVisit visit;
final bool selected;
final bool cupertino;
final VoidCallback? onTap;
/// The visit's state for its glyph: the outcome when it has one (a completed
/// step can still have failed), else the step status.
String get _state {
final outcome = visit.outcome.toLowerCase();
if (outcome == 'error' || outcome == 'failed' || outcome == 'failure') {
return 'failed';
}
return runStateOf(visit.status);
}
/// One line under the title: where the visit went and how long it took.
String get _detail => [
if (visit.target.isNotEmpty) '→ ${visit.target}',
?visit.duration,
].join(' · ');
Widget _outcome(BuildContext context) {
final label = visit.outcome.isNotEmpty
? visit.outcome
: (visit.status.isEmpty ? 'unknown' : visit.status);
final color = runStatusColor(_state).resolveFrom(context);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: color.withValues(alpha: 0.14),
borderRadius: BorderRadius.circular(10),
),
child: Text(
label,
style: TextStyle(
color: color,
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
);
}
@override
Widget build(BuildContext context) {
final leading = RunStatusIcon(
state: _state,
label: visit.status.isEmpty ? 'Status unavailable' : visit.status,
size: 22,
);
final title = Text(
visit.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
);
final detail = _detail;
// The outcome chip leads the second line, so the title keeps the width.
final subtitle = Wrap(
spacing: 8,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [_outcome(context), if (detail.isNotEmpty) Text(detail)],
);
if (cupertino) {
return Semantics(
selected: selected,
child: CupertinoListTile(
leading: leading,
title: title,
subtitle: subtitle,
trailing: const CupertinoListTileChevron(),
backgroundColor: selected
? CupertinoDynamicColor.resolve(
CupertinoColors.secondarySystemFill,
context,
)
: null,
onTap: onTap,
),
);
}
return ListTile(
selected: selected,
leading: leading,
title: title,
subtitle: subtitle,
onTap: onTap,
);
}
}