Merge branch 'worktree-agent-a75e04ded5a42e4fb' into integrate/detail-bodies
# Conflicts: # app/lib/features/runs/ui/run_detail_timeline.dart
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../adaptive/host.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 on
|
||||
/// both hosts and 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,
|
||||
this.cupertino,
|
||||
});
|
||||
|
||||
final List<FactsGridItem> items;
|
||||
final EdgeInsetsGeometry padding;
|
||||
|
||||
/// Material values are selectable text; Cupertino values stay plain text.
|
||||
final bool selectable;
|
||||
|
||||
/// Overrides the host detection (a feature that picks its style per
|
||||
/// platform).
|
||||
final bool? cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = this.cupertino ?? usesCupertinoHost(context);
|
||||
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(
|
||||
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, cupertino),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _value(FactsGridItem item, TextStyle base, bool cupertino) {
|
||||
final style = item.monospace
|
||||
? base.copyWith(fontFamily: appMonospaceFamily)
|
||||
: base;
|
||||
if (cupertino || !selectable) return Text(item.value, style: style);
|
||||
return SelectableText(item.value, style: style);
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,15 @@ class SectionHeadingStyle {
|
||||
|
||||
static SectionHeadingStyle of(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
final base = CupertinoTheme.of(context).textTheme.textStyle;
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final base = theme.textTheme.textStyle;
|
||||
// The detail pages (run, stage, pipeline) are flat on the page colour,
|
||||
// as on Material, so a pinned heading's scrim is the page itself rather
|
||||
// than a grey grouped band (black in dark mode).
|
||||
final page = theme.scaffoldBackgroundColor;
|
||||
return SectionHeadingStyle(
|
||||
background: CupertinoColors.systemGroupedBackground.resolveFrom(
|
||||
context,
|
||||
),
|
||||
body: CupertinoColors.systemGroupedBackground.resolveFrom(context),
|
||||
background: page,
|
||||
body: page,
|
||||
accent: CupertinoTheme.of(context).primaryColor,
|
||||
title: base.copyWith(
|
||||
fontSize: 13,
|
||||
@@ -66,6 +69,7 @@ class SectionHeading extends StatelessWidget {
|
||||
this.titleColor,
|
||||
this.padding = const EdgeInsetsDirectional.only(start: 12, end: 8),
|
||||
this.minHeight = 40,
|
||||
this.header = false,
|
||||
});
|
||||
|
||||
final String title;
|
||||
@@ -75,6 +79,10 @@ class SectionHeading extends StatelessWidget {
|
||||
final EdgeInsetsGeometry padding;
|
||||
final double minHeight;
|
||||
|
||||
/// Announces the title as a heading to assistive tech (the trailing
|
||||
/// controls stay separate nodes).
|
||||
final bool header;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = SectionHeadingStyle.of(context);
|
||||
@@ -86,13 +94,17 @@ class SectionHeading extends StatelessWidget {
|
||||
children: [
|
||||
if (leading != null) ...[leading!, const SizedBox(width: 8)],
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: titleColor == null
|
||||
? style.title
|
||||
: style.title.copyWith(color: titleColor),
|
||||
child: Semantics(
|
||||
header: header,
|
||||
container: header,
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: titleColor == null
|
||||
? style.title
|
||||
: style.title.copyWith(color: titleColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
...trailing,
|
||||
|
||||
Reference in New Issue
Block a user