merge(app): land bottom run tabs

This commit is contained in:
2026-10-23 16:58:57 +01:00
3 changed files with 73 additions and 9 deletions
@@ -31,6 +31,7 @@ class RunDetailTabStrip extends StatefulWidget {
required this.selected,
required this.onSelected,
this.tabs = renderedRunDetailTabs,
this.bottom = false,
});
final RunDetailTab selected;
@@ -39,6 +40,10 @@ class RunDetailTabStrip extends StatefulWidget {
/// The tabs this run offers, in [renderedRunDetailTabs] order.
final List<RunDetailTab> tabs;
/// The phone layout: a full-width bar under the content instead of a compact
/// strip under the header.
final bool bottom;
@override
State<RunDetailTabStrip> createState() => _RunDetailTabStripState();
}
@@ -69,6 +74,26 @@ class _RunDetailTabStripState extends State<RunDetailTabStrip> {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
if (widget.bottom) {
final divider = cupertino
? CupertinoColors.separator.resolveFrom(context)
: Theme.of(context).colorScheme.outlineVariant;
return DecoratedBox(
decoration: BoxDecoration(
border: Border(top: BorderSide(color: divider, width: 0.5)),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
child: SizedBox(
width: double.infinity,
child: KeyedSubtree(
key: const Key('run-detail-tabs'),
child: cupertino ? _cupertinoControl() : _materialControl(),
),
),
),
);
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: ScrollWhenOverflowing(
@@ -87,6 +112,8 @@ class _RunDetailTabStripState extends State<RunDetailTabStrip> {
],
selected: {widget.selected},
showSelectedIcon: false,
// The bottom bar spans the width; the header strip keeps its content size.
expandedInsets: widget.bottom ? EdgeInsets.zero : null,
onSelectionChanged: (selection) => widget.onSelected(selection.single),
);
@@ -109,7 +136,13 @@ class _RunDetailTabStripState extends State<RunDetailTabStrip> {
key: _labels[tab],
child: KeyedSubtree(
key: ValueKey('run-detail-tab-${tab.name}'),
child: Text(tab.label, maxLines: 1, softWrap: false),
// A full-width bar shrinks a long label rather than overflowing it.
child: widget.bottom
? FittedBox(
fit: BoxFit.scaleDown,
child: Text(tab.label, maxLines: 1, softWrap: false),
)
: Text(tab.label, maxLines: 1, softWrap: false),
),
);
}
+13 -8
View File
@@ -26,6 +26,9 @@ import 'run_search_selection.dart';
/// reserve keeps its bounded canvas positive at 320px with 2x text.
const double kRunDetailMinContentHeight = 240;
/// Below this width (a phone) the run detail's tabs sit at the bottom.
const double kRunDetailBottomTabsWidth = 600;
/// The run detail's tabbed body: the host-built header and platform tab strip
/// above the bounded selected tab.
///
@@ -271,6 +274,14 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
return LayoutBuilder(
builder: (context, constraints) {
final headerLimit = _headerLimit(constraints);
// On a phone the tabs are a bottom bar, under the content they switch.
final bottomTabs = constraints.maxWidth < kRunDetailBottomTabsWidth;
final strip = RunDetailTabStrip(
tabs: tabs,
selected: shown,
bottom: bottomTabs,
onSelected: (tab) => setState(() => _tab = tab),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -280,14 +291,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
key: ValueKey('run-detail-header-${widget.run['id']}'),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
widget.header,
RunDetailTabStrip(
tabs: tabs,
selected: shown,
onSelected: (tab) => setState(() => _tab = tab),
),
],
children: [widget.header, if (!bottomTabs) strip],
),
),
),
@@ -298,6 +302,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
key: ValueKey('run-detail-body-${widget.run['id']}'),
child: _body(shown),
),
if (bottomTabs) SafeArea(top: false, child: strip),
],
);
},
@@ -74,6 +74,32 @@ void main() {
}
});
testWidgets('${platform.name} phone tabs sit at the bottom, wide ones '
'under the header', (tester) async {
await pumpRunDetail(tester, platform, size: const Size(390, 844));
final strip = tester.getRect(find.byKey(const Key('run-detail-tabs')));
final body = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
);
expect(strip.top, greaterThanOrEqualTo(body.bottom));
expect(strip.bottom, greaterThan(844 - 80));
// Every tab is on screen without scrolling the bar.
for (final tab in renderedRunDetailTabs) {
final rect = tester.getRect(runDetailTab(tab));
expect(rect.left, greaterThanOrEqualTo(0), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(390), reason: tab.name);
}
await pumpRunDetail(tester, platform, size: const Size(1000, 844));
final wideStrip = tester.getRect(
find.byKey(const Key('run-detail-tabs')),
);
final wideBody = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
);
expect(wideStrip.bottom, lessThanOrEqualTo(wideBody.top));
});
testWidgets('${platform.name} missing graph states the exact wording', (
tester,
) async {