merge(app): land summary facts grid
This commit is contained in:
@@ -39,8 +39,10 @@ Widget runDetailSummaryTab({
|
||||
if (rows.any((row) => !row.block))
|
||||
CupertinoListSection.insetGrouped(
|
||||
children: [
|
||||
for (final row in rows.where((row) => !row.block))
|
||||
_cupertinoRow(context, row),
|
||||
_summaryFacts(context, [
|
||||
for (final row in rows)
|
||||
if (!row.block) row,
|
||||
], cupertino: true),
|
||||
],
|
||||
),
|
||||
for (final row in rows.where((row) => row.block))
|
||||
@@ -81,8 +83,13 @@ Widget runDetailSummaryTab({
|
||||
),
|
||||
),
|
||||
),
|
||||
if (rows.any((row) => !row.block))
|
||||
_summaryFacts(context, [
|
||||
for (final row in rows)
|
||||
if (!row.block) row,
|
||||
], cupertino: false),
|
||||
for (final row in rows)
|
||||
row.block ? _materialBlock(context, row) : _materialRow(context, row),
|
||||
if (row.block) _materialBlock(context, row),
|
||||
_materialFieldSection(
|
||||
context,
|
||||
key: 'run-detail-summary-input',
|
||||
@@ -135,22 +142,72 @@ Widget runDetailFieldTab({
|
||||
|
||||
// --- Material --------------------------------------------------------------
|
||||
|
||||
Widget _materialRow(BuildContext context, DetailSummaryRow row) {
|
||||
final theme = Theme.of(context);
|
||||
final base = theme.textTheme.bodyMedium;
|
||||
return ListTile(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
title: Text(
|
||||
row.label,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
subtitle: SelectableText(
|
||||
row.value,
|
||||
style: row.monospace
|
||||
? base?.copyWith(fontFamily: appMonospaceFamily)
|
||||
: base,
|
||||
/// The recorded facts as a compact grid: two short facts per line on a phone,
|
||||
/// three when wider; a long or monospace value (a path, a hash) takes a whole
|
||||
/// line so it is never squeezed.
|
||||
Widget _summaryFacts(
|
||||
BuildContext context,
|
||||
List<DetailSummaryRow> rows, {
|
||||
required bool cupertino,
|
||||
}) {
|
||||
final labelStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
final TextStyle valueStyle =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium) ??
|
||||
const TextStyle();
|
||||
return Padding(
|
||||
key: const Key('run-detail-summary-facts'),
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
const gap = 16.0;
|
||||
final columns = constraints.maxWidth >= 600 ? 3 : 2;
|
||||
final cell = (constraints.maxWidth - gap * (columns - 1)) / columns;
|
||||
return Wrap(
|
||||
spacing: gap,
|
||||
runSpacing: 12,
|
||||
children: [
|
||||
for (final row in rows)
|
||||
SizedBox(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
width: row.monospace || row.value.length > 28
|
||||
? constraints.maxWidth
|
||||
: cell,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(row.label, style: labelStyle),
|
||||
const SizedBox(height: 2),
|
||||
cupertino
|
||||
? Text(
|
||||
row.value,
|
||||
style: row.monospace
|
||||
? valueStyle.copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
)
|
||||
: valueStyle,
|
||||
)
|
||||
: SelectableText(
|
||||
row.value,
|
||||
style: row.monospace
|
||||
? valueStyle.copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
)
|
||||
: valueStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -222,20 +279,6 @@ Widget _cupertinoIdentity(BuildContext context, String identity) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoRow(BuildContext context, DetailSummaryRow row) {
|
||||
final style = CupertinoTheme.of(context).textTheme.textStyle;
|
||||
return CupertinoListTile(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
title: Text(row.label),
|
||||
subtitle: Text(
|
||||
row.value,
|
||||
style: row.monospace
|
||||
? style.copyWith(fontFamily: appMonospaceFamily)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoBlock(BuildContext context, DetailSummaryRow row) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Padding(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -160,13 +159,39 @@ void main() {
|
||||
);
|
||||
expect(hash.style?.fontFamily, appMonospaceFamily);
|
||||
} else {
|
||||
final tile = tester.widget<CupertinoListTile>(
|
||||
find.byKey(const ValueKey('run-detail-summary-content-hash')),
|
||||
final hash = tester.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const ValueKey('run-detail-summary-content-hash')),
|
||||
matching: find.text('abc123def456'),
|
||||
),
|
||||
);
|
||||
expect((tile.subtitle! as Text).style?.fontFamily, appMonospaceFamily);
|
||||
expect(hash.style?.fontFamily, appMonospaceFamily);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('${platform.name} short summary facts share a line on a '
|
||||
'phone', (tester) async {
|
||||
await pumpRunDetail(
|
||||
tester,
|
||||
platform,
|
||||
run: recordedRunFixture(),
|
||||
size: const Size(390, 1600),
|
||||
);
|
||||
final started = tester.getRect(
|
||||
find.byKey(const ValueKey('run-detail-summary-started')),
|
||||
);
|
||||
final finished = tester.getRect(
|
||||
find.byKey(const ValueKey('run-detail-summary-finished')),
|
||||
);
|
||||
// Two facts per line, side by side; a hash still takes its own line.
|
||||
expect(finished.top, moreOrLessEquals(started.top));
|
||||
expect(finished.left, greaterThan(started.right));
|
||||
final hash = tester.getRect(
|
||||
find.byKey(const ValueKey('run-detail-summary-content-hash')),
|
||||
);
|
||||
expect(hash.width, greaterThan(300));
|
||||
});
|
||||
|
||||
testWidgets('${platform.name} summary sections state their exact empty '
|
||||
'wording', (tester) async {
|
||||
await pumpRunDetail(
|
||||
|
||||
Reference in New Issue
Block a user