diff --git a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart index 0fa4d15e..4721ac5d 100644 --- a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart @@ -127,8 +127,8 @@ class _PipelineDetailPanelState extends State { final panel = LayoutBuilder( builder: (context, constraints) { final headerLimit = _headerLimit(constraints); - // The tabs float over the tab body: at the bottom on a phone page, - // under the pane's top bar beside a list (never on the shell's bar). + // The tabs float over the bottom of the tab body, on a phone page + // and beside a list alike (the shell's bar stays over the list). final edge = PageTabsEdge.of(context); final tabs = PipelineDetailTabs( selected: _tab, diff --git a/app/lib/features/pipelines/widgets/pipeline_tabs.dart b/app/lib/features/pipelines/widgets/pipeline_tabs.dart index f8783643..13ad4f5c 100644 --- a/app/lib/features/pipelines/widgets/pipeline_tabs.dart +++ b/app/lib/features/pipelines/widgets/pipeline_tabs.dart @@ -7,8 +7,9 @@ import 'pipeline_detail_tab.dart'; export 'pipeline_detail_tab.dart'; -/// The pipeline detail's tabs: the app's floating glass tab bar, full width on -/// a phone page; beside a list, sized to its tabs under the pane's top bar. +/// The pipeline detail's tabs: the app's floating glass tab bar at the bottom, +/// full width on a phone page; beside a list, sized to its tabs at the bottom +/// of the detail pane (the shell's tab bar stays over the list pane). /// /// Float it over the tab body with `FloatingBarOverlay`. The whole bar is /// keyed `pipeline-detail-tabs`, each tab `pipeline-detail-tab-`. 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 f70002d4..d3db9d27 100644 --- a/app/lib/features/runs/ui/run_detail_tab_strip.dart +++ b/app/lib/features/runs/ui/run_detail_tab_strip.dart @@ -18,8 +18,8 @@ const List renderedRunDetailTabs = [ ]; /// The run detail's tabs: the app's floating glass tab bar, full width at the -/// bottom of a phone page; beside a list, under the pane's top bar (sized to -/// its tabs) so it never stacks on the shell's own tab bar. +/// bottom of a phone page; beside a list, sized to its tabs at the bottom of +/// the detail pane (the shell's own tab bar stays over the list pane). /// /// Float it over the tab body with `FloatingBarOverlay` at the same [edge]; /// every tab is always visible, so a tab selected by the Graph is shown diff --git a/app/lib/features/runs/ui/run_detail_tabs.dart b/app/lib/features/runs/ui/run_detail_tabs.dart index 974afb4a..05836376 100644 --- a/app/lib/features/runs/ui/run_detail_tabs.dart +++ b/app/lib/features/runs/ui/run_detail_tabs.dart @@ -364,7 +364,7 @@ class _RunDetailTabsState extends State { // The header (status, actions, notices) is a glass strip floating // just under the top bar, so every tab scrolls behind both and pads // its first item clear of them at rest. Below it, the tabs float over - // the tab, at its bottom on a page or at its top beside a list, and + // the bottom of the tab (on a page and beside a list alike), and // the tab learns their height as its padding on that edge too. Every // tab gets the whole height: the scrolling tabs own their content and // the Graph tab fills the slot, so its canvas is never asked for an diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index cecaebb9..81ed392a 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -165,25 +165,34 @@ class _AdaptiveShellState extends State { split: split, bar: _segmentedBar(spec, details.label), ); + // The scaffolds below swap the system insets for their bars' + // heights; panes beside a list read the real ones from here. + final system = MediaQuery.paddingOf(context); if (widget.cupertino) { - return CupertinoPageScaffold( - navigationBar: topBar, - child: SafeArea( - top: false, - bottom: false, - child: FloatingBarOverlay( - bar: bar, - child: _destinationStack(contents, index), + return ShellSystemInsets( + padding: system, + child: CupertinoPageScaffold( + navigationBar: topBar, + child: SafeArea( + top: false, + bottom: false, + child: FloatingBarOverlay( + bar: bar, + child: _destinationStack(contents, index), + ), ), ), ); } - return Scaffold( - extendBodyBehindAppBar: true, - appBar: topBar, - body: _destinationStack(contents, index), - extendBody: true, - bottomNavigationBar: bar, + return ShellSystemInsets( + padding: system, + child: Scaffold( + extendBodyBehindAppBar: true, + appBar: topBar, + body: _destinationStack(contents, index), + extendBody: true, + bottomNavigationBar: bar, + ), ); }, ); diff --git a/app/lib/shell/list_detail.dart b/app/lib/shell/list_detail.dart index 0add8deb..c6f44de4 100644 --- a/app/lib/shell/list_detail.dart +++ b/app/lib/shell/list_detail.dart @@ -36,6 +36,33 @@ double listDetailBodyWidth(double window, double available) { double listDetailListWidth(double window, double available) => math.max(0, available - 1 - listDetailBodyWidth(window, available)); +/// The system's own insets (status bar, navigation bar) as the shell saw +/// them, before its scaffold replaced them with its bars' heights. +/// +/// A Material [Scaffold] with an app bar and a bottom bar removes the top and +/// bottom padding *and* view padding from its body, so a pane beside the list +/// cannot recover the status-bar inset from its own [MediaQuery]. The shell +/// publishes the insets here; outside a shell the view padding stands in. +class ShellSystemInsets extends InheritedWidget { + const ShellSystemInsets({ + super.key, + required this.padding, + required super.child, + }); + + final EdgeInsets padding; + + static EdgeInsets of(BuildContext context) => + context + .dependOnInheritedWidgetOfExactType() + ?.padding ?? + MediaQuery.viewPaddingOf(context); + + @override + bool updateShouldNotify(ShellSystemInsets oldWidget) => + padding != oldWidget.padding; +} + /// Narrows a shell bar to the list pane while [split] (the tab shows its list /// beside an open item), placing it at the pane's [alignment]; otherwise the /// bar keeps the whole width it is given. The bar keeps its place in the tree @@ -76,8 +103,8 @@ class ListPaneWidth extends StatelessWidget { /// Under the shell, the list keeps the shell's bars (both 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 and reaches the -/// bottom edge with only the system insets as its padding, and its own tabs -/// float at its top ([PageTabsEdge]). +/// bottom edge with only the system insets ([ShellSystemInsets]) as its +/// padding, and its own tabs float at its bottom, as on a phone. class ListDetailPanes extends StatelessWidget { const ListDetailPanes({super.key, required this.list, required this.detail}); @@ -103,19 +130,20 @@ class ListDetailPanes extends StatelessWidget { ); Widget body = detail; if (split) { - // Beside the list the item is not under the shell's bar: it keeps - // only the system's own inset and draws its bar at the top edge. - // The shell's destination bar stays over the list pane too, so the - // item keeps only the system's bottom inset: its own composer or - // controls own the pane's bottom edge. + // Beside the list the item is under neither of the shell's bars + // (both stay over the list pane): it keeps only the system's own + // insets, so its bar sits just below the status bar at the top + // edge, and its tabs or composer own the pane's bottom edge, + // floating just above the system inset. + final system = ShellSystemInsets.of(context); body = MediaQuery( data: media.copyWith( padding: media.padding.copyWith( - top: media.viewPadding.top, - bottom: media.viewPadding.bottom, + top: system.top, + bottom: system.bottom, ), ), - child: PageTabsEdge(edge: FloatingBarEdge.top, child: body), + child: PageTabsEdge(edge: FloatingBarEdge.bottom, child: body), ); } return Row( diff --git a/app/lib/ui/adaptive/floating_bar_layout.dart b/app/lib/ui/adaptive/floating_bar_layout.dart index c6b44a35..ed08aef4 100644 --- a/app/lib/ui/adaptive/floating_bar_layout.dart +++ b/app/lib/ui/adaptive/floating_bar_layout.dart @@ -112,19 +112,19 @@ class SliverFloatingBarClearance extends StatelessWidget { /// The edge a page's own floating tab bar sits at. enum FloatingBarEdge { - /// Above the bottom safe area: a phone page, or a page covering the shell. + /// Above the bottom safe area: a phone page, a page covering the shell, + /// or a detail pane beside a list (the shell's tab bar stays over the + /// list pane). bottom, - /// Just below the page's top bar: a detail pane beside a list, where the - /// shell's own tab bar already floats at the bottom. + /// Just below the page's top bar, for a surface whose bottom is taken. top, } /// Where the pages' own tab bars float in this subtree ([FloatingBarEdge]). /// -/// A detail pane beside a list says [FloatingBarEdge.top], so an open item's -/// tabs never stack on the shell's tab bar; everywhere else they float at the -/// bottom. +/// Pages float their tabs at the bottom (the default), including a detail +/// pane beside a list, whose bottom the shell leaves free. class PageTabsEdge extends InheritedWidget { const PageTabsEdge({super.key, required this.edge, required super.child}); diff --git a/app/notes/wide-shell-fixes.md b/app/notes/wide-shell-fixes.md index ad8277c6..b7e8896b 100644 --- a/app/notes/wide-shell-fixes.md +++ b/app/notes/wide-shell-fixes.md @@ -31,6 +31,46 @@ run and pipeline detail content. no split (Settings, Search, Schedules, Templates) it is compact and right-aligned. `floating_destination_bar.dart` needed no change. +## Detail tabs at the bottom (operator request) + +Beside a list, run and pipeline detail used to float their tabs at the top +of the pane, under its bar (`PageTabsEdge(top)` from +`notes/app-chrome-fixes.md`). The shell's tab bar now stays over the list +pane, which leaves the detail pane's bottom free. So `ListDetailPanes` now +says `PageTabsEdge(edge: FloatingBarEdge.bottom)`, and the item's tabs float +at the bottom of the detail pane, the same as on a phone page: + +- At 1200 and 1600 they are sized to their tabs and sit at the pane's + trailing edge. +- They sit 16 above the system inset. +- The content pads its last item clear of them. + +The chat composer owns the chat pane's bottom in the same way. No pill sits +on top of another pill. The stage page is always a pushed page, so its tabs +were already at the bottom. `FloatingBarEdge.top` remains in the layout +primitives, but nothing in the app uses it now. + +## Status-bar inset in the detail pane (unfolded foldable) + +On the Pixel Fold, the right pane drew its bar (chat header, run detail bar) +under the status bar. The cause is that a Material `Scaffold` with an +`appBar` and a `bottomNavigationBar` removes the top and bottom padding +*and view padding* from its body. `ListDetailPanes` rebuilt the detail's +insets from `viewPadding`, and inside the Material shell that is zero. +Cupertino was unaffected. + +The fix is in two places: + +- The shell publishes the system insets it saw before its scaffold: + `ShellSystemInsets` in `list_detail.dart`, set in `adaptive_shell.dart` + from `MediaQuery.paddingOf`. +- `ListDetailPanes` gives the detail exactly those insets at the top and + bottom. Outside a shell, `viewPadding` stands in. + +The list side keeps the shell bar's height, so it was already correct. +Headless Chrome has no status bar, so this is covered by widget tests only. +It has not been verified on a device. + ## P2-9: Schedules on a wide window - The strip (`schedule_list_toolbar.dart`) now holds the field and the filter, @@ -88,6 +128,14 @@ New: - At 1200 unsplit, the pill is compact at the right edge. - At 390, the pill spans the phone. - At 600 and 840 split with 2x text, there is no overflow. +- `test/shell/split_status_bar_test.dart` covers both hosts at 1200 with a + 40px status bar (`tester.view.padding` and `viewPadding`): + - The list bar, the detail pane bar and a self-drawn header (like the + chat thread's `SegmentedBarOverlay`) all start at y ≥ 40. + - The list and the item content still start at y=0. + - The item tabs float at the pane's bottom, inside the detail pane, and do + not overlap the shell tabs; the list clears them. + - Before the fix, Material failed with the bar at y=8. - `test/ui/layout/reading_width_test.dart`: - The cap applies from the leading edge, and the body is not remounted across the cap. @@ -107,6 +155,8 @@ Updated: - The pipelines tests (placeholder wording). - `chat_list_detail_test.dart`, `pipelines_screen_test.dart` and `runs_screen_test.dart` now assert `EmptyDetailPane`. +- `pane_bar_row_test.dart`: the item tabs are now at the bottom of the pane + (they were under the pane bar). - `run_detail_tabs_test.dart`: at 1000 the Summary body is now `kReadingMaxWidth` wide from x=0 instead of spanning the window. diff --git a/app/test/shell/pane_bar_row_test.dart b/app/test/shell/pane_bar_row_test.dart index ca48d31b..2f24dfef 100644 --- a/app/test/shell/pane_bar_row_test.dart +++ b/app/test/shell/pane_bar_row_test.dart @@ -12,7 +12,8 @@ import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; /// Beside a list each pane owns its bar on one shared top row, and an open -/// item's tabs never stack on the shell's tab bar at the bottom. +/// item's tabs float at the bottom of its own pane, beside (never on) the +/// shell's tab bar over the list. void main() { Future setSize(WidgetTester tester, Size size) async { tester.view.physicalSize = size; @@ -149,18 +150,20 @@ void main() { expect(find.text('Its context'), findsOneWidget); }); - testWidgets('$host 1200: the item\'s tabs float under its bar, not on ' - 'the shell\'s tab bar', (tester) async { + testWidgets('$host 1200: the item\'s tabs float at the bottom of its ' + 'pane, beside the shell\'s tab bar', (tester) async { await setSize(tester, const Size(1200, 800)); await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pump(); await tester.pump(); final shellTabs = tester.getRect( - find.descendant( - of: find.byKey(const ValueKey('shell.destination.runs')).first, - matching: find.byType(Icon), - ), + find + .ancestor( + of: find.byKey(const ValueKey('shell.destination.runs')).first, + matching: find.byType(GlassPill), + ) + .first, ); final itemTabs = tester.getRect( find.descendant( @@ -168,16 +171,26 @@ void main() { matching: find.byType(GlassPill), ), ); + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + // Near the bottom of the detail pane, never on the shell's tabs. + expect(itemTabs.bottom, closeTo(800 - 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. final paneBarPill = tester.getRect( find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first, ); - expect(itemTabs.top, greaterThanOrEqualTo(paneBarPill.bottom)); - expect(itemTabs.top, lessThan(200)); - expect(itemTabs.bottom, lessThan(shellTabs.top - 100)); - // The item's list starts below its tabs at rest. expect( tester.getTopLeft(find.text('item row 0')).dy, - greaterThanOrEqualTo(itemTabs.bottom), + greaterThanOrEqualTo(paneBarPill.bottom), + ); + expect( + MediaQuery.paddingOf( + tester.element(find.byKey(const Key('item-list'))), + ).bottom, + greaterThanOrEqualTo(800 - itemTabs.top), ); }); } diff --git a/app/test/shell/split_status_bar_test.dart b/app/test/shell/split_status_bar_test.dart new file mode 100644 index 00000000..299204b8 --- /dev/null +++ b/app/test/shell/split_status_bar_test.dart @@ -0,0 +1,191 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +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/detail_page.dart'; +import 'package:pipelines_app/shell/list_detail.dart'; +import 'package:pipelines_app/shell/shell_bar.dart'; +import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart'; +import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart'; + +/// On a wide split window (an unfolded foldable) under a system status bar, +/// every pane's bar sits below the status-bar inset while content still +/// reaches the top edge; and the open item's tabs float at the bottom of the +/// detail pane, beside (never on) the shell's tab bar over the list. +void main() { + const statusBar = 40.0; + + Future setUp(WidgetTester tester, Size size) async { + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1; + tester.view.padding = const FakeViewPadding(top: statusBar); + tester.view.viewPadding = const FakeViewPadding(top: statusBar); + addTearDown(tester.view.reset); + } + + List rows(String label) => [ + for (var index = 0; index < 40; index++) + SizedBox(height: 40, child: Text('$label $index')), + ]; + + /// An item publishing its bar to the pane, with its own floating tabs + /// placed where the pane says (like run and pipeline detail). + Widget tabbedItem(bool cupertino) => ShellBar( + title: 'Open item', + child: Builder( + builder: (context) { + final edge = PageTabsEdge.of(context); + return FloatingBarOverlay( + edge: edge, + bar: KeyedSubtree( + key: const Key('item-tabs'), + child: FloatingDestinationBar( + cupertino: cupertino, + edge: edge, + currentIndex: 0, + onTap: (_) {}, + items: const [ + FloatingDestinationItem(icon: Icon(Icons.notes), label: 'One'), + FloatingDestinationItem(icon: Icon(Icons.share), label: 'Two'), + ], + ), + ), + child: Builder( + builder: (context) => ListView( + key: const Key('item-list'), + padding: withBarClearance(context, EdgeInsets.zero), + children: rows('item'), + ), + ), + ); + }, + ), + ); + + /// An item drawing its own header over itself (like the chat thread). + Widget overlayItem(bool cupertino) => ShellBar( + barless: true, + child: SegmentedBarOverlay( + bar: SegmentedBar( + key: const Key('own-header'), + cupertino: cupertino, + automaticallyImplyLeading: false, + title: 'Own header', + ), + child: ListView(key: const Key('item-list'), children: rows('item')), + ), + ); + + Widget shell(bool cupertino, Widget Function(bool) item) { + final app = AdaptiveShell( + cupertino: cupertino, + destination: AppDestination.runs, + destinationBodies: { + AppDestination.runs: (_) => ListDetailPanes( + list: ShellBar( + child: ListView(key: const Key('list'), children: rows('list')), + ), + detail: DetailPane( + destination: AppDestination.runs, + implyBack: false, + builder: (_) => item(cupertino), + ), + ), + }, + ); + return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app); + } + + Iterable pillsOf(WidgetTester tester, Finder bar) => find + .descendant(of: bar, matching: find.byType(GlassPill)) + .evaluate() + .map((element) { + final box = element.renderObject! as RenderBox; + return box.localToGlobal(Offset.zero) & box.size; + }); + + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + + testWidgets('$host split under a status bar: list and pane bars sit ' + 'below it, content reaches the top edge', (tester) async { + await setUp(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(cupertino, tabbedItem)); + await tester.pump(); + await tester.pump(); + + final listBar = find.byWidgetPredicate( + (widget) => widget is SegmentedBar && widget.title == 'Runs', + ); + final paneBar = find.byWidgetPredicate( + (widget) => widget is SegmentedBar && widget.title == 'Open item', + ); + for (final bar in [listBar, paneBar]) { + final pills = pillsOf(tester, bar); + expect(pills, isNotEmpty); + for (final pill in pills) { + expect(pill.top, greaterThanOrEqualTo(statusBar)); + } + } + // Content may still extend under the bars and the status bar. + expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0); + expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); + // At rest the first rows start below the bars. + final paneBottom = pillsOf(tester, paneBar).first.bottom; + expect( + tester.getTopLeft(find.text('item 0')).dy, + greaterThanOrEqualTo(paneBottom), + ); + }); + + testWidgets('$host split under a status bar: a self-drawn header (chat) ' + 'sits below it', (tester) async { + await setUp(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(cupertino, overlayItem)); + await tester.pump(); + await tester.pump(); + final pills = pillsOf(tester, find.byKey(const Key('own-header'))); + expect(pills, isNotEmpty); + for (final pill in pills) { + expect(pill.top, greaterThanOrEqualTo(statusBar)); + } + expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0); + }); + + testWidgets('$host split: the item tabs float at the bottom of the ' + 'detail pane, beside the shell tab bar over the list', (tester) async { + await setUp(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(cupertino, tabbedItem)); + await tester.pump(); + await tester.pump(); + + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + final tabs = pillsOf(tester, find.byKey(const Key('item-tabs'))).single; + expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(tabs.left, greaterThanOrEqualTo(body.left)); + expect(tabs.right, lessThanOrEqualTo(body.right)); + final shellTabs = tester.getRect( + find + .ancestor( + of: find.byKey(const ValueKey('shell.destination.runs')).first, + matching: find.byType(GlassPill), + ) + .first, + ); + expect(shellTabs.overlaps(tabs), isFalse); + expect(shellTabs.right, lessThanOrEqualTo(body.left)); + // The item's list clears its tabs at rest. + final list = tester.element(find.byKey(const Key('item-list'))); + expect( + MediaQuery.paddingOf(list).bottom, + greaterThanOrEqualTo(800 - tabs.top), + ); + }); + } +}