diff --git a/app/lib/features/runs/ui/run_detail_tab_strip.dart b/app/lib/features/runs/ui/run_detail_tab_strip.dart index a567a241..2324b456 100644 --- a/app/lib/features/runs/ui/run_detail_tab_strip.dart +++ b/app/lib/features/runs/ui/run_detail_tab_strip.dart @@ -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 tabs; + /// The phone layout: a full-width bar under the content instead of a compact + /// strip under the header. + final bool bottom; + @override State createState() => _RunDetailTabStripState(); } @@ -69,6 +74,26 @@ class _RunDetailTabStripState extends State { @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 { ], 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 { 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), ), ); } diff --git a/app/lib/features/runs/ui/run_detail_tabs.dart b/app/lib/features/runs/ui/run_detail_tabs.dart index 47a7443f..841703e3 100644 --- a/app/lib/features/runs/ui/run_detail_tabs.dart +++ b/app/lib/features/runs/ui/run_detail_tabs.dart @@ -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 { 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 { 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 { key: ValueKey('run-detail-body-${widget.run['id']}'), child: _body(shown), ), + if (bottomTabs) SafeArea(top: false, child: strip), ], ); }, diff --git a/app/test/features/runs/ui/run_detail_tabs_test.dart b/app/test/features/runs/ui/run_detail_tabs_test.dart index 51ff3e38..d9fefdf3 100644 --- a/app/test/features/runs/ui/run_detail_tabs_test.dart +++ b/app/test/features/runs/ui/run_detail_tabs_test.dart @@ -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 {