merge(app): land pipeline row alignment
This commit is contained in:
@@ -199,7 +199,8 @@ 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(
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -211,7 +212,7 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Flexible(
|
_RightCorner(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${pipelineVersionLabel(pipeline)} · #${pipeline.id}',
|
'${pipelineVersionLabel(pipeline)} · #${pipeline.id}',
|
||||||
style: muted,
|
style: muted,
|
||||||
@@ -220,6 +221,7 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +268,8 @@ 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(
|
||||||
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@@ -276,7 +279,7 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
if (shape != null) ...[
|
if (shape != null) ...[
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
// The miniature keeps to its corner and scales down when narrow.
|
// The miniature keeps to its corner and scales down when narrow.
|
||||||
Flexible(
|
_RightCorner(
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
@@ -295,7 +298,7 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
Expanded(child: lastRun),
|
Expanded(child: lastRun),
|
||||||
if (updated != null) ...[
|
if (updated != null) ...[
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Flexible(
|
_RightCorner(
|
||||||
child: Text(
|
child: Text(
|
||||||
updated,
|
updated,
|
||||||
style: style,
|
style: style,
|
||||||
@@ -307,6 +310,7 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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