diff --git a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart index 5db43c02..a9d4335d 100644 --- a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart @@ -199,27 +199,29 @@ class PipelineListPanel extends StatelessWidget { /// The row's title line: its name, and its version and id in the corner. Widget _rowTitle(BuildContext context, PipelineSummary pipeline) { final muted = _mutedStyle(context); - return Row( - children: [ - Expanded( - child: Text( - pipeline.displayName, - maxLines: 1, - overflow: TextOverflow.ellipsis, - // Weight only: the native tile owns size and the selected colour. - style: const TextStyle(fontWeight: FontWeight.w600), + return _measured( + Row( + children: [ + Expanded( + child: Text( + pipeline.displayName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + // Weight only: the native tile owns size and the selected colour. + style: const TextStyle(fontWeight: FontWeight.w600), + ), ), - ), - const SizedBox(width: 8), - Flexible( - child: Text( - '${pipelineVersionLabel(pipeline)} · #${pipeline.id}', - style: muted, - maxLines: 1, - overflow: TextOverflow.ellipsis, + const SizedBox(width: 8), + _RightCorner( + child: Text( + '${pipelineVersionLabel(pipeline)} · #${pipeline.id}', + style: muted, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), ), - ), - ], + ], + ), ); } @@ -266,47 +268,49 @@ class PipelineListPanel extends StatelessWidget { : controller.runsLoaded ? Text('no runs recorded', style: style) : const SizedBox.shrink(); - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded(child: Text(what, style: style)), - if (shape != null) ...[ - const SizedBox(width: 8), - // The miniature keeps to its corner and scales down when narrow. - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - alignment: AlignmentDirectional.centerEnd, - child: PipelineMiniGraph( - key: Key('pipeline-mini-${pipeline.id}'), - shape: shape, + return _measured( + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded(child: Text(what, style: style)), + if (shape != null) ...[ + const SizedBox(width: 8), + // The miniature keeps to its corner and scales down when narrow. + _RightCorner( + child: FittedBox( + fit: BoxFit.scaleDown, + alignment: AlignmentDirectional.centerEnd, + child: PipelineMiniGraph( + key: Key('pipeline-mini-${pipeline.id}'), + shape: shape, + ), ), ), - ), + ], ], - ], - ), - const SizedBox(height: 2), - Row( - children: [ - Expanded(child: lastRun), - if (updated != null) ...[ - const SizedBox(width: 8), - Flexible( - child: Text( - updated, - style: style, - maxLines: 1, - overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 2), + Row( + children: [ + Expanded(child: lastRun), + if (updated != null) ...[ + const SizedBox(width: 8), + _RightCorner( + child: Text( + updated, + style: style, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), ), - ), + ], ], - ], - ), - ], + ), + ], + ), ); } @@ -549,3 +553,44 @@ List pipelineListActions( ), ]; } + +/// A row's right-hand item: its own width, flush against the trailing edge, +/// never more than about half the row, so the left side keeps the rest. +class _RightCorner extends StatelessWidget { + const _RightCorner({required this.child}); + + final Widget child; + + @override + Widget build(BuildContext context) { + final width = _RowWidth.of(context); + return ConstrainedBox( + constraints: BoxConstraints(maxWidth: width * 0.45), + child: child, + ); + } +} + +/// The width of the row a [_RightCorner] sits in. +class _RowWidth extends InheritedWidget { + const _RowWidth({required this.width, required super.child}); + + final double width; + + static double of(BuildContext context) => + context.dependOnInheritedWidgetOfExactType<_RowWidth>()?.width ?? + MediaQuery.sizeOf(context).width; + + @override + bool updateShouldNotify(_RowWidth oldWidget) => width != oldWidget.width; +} + +/// Gives the [_RightCorner]s inside [child] the row's own width. +Widget _measured(Widget child) => LayoutBuilder( + builder: (context, constraints) => _RowWidth( + width: constraints.hasBoundedWidth + ? constraints.maxWidth + : MediaQuery.sizeOf(context).width, + child: child, + ), +); diff --git a/app/test/features/pipelines/pipeline_list_composition_test.dart b/app/test/features/pipelines/pipeline_list_composition_test.dart index e90e7063..78555698 100644 --- a/app/test/features/pipelines/pipeline_list_composition_test.dart +++ b/app/test/features/pipelines/pipeline_list_composition_test.dart @@ -151,4 +151,21 @@ void main() { expect(updated.right, greaterThan(row.center.dx)); expect(updated.top, greaterThan(what.top)); }); + + testWidgets('right-hand row items end flush with the same edge', ( + tester, + ) async { + final fixture = PipelineFixture(); + await pumpWide(tester, gatewayFor(fixture)); + final version = tester.getRect(find.textContaining('v2 · #1')); + final updated = tester.getRect(find.text('updated 17 Oct 21:26')); + expect(updated.right, moreOrLessEquals(version.right, epsilon: 1)); + final mini = find.byKey(const Key('pipeline-mini-1')); + if (mini.evaluate().isNotEmpty) { + expect( + tester.getRect(mini).right, + moreOrLessEquals(version.right, epsilon: 1), + ); + } + }); }