Files
pipelines/app/lib/features/runs/ui/run_detail_timeline.dart
T

107 lines
2.9 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'run_detail_content.dart';
/// The Timeline tab's recorded visits, one native row per visit.
///
/// [selectedSequence] is the server sequence of the visit selected from the
/// Graph tab. 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,
});
final List<DetailVisit> visits;
final bool cupertino;
final int? selectedSequence;
@override
Widget build(BuildContext context) {
if (visits.isEmpty) {
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: 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,
),
];
if (cupertino) {
return ListView(
key: const Key('run-detail-tab-body-timeline'),
children: [
CupertinoListSection.insetGrouped(
header: const Text('Timeline'),
children: rows,
),
],
);
}
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: const EdgeInsets.symmetric(vertical: 8),
children: rows,
);
}
}
/// One recorded visit. [selected] highlights the row the Graph tab selected;
/// 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,
});
final DetailVisit visit;
final bool selected;
final bool cupertino;
@override
Widget build(BuildContext context) {
if (cupertino) {
return Semantics(
selected: selected,
child: CupertinoListTile(
leading: Icon(
selected
? CupertinoIcons.check_mark_circled_solid
: CupertinoIcons.circle,
),
title: Text(visit.title),
subtitle: Text(visit.subtitle),
trailing: selected ? const Icon(CupertinoIcons.check_mark) : null,
backgroundColor: selected
? CupertinoDynamicColor.resolve(
CupertinoColors.secondarySystemFill,
context,
)
: null,
),
);
}
return ListTile(
selected: selected,
leading: Icon(selected ? Icons.check_circle : Icons.circle_outlined),
title: Text(visit.title),
subtitle: Text(visit.subtitle),
);
}
}