diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index ad473460..bd62192e 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -152,25 +152,34 @@ class _AdaptiveShellState extends State { // Only the bar shows the registry's state, so a published bar or badge // rebuilds its bar alone; the destinations and scaffold stay as built. _bar.focus = _selected; - // One floating glass tab bar at every width: full width on a phone, - // sized to its tabs at the right edge on a wide window (the bar judges - // that itself, live). Content keeps the whole width and scrolls behind - // it, learning the bar's height as its bottom media padding. Neither - // scaffold's structure depends on the width, so resizing never + // One floating glass tab bar at every width: sized to its tabs at the + // right edge, near the thumb. Content keeps the whole width and scrolls + // behind it, learning the bar's height as its bottom media padding. + // Neither scaffold's structure depends on the width, so resizing never // remounts a destination. // - // While the tab shows its list beside an open item the bar keeps - // the same place, bottom right near the thumb: the item pane learns - // the bar's height (see ListDetailPanes) and floats its own tabs or - // composer above it, so the two never overlap. + // While the tab shows its list beside an open item the bar moves under + // the list pane, centred in the list's (dragged) width, so the open item + // keeps its whole height: the list clears the bar and the item clears + // only the system inset (see ListDetailPanes). The bar keeps its place + // in the tree, so a split never replays its entrance. final bar = ListenableBuilder( - listenable: _bar.badges, - builder: (context, _) => FloatingDestinationBar( - cupertino: widget.cupertino, - currentIndex: index, - onTap: (value) => _select(shellTabDestinations[value]), - items: _destinationItems(), - ), + listenable: Listenable.merge([_bar.badges, _bar.bar, _paneWidths]), + builder: (context, _) { + final split = _bar.split(_selected); + return ListPaneWidth( + split: split, + preferredWidth: _paneWidths.widthFor(_selected.name), + alignment: AlignmentDirectional.bottomStart, + child: FloatingDestinationBar( + cupertino: widget.cupertino, + currentIndex: index, + onTap: (value) => _select(shellTabDestinations[value]), + items: _destinationItems(), + alignment: split ? Alignment.bottomCenter : null, + ), + ); + }, ); // Destinations reach the top edge and scroll behind the floating top // bar too: each learns the bar's height as its top media padding and diff --git a/app/lib/shell/detail_pane_navigator.dart b/app/lib/shell/detail_pane_navigator.dart index ede2e21f..e10e8141 100644 --- a/app/lib/shell/detail_pane_navigator.dart +++ b/app/lib/shell/detail_pane_navigator.dart @@ -7,8 +7,8 @@ import '../ui/adaptive/host.dart'; /// /// A page the item opens (a run's stage page, an artifact, a file) is pushed /// here, so it fills the item's pane while the list and the shell's tab bar -/// stay in place: the page's own tabs then float above the shell's bar, as -/// the item's tabs do. Dialogs still use the root navigator. +/// stay in place: the page's own tabs then float at the bottom of the pane, +/// as the item's tabs do (the shell's bar stays under the list). Dialogs still use the root navigator. /// /// The item is this navigator's first page under a fixed key, so a rebuilt /// item updates in place and is never remounted. The system Back pops a page diff --git a/app/lib/shell/list_detail.dart b/app/lib/shell/list_detail.dart index e876df28..01cbea0f 100644 --- a/app/lib/shell/list_detail.dart +++ b/app/lib/shell/list_detail.dart @@ -84,11 +84,11 @@ class ListPaneWidth extends StatelessWidget { /// Under the shell, the list keeps the shell's top bar (narrowed to the list /// pane through [ShellPaneSplit], see [ListPaneWidth]) and the open item owns /// the rest of the window: the detail starts at the top edge below the status -/// bar ([ShellSystemInsets]). The shell's tab bar stays at the bottom right, -/// over the detail pane, so the detail learns that bar's height plus -/// [kStackedBarGap] as its bottom padding: its own tabs (or the chat -/// composer) float above the shell's bar, never on it, and its content clears -/// both. Pages the item opens stay in its pane ([DetailPaneNavigator]). +/// bar ([ShellSystemInsets]). The shell's tab bar moves to the bottom of the +/// list pane, so the list learns that bar's height as its bottom padding and +/// the detail keeps its whole height: its own tabs (or the chat composer) sit +/// at its bottom edge, above the system inset only. Pages the item opens stay +/// in its pane ([DetailPaneNavigator]). class ListDetailPanes extends StatefulWidget { const ListDetailPanes({ super.key, @@ -139,20 +139,20 @@ class _ListDetailPanesState extends State { final bodyWidth = math.max(0.0, available - 1 - listWidth); final bounds = listPaneWidthBounds(window, available); Widget body = widget.detail; - Widget listPane = widget.list; if (split) { // Beside the list the item is not under the shell's top bar (it // stays over the list pane): it keeps the system's own top // inset, so its bar sits just below the status bar at the top - // edge. The shell's tab bar floats at the bottom right, over - // this pane; its height (the shell's bottom padding here) plus - // a gap lifts the item's tabs or composer above it. + // edge. The shell's tab bar floats at the bottom of the list + // pane, not over this one, so the item clears only the + // system's bottom inset and its own tabs or composer sit at + // its bottom edge. final system = ShellSystemInsets.of(context); body = MediaQuery( data: media.copyWith( padding: media.padding.copyWith( top: system.top, - bottom: media.padding.bottom + kStackedBarGap, + bottom: system.bottom, ), ), child: PageTabsEdge( @@ -163,15 +163,8 @@ class _ListDetailPanesState extends State { ), ), ); - // The tab bar sits over the detail pane, never the list (the - // detail is at least half the window, wider than the bar), so - // the list clears only the system's bottom inset. - listPane = MediaQuery( - data: media.copyWith( - padding: media.padding.copyWith(bottom: system.bottom), - ), - child: widget.list, - ); + // The list keeps the shell's bottom padding (the tab bar's + // height), so its last rows scroll clear of the bar. } return Stack( children: [ @@ -185,7 +178,7 @@ class _ListDetailPanesState extends State { container: true, explicitChildNodes: true, identifier: 'list-detail-list', - child: listPane, + child: widget.list, ), ), ), diff --git a/app/lib/shell/list_detail_policy.dart b/app/lib/shell/list_detail_policy.dart index 113aefd2..fb25c345 100644 --- a/app/lib/shell/list_detail_policy.dart +++ b/app/lib/shell/list_detail_policy.dart @@ -21,7 +21,7 @@ bool showsListBesideDetail(BuildContext context) => const double kListPaneMinWidth = 240; /// The narrowest open item a drag leaves, beside the share of the window it -/// always keeps (so the shell's tab bar, floating over it, still fits). +/// always keeps (so its own tabs, floating at its bottom, still fit). const double kDetailPaneMinWidth = 320; const double _listWindowMaximum = 0.6; diff --git a/app/lib/ui/adaptive/floating_bar_layout.dart b/app/lib/ui/adaptive/floating_bar_layout.dart index b3e06c8f..ed08aef4 100644 --- a/app/lib/ui/adaptive/floating_bar_layout.dart +++ b/app/lib/ui/adaptive/floating_bar_layout.dart @@ -7,11 +7,6 @@ const double kFloatingBarWideWidth = 600; /// The gap between a floating tab bar and the edges (and bottom safe area). const double kFloatingBarMargin = 16; -/// The gap between two floating bars stacked at the bottom right of a wide -/// window: the shell's tab bar and, above it, an open item's own tabs (the -/// chat composer adds its own padding on top of this). -const double kStackedBarGap = 12; - /// [padding] with the floating bar's clearance added at the bottom. /// /// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell) diff --git a/app/lib/ui/adaptive/floating_destination_bar.dart b/app/lib/ui/adaptive/floating_destination_bar.dart index 053a4602..f1c99e6c 100644 --- a/app/lib/ui/adaptive/floating_destination_bar.dart +++ b/app/lib/ui/adaptive/floating_destination_bar.dart @@ -36,10 +36,16 @@ class FloatingDestinationBar extends StatefulWidget { required this.onTap, required this.items, this.edge = FloatingBarEdge.bottom, + this.alignment, }); final bool cupertino; + /// Where the row sits in the width it is given, at [FloatingBarEdge.bottom]: + /// the trailing end by default. The shell centres its tabs under the list + /// pane while a list shows beside an open item. + final AlignmentGeometry? alignment; + /// The edge the bar floats at. At [FloatingBarEdge.top] (an open item's /// tabs under its pane's top bar) the bar sits at the leading edge, in line /// with the bar's title, and keeps no bottom safe area. @@ -149,7 +155,7 @@ class _FloatingDestinationBarState extends State heightFactor: 1, alignment: top ? AlignmentDirectional.topStart - : AlignmentDirectional.bottomEnd, + : widget.alignment ?? AlignmentDirectional.bottomEnd, child: _row(context, constraints.maxWidth), ), ); diff --git a/app/test/shell/pane_bar_row_test.dart b/app/test/shell/pane_bar_row_test.dart index fdc55a58..149d7a66 100644 --- a/app/test/shell/pane_bar_row_test.dart +++ b/app/test/shell/pane_bar_row_test.dart @@ -151,7 +151,7 @@ void main() { }); testWidgets('$host 1200: the item\'s tabs float at the bottom of its ' - 'pane, above the shell\'s tab bar', (tester) async { + 'pane, the shell\'s tab bar under the list', (tester) async { await setSize(tester, const Size(1200, 800)); await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pump(); @@ -174,11 +174,15 @@ void main() { final body = tester.getRect( find.byKey(const ValueKey('list-detail-body')), ); - // The shell's tabs keep the bottom right; the item's float a gap - // above them in the detail pane, never on them. + // The shell's tabs sit at the bottom of the list pane; the item's at + // the bottom right of the detail pane, never on them. + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); - expect(itemTabs.bottom, closeTo(shellTabs.top - kStackedBarGap, 0.5)); + expect(shellTabs.right, lessThanOrEqualTo(list.right)); + expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(itemTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); expect(itemTabs.left, greaterThanOrEqualTo(body.left)); expect(itemTabs.overlaps(shellTabs), isFalse); // The item's list starts below its bar and clears its tabs at rest. diff --git a/app/test/shell/split_destination_bar_test.dart b/app/test/shell/split_destination_bar_test.dart index 7d0bd3e4..3f700e86 100644 --- a/app/test/shell/split_destination_bar_test.dart +++ b/app/test/shell/split_destination_bar_test.dart @@ -4,13 +4,14 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/shell/adaptive_shell.dart'; import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/list_detail.dart'; +import 'package:pipelines_app/shell/list_pane_widths.dart'; import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; /// While a tab shows its list beside an open item, the shell's destination -/// bar keeps its place at the bottom right (near the thumb). The item's own -/// bottom control (its tabs, or a composer) floats above it with a gap, and -/// the item's content clears both. +/// bar moves to the bottom of the list pane, centred in the list's (dragged) +/// width. The list clears the bar; the item keeps its whole height, its own +/// bottom control (its tabs, or a composer) at its bottom edge. void main() { Future setSize(WidgetTester tester, Size size) async { tester.view.physicalSize = size; @@ -75,9 +76,11 @@ void main() { bool split = true, bool tabs = false, double textScale = 1, + ListPaneWidthStore? store, }) { final app = AdaptiveShell( cupertino: cupertino, + listPaneWidthStore: store ?? MemoryListPaneWidthStore(), destination: AppDestination.chat, destinationBodies: { AppDestination.chat: (_) => split @@ -109,8 +112,8 @@ void main() { final host = cupertino ? 'Cupertino' : 'Material'; for (final width in [1200.0, 1600.0]) { - testWidgets('$host $width split: the destination bar stays bottom ' - 'right and the composer floats above it', (tester) async { + testWidgets('$host $width split: the destination bar sits under the ' + 'list and the composer at the detail\'s bottom edge', (tester) async { await setSize(tester, Size(width, 800)); await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pump(); @@ -123,29 +126,40 @@ void main() { find.byKey(const ValueKey('list-detail-body')), ); final pill = destinationPill(tester); - // Compact at the window's right edge, over the detail pane only. - expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5)); + // Centred at the bottom of the list pane, never over the detail. + expect(pill.center.dx, closeTo(list.center.dx, 0.5)); expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(pill.width, lessThan(body.width / 2)); - expect(pill.overlaps(list), isFalse, reason: 'never over the list'); - expect(pill.left, greaterThan(body.left)); + expect(pill.right, lessThanOrEqualTo(list.right)); + expect(pill.overlaps(body), isFalse, reason: 'never over the detail'); + expect( + pill.width, + FloatingDestinationBar.rowWidth(cupertino: cupertino, tabs: 4), + ); - // The composer's box starts a gap above the shell's pill (the real - // composer pads its pill by another 12 inside that box). + // The composer reaches the detail's bottom edge: nothing is reserved + // there for the shell's bar any more. final composer = tester.getRect(find.byKey(const Key('composer'))); expect(composer.left, body.left); + expect(composer.bottom, closeTo(800, 0.5)); expect(composer.overlaps(pill), isFalse); - expect(pill.top - composer.bottom, closeTo(kStackedBarGap, 0.5)); - // The list is not under the bar: it clears only the system inset. + // The list clears the bar, so its last rows scroll out from under it. final listContext = tester.element(find.byKey(const Key('list'))); - expect(MediaQuery.paddingOf(listContext).bottom, 0); + expect( + MediaQuery.paddingOf(listContext).bottom, + greaterThanOrEqualTo(800 - pill.top), + ); + await tester.drag( + find.byKey(const Key('list')), + const Offset(0, -4000), + ); + await tester.pumpAndSettle(); + final last = tester.getRect(find.text('row 39')); + expect(last.bottom, lessThanOrEqualTo(pill.top)); }); - testWidgets('$host $width split: the item tabs float above the ' - 'destination bar with a gap, and its content clears both', ( - tester, - ) async { + testWidgets('$host $width split: the item tabs sit at the bottom right ' + 'of the detail, and its content clears only them', (tester) async { await setSize(tester, Size(width, 800)); await tester.pumpWidget(shell(cupertino: cupertino, tabs: true)); await tester.pump(); @@ -163,13 +177,13 @@ void main() { ) .first, ); - expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5)); expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5)); + expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); expect(tabs.left, greaterThan(body.left)); expect(tabs.overlaps(pill), isFalse); - expect(pill.top - tabs.bottom, closeTo(kStackedBarGap, 0.5)); + expect(pill.right, lessThan(body.left)); - // The item's list pads its end clear of both pills. + // The item's list pads its end clear of its own tabs. final listContext = tester.element( find.byKey(const Key('detail-list')), ); @@ -180,6 +194,23 @@ void main() { }); } + testWidgets('$host 1200 split: the bar follows a dragged list width', ( + tester, + ) async { + await setSize(tester, const Size(1200, 800)); + final store = MemoryListPaneWidthStore({'chat': 300}); + await tester.pumpWidget(shell(cupertino: cupertino, store: store)); + await tester.pumpAndSettle(); + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + expect(list.width, closeTo(300, 0.5)); + final pill = destinationPill(tester); + expect(pill.center.dx, closeTo(list.center.dx, 0.5)); + expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5)); + expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin)); + }); + testWidgets('$host 1200 unsplit: the bar is compact at the right edge', ( tester, ) async { @@ -205,8 +236,8 @@ void main() { }); for (final width in [600.0, 840.0]) { - testWidgets('$host $width split at 2x: both bars lay out over the ' - 'detail pane without overflow', (tester) async { + testWidgets('$host $width split at 2x: the bar fits the list pane and ' + 'the item tabs the detail, without overflow', (tester) async { await setSize(tester, Size(width, 800)); await tester.pumpWidget( shell(cupertino: cupertino, tabs: true, textScale: 2), @@ -214,12 +245,12 @@ void main() { await tester.pump(); await tester.pump(); expect(tester.takeException(), isNull); - final body = tester.getRect( - find.byKey(const ValueKey('list-detail-body')), + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), ); final pill = destinationPill(tester); - expect(pill.left, greaterThanOrEqualTo(body.left)); - expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5)); + expect(pill.left, greaterThanOrEqualTo(list.left)); + expect(pill.right, lessThanOrEqualTo(list.right)); }); } } diff --git a/app/test/shell/split_detail_pages_test.dart b/app/test/shell/split_detail_pages_test.dart index 7997d4ba..2f9c2d84 100644 --- a/app/test/shell/split_detail_pages_test.dart +++ b/app/test/shell/split_detail_pages_test.dart @@ -78,23 +78,26 @@ void main() { for (final cupertino in [false, true]) { final host = cupertino ? 'Cupertino' : 'Material'; - testWidgets('$host 1200: run tabs float above the shell bar, and the ' - 'stage page opens in the pane with its tabs above it too', ( + testWidgets('$host 1200: run tabs float at the pane\'s bottom beside the ' + 'shell bar under the list, and the stage page opens in the pane', ( tester, ) async { await pumpSplitRun(tester, cupertino); final body = tester.getRect( find.byKey(const ValueKey('list-detail-body')), ); + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); var main = shellPill(tester); - expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(main.center.dx, closeTo(list.center.dx, 0.5)); expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs'))); expect(runTabs.left, greaterThanOrEqualTo(body.left)); expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); expect(runTabs.overlaps(main), isFalse); - expect(main.top - runTabs.bottom, closeTo(kStackedBarGap, 0.5)); + expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); // Open the stage page from the timeline. await openRunDetailTab(tester, RunDetailTab.timeline); @@ -115,14 +118,14 @@ void main() { final back = tester.getRect(find.byKey(const Key('run-visit-back'))); expect(back.left, greaterThanOrEqualTo(body.left)); main = shellPill(tester); - expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(main.center.dx, closeTo(list.center.dx, 0.5)); final visitTabs = pillOf( tester, find.byKey(const Key('run-visit-tabs')).last, ); expect(visitTabs.left, greaterThanOrEqualTo(body.left)); expect(visitTabs.overlaps(main), isFalse); - expect(main.top - visitTabs.bottom, closeTo(kStackedBarGap, 0.5)); + expect(visitTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); expect(tester.takeException(), isNull); // The shell's tabs still work over the open stage page. diff --git a/app/test/shell/split_status_bar_test.dart b/app/test/shell/split_status_bar_test.dart index c93bd678..89e4e810 100644 --- a/app/test/shell/split_status_bar_test.dart +++ b/app/test/shell/split_status_bar_test.dart @@ -162,8 +162,8 @@ void main() { expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); }); - testWidgets('$host split: the item tabs float above the shell tab bar ' - 'at the bottom right of the detail pane', (tester) async { + testWidgets('$host split: the item tabs sit at the bottom right of the ' + 'detail pane, the shell tab bar under the list', (tester) async { // A gesture-navigation inset as on the unfolded foldable. await setUp(tester, const Size(1200, 800), bottom: 24); await tester.pumpWidget(shell(cupertino, tabbedItem)); @@ -189,13 +189,16 @@ void main() { ) .first, ); - // The shell's bar keeps the bottom right, above the system inset; the - // item's tabs sit a gap above it, both at the trailing edge. + // Both bars sit above the system inset: the shell's under the list + // pane, the item's at the detail pane's trailing edge. + final listPane = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); expect(shellTabs.bottom, closeTo(800 - 24, 0.5)); - expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(shellTabs.right, lessThanOrEqualTo(listPane.right)); + expect(tabs.bottom, closeTo(800 - 24, 0.5)); expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); expect(shellTabs.overlaps(tabs), isFalse); - expect(shellTabs.top - tabs.bottom, closeTo(kStackedBarGap, 0.5)); // The item's list clears its tabs at rest. final list = tester.element(find.byKey(const Key('item-list'))); expect( diff --git a/app/test/ui/adaptive/floating_bar_geometry_test.dart b/app/test/ui/adaptive/floating_bar_geometry_test.dart index e5e7f54f..982227f1 100644 --- a/app/test/ui/adaptive/floating_bar_geometry_test.dart +++ b/app/test/ui/adaptive/floating_bar_geometry_test.dart @@ -192,6 +192,63 @@ void main() { }); } + for (final listWidth in [511.0, 300.0, 240.0]) { + testWidgets('$host: centred in a $listWidth list pane, the row keeps ' + 'the margins and the selected size', (tester) async { + // The shell's wide placement: under the list pane, centred in it. + await pump( + tester, + cupertino: cupertino, + size: const Size(1280, 800), + child: Align( + alignment: AlignmentDirectional.bottomStart, + child: SizedBox( + width: listWidth, + child: FloatingDestinationBar( + cupertino: cupertino, + currentIndex: 1, + onTap: (_) {}, + alignment: Alignment.bottomCenter, + items: [ + for (var index = 0; index < 4; index += 1) + FloatingDestinationItem( + key: tabKey(index), + icon: Icon(icons[index]), + label: 'Tab $index', + ), + ], + ), + ), + ), + ); + final box = row(tester); + expect(box.center.dx, moreOrLessEquals(listWidth / 2)); + // A squeezed row scales down about its centre, which stays put. + expect( + box.center.dy, + moreOrLessEquals( + 800 - + 16 - + FloatingDestinationBar.selectedButtonSize( + cupertino: cupertino, + ) / + 2, + ), + ); + expect(box.left, greaterThanOrEqualTo(16 - 0.01)); + expect(box.right, lessThanOrEqualTo(listWidth - 16 + 0.01)); + // The selected button keeps its larger size relative to the others. + expect( + button(tester, 1).width / button(tester, 0).width, + moreOrLessEquals( + FloatingDestinationBar.selectedButtonSize(cupertino: cupertino) / + diameter, + ), + ); + expect(tester.takeException(), isNull); + }); + } + testWidgets('$host: taps between and beside the buttons reach the ' 'content, taps on them the tabs', (tester) async { final tapped = [];