Files
alan 9551eceaed Complete Material-only APIs and fixtures
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
2026-11-11 21:55:39 +00:00

109 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import '../text/monospace.dart';
/// One recorded fact of a detail Summary: a small muted label over its value.
class FactsGridItem {
const FactsGridItem({
required this.label,
required this.value,
this.key,
this.monospace = false,
this.wide = false,
});
final String label;
final String value;
final Key? key;
/// Draws the value in the monospace family (and gives it a whole line).
final bool monospace;
/// Gives the fact a whole line even when its value is short.
final bool wide;
}
/// A value longer than this takes a whole line so it is never squeezed.
const int kFactsGridLongValue = 28;
/// The pane width from which the grid shows three facts per line.
const double kFactsGridThreeColumnWidth = 600;
/// A detail Summary's facts as one compact grid on the page, the same in every
/// detail (run, pipeline): two facts per line on a
/// phone, three from [kFactsGridThreeColumnWidth]; a long, wide or monospace
/// value (a path, a hash) takes a whole line.
///
/// The grid always fills its width and starts at the leading edge, so a
/// single fact is a cell at the start of the line, never a shrunk block
/// centred on the page. It draws no card or group of its own.
class FactsGrid extends StatelessWidget {
const FactsGrid({
super.key,
required this.items,
this.padding = const EdgeInsets.fromLTRB(16, 12, 16, 12),
this.selectable = true,
});
final List<FactsGridItem> items;
final EdgeInsetsGeometry padding;
/// Values are selectable text unless this is false.
final bool selectable;
@override
Widget build(BuildContext context) {
final labelStyle = Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
final TextStyle valueStyle =
Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
return Padding(
padding: padding,
child: LayoutBuilder(
builder: (context, constraints) {
const gap = 16.0;
final width = constraints.maxWidth;
final columns = width >= kFactsGridThreeColumnWidth ? 3 : 2;
final cell = (width - gap * (columns - 1)) / columns;
return SizedBox(
width: width,
child: Wrap(
spacing: gap,
runSpacing: 12,
children: [
for (final item in items)
SizedBox(
key: item.key,
width:
item.wide ||
item.monospace ||
item.value.length > kFactsGridLongValue
? width
: cell,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(item.label, style: labelStyle),
const SizedBox(height: 2),
_value(item, valueStyle),
],
),
),
],
),
);
},
),
);
}
Widget _value(FactsGridItem item, TextStyle base) {
final style = item.monospace
? base.copyWith(fontFamily: appMonospaceFamily)
: base;
if (!selectable) return Text(item.value, style: style);
return SelectableText(item.value, style: style);
}
}