merge(app): land pipeline row alignment
This commit is contained in:
@@ -199,27 +199,29 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
/// The row's title line: its name, and its version and id in the corner.
|
/// The row's title line: its name, and its version and id in the corner.
|
||||||
Widget _rowTitle(BuildContext context, PipelineSummary pipeline) {
|
Widget _rowTitle(BuildContext context, PipelineSummary pipeline) {
|
||||||
final muted = _mutedStyle(context);
|
final muted = _mutedStyle(context);
|
||||||
return Row(
|
return _measured(
|
||||||
children: [
|
Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: Text(
|
Expanded(
|
||||||
pipeline.displayName,
|
child: Text(
|
||||||
maxLines: 1,
|
pipeline.displayName,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 1,
|
||||||
// Weight only: the native tile owns size and the selected colour.
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
// Weight only: the native tile owns size and the selected colour.
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 8),
|
_RightCorner(
|
||||||
Flexible(
|
child: Text(
|
||||||
child: Text(
|
'${pipelineVersionLabel(pipeline)} · #${pipeline.id}',
|
||||||
'${pipelineVersionLabel(pipeline)} · #${pipeline.id}',
|
style: muted,
|
||||||
style: muted,
|
maxLines: 1,
|
||||||
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,47 +268,49 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
: controller.runsLoaded
|
: controller.runsLoaded
|
||||||
? Text('no runs recorded', style: style)
|
? Text('no runs recorded', style: style)
|
||||||
: const SizedBox.shrink();
|
: const SizedBox.shrink();
|
||||||
return Column(
|
return _measured(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
Row(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
Row(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
Expanded(child: Text(what, style: style)),
|
children: [
|
||||||
if (shape != null) ...[
|
Expanded(child: Text(what, style: style)),
|
||||||
const SizedBox(width: 8),
|
if (shape != null) ...[
|
||||||
// The miniature keeps to its corner and scales down when narrow.
|
const SizedBox(width: 8),
|
||||||
Flexible(
|
// The miniature keeps to its corner and scales down when narrow.
|
||||||
child: FittedBox(
|
_RightCorner(
|
||||||
fit: BoxFit.scaleDown,
|
child: FittedBox(
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
fit: BoxFit.scaleDown,
|
||||||
child: PipelineMiniGraph(
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
key: Key('pipeline-mini-${pipeline.id}'),
|
child: PipelineMiniGraph(
|
||||||
shape: shape,
|
key: Key('pipeline-mini-${pipeline.id}'),
|
||||||
|
shape: shape,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
),
|
const SizedBox(height: 2),
|
||||||
const SizedBox(height: 2),
|
Row(
|
||||||
Row(
|
children: [
|
||||||
children: [
|
Expanded(child: lastRun),
|
||||||
Expanded(child: lastRun),
|
if (updated != null) ...[
|
||||||
if (updated != null) ...[
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 8),
|
_RightCorner(
|
||||||
Flexible(
|
child: Text(
|
||||||
child: Text(
|
updated,
|
||||||
updated,
|
style: style,
|
||||||
style: style,
|
maxLines: 1,
|
||||||
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,3 +553,44 @@ List<Widget> 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,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|||||||
@@ -151,4 +151,21 @@ void main() {
|
|||||||
expect(updated.right, greaterThan(row.center.dx));
|
expect(updated.right, greaterThan(row.center.dx));
|
||||||
expect(updated.top, greaterThan(what.top));
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user