feat(app): timeline rows lead with the visit's status icon and an outcome chip, with target and duration
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show formatDuration;
|
||||
import '../domain/run_models.dart';
|
||||
|
||||
/// One labelled value in the run detail's metrics block.
|
||||
@@ -17,6 +18,10 @@ typedef DetailVisit = ({
|
||||
int? sequence,
|
||||
String title,
|
||||
String subtitle,
|
||||
String status,
|
||||
String outcome,
|
||||
String target,
|
||||
String? duration,
|
||||
});
|
||||
|
||||
/// The run's primary label: the stored title, else the pipeline name, and only
|
||||
@@ -107,6 +112,10 @@ List<DetailVisit> detailTimeline(dynamic steps) {
|
||||
'${_text(step['stage'], 'Stage unavailable')} · visit '
|
||||
'${step['sequence'] is num ? (step['sequence'] as num).toInt() : 'unavailable'}',
|
||||
subtitle: _visitSubtitle(step),
|
||||
status: '${step['status'] ?? ''}'.trim(),
|
||||
outcome: '${step['outcome'] ?? ''}'.trim(),
|
||||
target: '${step['target'] ?? ''}'.trim(),
|
||||
duration: _visitDuration(step),
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -144,6 +153,15 @@ String _visitSubtitle(Map step) {
|
||||
].join(' · ');
|
||||
}
|
||||
|
||||
/// The web's `stepDuration`: finished minus started, when both are recorded.
|
||||
String? _visitDuration(Map step) {
|
||||
final started = DateTime.tryParse('${step['started_at'] ?? ''}');
|
||||
final finished = DateTime.tryParse('${step['finished_at'] ?? ''}');
|
||||
if (started == null || finished == null) return null;
|
||||
final seconds = finished.difference(started).inSeconds;
|
||||
return seconds < 0 ? null : formatDuration(seconds);
|
||||
}
|
||||
|
||||
String _text(dynamic value, String fallback) {
|
||||
final text = '${value ?? ''}'.trim();
|
||||
return text.isEmpty ? fallback : text;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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';
|
||||
|
||||
/// The Timeline tab's recorded visits, one native row per visit.
|
||||
@@ -82,20 +84,72 @@ class RunTimelineRow extends StatelessWidget {
|
||||
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: 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,
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
backgroundColor: selected
|
||||
? CupertinoDynamicColor.resolve(
|
||||
CupertinoColors.secondarySystemFill,
|
||||
@@ -108,9 +162,9 @@ class RunTimelineRow extends StatelessWidget {
|
||||
}
|
||||
return ListTile(
|
||||
selected: selected,
|
||||
leading: Icon(selected ? Icons.check_circle : Icons.circle_outlined),
|
||||
title: Text(visit.title),
|
||||
subtitle: Text(visit.subtitle),
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user