From 2c4c4891eab55c55cea34b3c6bfb626d9d7aeda1 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 31 Oct 2026 12:09:47 +0000 Subject: [PATCH 1/3] Keep the shell tab bar over the list pane on wide splits; cap schedules and reading bodies; share the empty-pane placeholder --- app/lib/features/chat/screen.dart | 31 +--- .../widgets/pipeline_detail_panel.dart | 27 +++- app/lib/features/runs/screen.dart | 24 +-- app/lib/features/runs/ui/run_detail_tabs.dart | 11 +- .../features/runs/ui/run_detail_visit.dart | 34 ++-- .../ui/list/schedule_list_toolbar.dart | 115 +++++++------ .../schedules/ui/list/schedule_list_view.dart | 54 +++++-- app/lib/shell/adaptive_shell.dart | 39 +++-- app/lib/shell/empty_detail_pane.dart | 49 ++++++ app/lib/shell/list_detail.dart | 52 +++++- app/lib/ui/layout/reading_width.dart | 40 +++++ app/notes/wide-shell-fixes.md | 124 ++++++++++++++ .../features/chat/chat_list_detail_test.dart | 6 +- .../pipelines/pipeline_deep_link_test.dart | 4 +- .../pipelines_screen_filter_test.dart | 2 +- .../pipelines/pipelines_screen_test.dart | 9 +- .../runs/ui/run_detail_tabs_test.dart | 7 +- .../features/runs/ui/runs_screen_test.dart | 6 + .../ui/list/schedule_screen_harness.dart | 3 +- .../ui/list/schedules_layout_test.dart | 4 +- .../ui/list/schedules_wide_test.dart | 46 ++++++ app/test/shell/empty_detail_pane_test.dart | 52 ++++++ .../shell/split_destination_bar_test.dart | 151 ++++++++++++++++++ app/test/ui/layout/reading_width_test.dart | 115 +++++++++++++ 24 files changed, 851 insertions(+), 154 deletions(-) create mode 100644 app/lib/shell/empty_detail_pane.dart create mode 100644 app/lib/ui/layout/reading_width.dart create mode 100644 app/notes/wide-shell-fixes.md create mode 100644 app/test/features/schedules/ui/list/schedules_wide_test.dart create mode 100644 app/test/shell/empty_detail_pane_test.dart create mode 100644 app/test/shell/split_destination_bar_test.dart create mode 100644 app/test/ui/layout/reading_width_test.dart diff --git a/app/lib/features/chat/screen.dart b/app/lib/features/chat/screen.dart index b8aa6b5a..c8049662 100644 --- a/app/lib/features/chat/screen.dart +++ b/app/lib/features/chat/screen.dart @@ -1,7 +1,7 @@ import '../../shell/destination.dart'; import '../../shell/detail_page.dart'; +import '../../shell/empty_detail_pane.dart'; import '../../shell/list_detail.dart'; -import '../../ui/adaptive/host.dart'; import 'dart:async'; import 'package:flutter/cupertino.dart'; @@ -257,7 +257,10 @@ class _ChatScreenState extends State { return ListDetailPanes( list: list, detail: selected == null - ? const _NoChatSelected() + ? const EmptyDetailPane( + destination: AppDestination.chat, + message: 'Select a chat to open it here.', + ) : DetailPane( key: const ValueKey('chat-detail-pane'), destination: AppDestination.chat, @@ -267,27 +270,3 @@ class _ChatScreenState extends State { ); } } - -/// The open-chat pane before any chat is chosen. -class _NoChatSelected extends StatelessWidget { - const _NoChatSelected(); - - @override - Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); - return Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - cupertino - ? CupertinoIcons.chat_bubble_2 - : Icons.chat_bubble_outline, - ), - const SizedBox(height: 12), - const Text('Select a chat to open it here.'), - ], - ), - ); - } -} diff --git a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart index e493448d..0fa4d15e 100644 --- a/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_detail_panel.dart @@ -4,8 +4,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; +import '../../../shell/destination.dart'; +import '../../../shell/empty_detail_pane.dart'; import '../../../shell/shell_bar.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; +import '../../../ui/layout/reading_width.dart'; import '../../graph/domain/graph_definition.dart'; import '../../graph/widgets/stage_definition_view.dart'; import '../pipeline_models.dart'; @@ -302,16 +305,26 @@ class _PipelineDetailPanelState extends State { ); } - Widget _scrolling(Widget child) => - ListView(children: [child, const SizedBox(height: 24)]); + /// A scrolling reading body: the whole pane scrolls, the content keeps + /// [kReadingMaxWidth] from the leading edge. + Widget _scrolling(Widget child) => ListView( + children: [ + Align( + alignment: AlignmentDirectional.topStart, + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: kReadingMaxWidth), + child: child, + ), + ), + const SizedBox(height: 24), + ], + ); Widget _withoutDetail(BuildContext context) { if (!_controller.hasSelection) { - return Center( - child: Padding( - padding: const EdgeInsets.all(24), - child: Text('Select a pipeline.', style: pipelineMutedStyle(context)), - ), + return const EmptyDetailPane( + destination: AppDestination.pipelines, + message: 'Select a pipeline to open it here.', ); } return ListView( diff --git a/app/lib/features/runs/screen.dart b/app/lib/features/runs/screen.dart index 36daae71..805044a3 100644 --- a/app/lib/features/runs/screen.dart +++ b/app/lib/features/runs/screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart'; import '../../core/api_gateway.dart'; import '../../shell/destination.dart'; import '../../shell/detail_page.dart'; +import '../../shell/empty_detail_pane.dart'; import '../../shell/list_detail.dart'; import '../../ui/adaptive/host.dart'; import '../attention/notify/notification_controller.dart'; @@ -262,15 +263,15 @@ class _RunsScreenState extends State { animation: controller, builder: (context, _) => ContentWidth( child: RunsList( - active: narrow ? !selected : true, - controller: controller, - onSelected: _select, - syncToken: widget.syncToken, - attentionStore: widget.attentionStore, - attentionNow: widget.attentionNow, - notifications: widget.notifications, - attention: widget.attention, - ), + active: narrow ? !selected : true, + controller: controller, + onSelected: _select, + syncToken: widget.syncToken, + attentionStore: widget.attentionStore, + attentionNow: widget.attentionNow, + notifications: widget.notifications, + attention: widget.attention, + ), ), ); if (narrow) return list; @@ -283,7 +284,10 @@ class _RunsScreenState extends State { implyBack: false, builder: (_) => _detail(_back), ) - : const Center(child: Text('Select a run to open it here.')), + : const EmptyDetailPane( + destination: AppDestination.runs, + message: 'Select a run to open it here.', + ), ); } } diff --git a/app/lib/features/runs/ui/run_detail_tabs.dart b/app/lib/features/runs/ui/run_detail_tabs.dart index 1daffb40..974afb4a 100644 --- a/app/lib/features/runs/ui/run_detail_tabs.dart +++ b/app/lib/features/runs/ui/run_detail_tabs.dart @@ -1,6 +1,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart'; import '../../../ui/adaptive/segmented_bar.dart'; import '../../../ui/adaptive/top_glass_strip.dart'; +import '../../../ui/layout/reading_width.dart'; import 'dart:math' as math; import 'package:flutter/cupertino.dart'; @@ -392,7 +393,15 @@ class _RunDetailTabsState extends State { selected: shown, onSelected: (tab) => setState(() => _tab = tab), ), - child: _body(shown), + // Reading tabs keep a readable width on a wide window; + // canvases, viewers and the gallery keep the whole pane. + child: switch (shown) { + RunDetailTab.summary || + RunDetailTab.input || + RunDetailTab.output || + RunDetailTab.timeline => ReadingWidth(child: _body(shown)), + _ => _body(shown), + }, ), ), ); diff --git a/app/lib/features/runs/ui/run_detail_visit.dart b/app/lib/features/runs/ui/run_detail_visit.dart index 49446124..c279adbb 100644 --- a/app/lib/features/runs/ui/run_detail_visit.dart +++ b/app/lib/features/runs/ui/run_detail_visit.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; +import '../../../ui/layout/reading_width.dart'; import 'run_detail_content.dart'; import 'run_detail_visit_facts_view.dart'; import 'run_detail_visit_sections.dart'; @@ -72,22 +73,31 @@ class _RunVisitPaneState extends State { selected: _section, onSelected: (section) => setState(() => _section = section), ), - child: runVisitSectionBody( - section: _section, - run: widget.run, - step: widget.step, - visitIndex: widget.visitIndex, - stageKey: widget.visit.stage, - runSteps: widget.runSteps, - gateway: widget.gateway, - onRunChanged: widget.onRunChanged, - configuredEndpoint: widget.configuredEndpoint, - cupertino: widget.cupertino, - facts: RunVisitFactsView(step: widget.step), + // Reading sections keep a readable width on a wide window; the + // gallery and the changes viewer keep the whole page. + child: _capped( + runVisitSectionBody( + section: _section, + run: widget.run, + step: widget.step, + visitIndex: widget.visitIndex, + stageKey: widget.visit.stage, + runSteps: widget.runSteps, + gateway: widget.gateway, + onRunChanged: widget.onRunChanged, + configuredEndpoint: widget.configuredEndpoint, + cupertino: widget.cupertino, + facts: RunVisitFactsView(step: widget.step), + ), ), ), ); } + + Widget _capped(Widget body) => switch (_section) { + RunVisitSection.artifacts || RunVisitSection.changes => body, + _ => ReadingWidth(child: body), + }; } /// The page bar's subtitle for a recorded visit: its sequence, then the run diff --git a/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart b/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart index 2a4e0d9b..78a52283 100644 --- a/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart +++ b/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart @@ -9,6 +9,10 @@ const scheduleSearchFieldKey = ValueKey('schedule-search-field'); const scheduleFilterKey = ValueKey('schedule-filter'); const scheduleRefreshKey = ValueKey('schedule-refresh'); +/// The strip width (inside its padding) from which the field, filter and +/// count share one row. +const double kScheduleToolbarRowWidth = 520; + /// Refresh for the list, as a bar action: the platform's activity indicator /// in the same touch target while a read is in flight. class ScheduleRefreshAction extends StatelessWidget { @@ -36,9 +40,12 @@ class ScheduleRefreshAction extends StatelessWidget { ); } -/// Search and the enabled filter, and the count; the refresh control too when -/// no bar above carries it ([onRefresh] null leaves it to the bar). The list -/// floats it as a glass strip under the page's bar. +/// Search and the enabled filter, with the count as a muted label; the +/// refresh control too when no bar above carries it ([onRefresh] null leaves +/// it to the bar). The list floats it as a glass strip under the page's bar. +/// +/// On a strip at least [kScheduleToolbarRowWidth] wide everything shares one +/// row; narrower, the field takes its own row above the filter and count. class ScheduleListToolbar extends StatelessWidget { const ScheduleListToolbar({ super.key, @@ -55,57 +62,60 @@ class ScheduleListToolbar extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(12, 12, 12, 8), - child: _search(context), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: Row( - children: [ - Expanded( - child: Align( - alignment: AlignmentDirectional.centerStart, - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 480), - child: _filter(context), - ), - ), - ), - if (onRefresh case final refresh?) ...[ - const SizedBox(width: 8), - ScheduleRefreshAction( - controller: controller, - cupertino: cupertino, - onRefresh: refresh, - ), - ], - ], - ), - ), - if (controller.hasLoaded) - Padding( - padding: const EdgeInsets.fromLTRB(12, 8, 12, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(controller.countLabel, style: _metaStyle(context)), - Text( - 'Saved run configurations, not pipeline definitions.', - style: _metaStyle(context), - ), - ], + return Padding( + padding: const EdgeInsets.all(12), + child: LayoutBuilder( + builder: (context, constraints) { + final refresh = switch (onRefresh) { + final refresh? => ScheduleRefreshAction( + controller: controller, + cupertino: cupertino, + onRefresh: refresh, ), - ), - const SizedBox(height: 12), - ], + null => null, + }; + if (constraints.maxWidth >= kScheduleToolbarRowWidth) { + return Row( + children: [ + Expanded(child: _search(context)), + const SizedBox(width: 12), + _filter(context), + const SizedBox(width: 12), + Flexible(child: _count(context)), + if (refresh != null) ...[const SizedBox(width: 8), refresh], + ], + ); + } + // Narrow: the count follows the filter, and wraps under it when + // large text leaves no room beside it. + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _search(context), + const SizedBox(height: 8), + Wrap( + spacing: 12, + runSpacing: 8, + crossAxisAlignment: WrapCrossAlignment.center, + children: [_filter(context), _count(context), ?refresh], + ), + ], + ); + }, + ), ); } + /// The count, muted; empty space until the first read lands so the + /// strip keeps its size. + Widget _count(BuildContext context) => Text( + controller.hasLoaded ? controller.countLabel : '', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: _metaStyle(context), + ); + Widget _search(BuildContext context) => AppSearchField( fieldKey: scheduleSearchFieldKey, controller: searchController, @@ -150,10 +160,11 @@ class ScheduleListToolbar extends StatelessWidget { } TextStyle? _metaStyle(BuildContext context) => cupertino - ? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith( + ? CupertinoTheme.of(context).textTheme.textStyle.copyWith( + fontSize: 15, color: CupertinoColors.secondaryLabel.resolveFrom(context), ) - : Theme.of(context).textTheme.bodySmall?.copyWith( + : Theme.of(context).textTheme.bodyMedium?.copyWith( color: Theme.of(context).colorScheme.onSurfaceVariant, ); } diff --git a/app/lib/features/schedules/ui/list/schedule_list_view.dart b/app/lib/features/schedules/ui/list/schedule_list_view.dart index 435fd12b..ff376840 100644 --- a/app/lib/features/schedules/ui/list/schedule_list_view.dart +++ b/app/lib/features/schedules/ui/list/schedule_list_view.dart @@ -13,9 +13,13 @@ const scheduleListKey = ValueKey('schedule-list'); const scheduleRetryKey = ValueKey('schedule-retry'); const scheduleToolbarKey = ValueKey('schedule-toolbar'); -/// The widest the search and filter strip grows on a wide window. +/// The widest the search and filter strip grows on a wide window. The rows +/// share its width, so a row's time ends under the strip's trailing edge. const double kScheduleToolbarMaxWidth = 720; +/// The widest a row grows: the strip plus its 12px leading inset. +const double kScheduleListMaxWidth = kScheduleToolbarMaxWidth + 12; + /// Platform-adaptive list body. It owns no navigation chrome; the shell frames /// it as the Schedules destination. /// @@ -74,7 +78,12 @@ class SchedulesListView extends StatelessWidget { return BelowTopBar(child: _loadingState(context)); } if (controller.schedules.isEmpty) { - return BelowTopBar(child: _emptyState('No schedules yet.')); + return BelowTopBar( + child: _emptyState( + 'No schedules yet.', + detail: 'Saved run configurations, not pipeline definitions.', + ), + ); } final content = controller.visibleSchedules.isEmpty ? BelowTopBar(child: _emptyState(controller.emptyMessage)) @@ -100,14 +109,20 @@ class SchedulesListView extends StatelessWidget { itemCount: schedules.length, itemBuilder: (context, index) { final schedule = schedules[index]; - return ScheduleListRow( - key: ValueKey( - 'schedule-row-$index-${schedule.id ?? 'unknown'}', + return Align( + alignment: AlignmentDirectional.centerStart, + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: kScheduleListMaxWidth), + child: ScheduleListRow( + key: ValueKey( + 'schedule-row-$index-${schedule.id ?? 'unknown'}', + ), + schedule: schedule, + cupertino: cupertino, + divider: index < schedules.length - 1, + onOpen: () => onOpen(schedule), + ), ), - schedule: schedule, - cupertino: cupertino, - divider: index < schedules.length - 1, - onOpen: () => onOpen(schedule), ); }, ); @@ -132,11 +147,28 @@ class SchedulesListView extends StatelessWidget { ); } - Widget _emptyState(String message) { + Widget _emptyState(String message, {String? detail}) { return Center( child: Padding( padding: const EdgeInsets.all(24), - child: Text(message, textAlign: TextAlign.center), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(message, textAlign: TextAlign.center), + if (detail != null) + Builder( + builder: (context) => Text( + detail, + textAlign: TextAlign.center, + style: TextStyle( + color: cupertino + ? CupertinoColors.secondaryLabel.resolveFrom(context) + : Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ), + ], + ), ), ); } diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index eb03c8a7..cecaebb9 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -143,17 +143,26 @@ class _AdaptiveShellState extends State { // 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. - final bar = FloatingDestinationBar( - cupertino: widget.cupertino, - currentIndex: index, - onTap: (value) => _select(AppDestination.values[value]), - items: _destinationItems(), + // + // While the tab shows its list beside an open item, the bar floats + // over the list pane only (judging its placement on that width), so + // it never covers the item or stacks on the item's own composer. + final split = _bar.split(_selected); + final bar = ListPaneWidth( + split: split, + alignment: AlignmentDirectional.bottomStart, + child: FloatingDestinationBar( + cupertino: widget.cupertino, + currentIndex: index, + onTap: (value) => _select(AppDestination.values[value]), + items: _destinationItems(), + ), ); // 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 // pads its own lists by it (see withTopBarClearance). final topBar = _ListPaneBar( - split: _bar.split(_selected), + split: split, bar: _segmentedBar(spec, details.label), ); if (widget.cupertino) { @@ -277,19 +286,9 @@ class _ListPaneBar extends StatelessWidget bar.shouldFullyObstruct(context); @override - Widget build(BuildContext context) => LayoutBuilder( - builder: (context, constraints) { - final width = split - ? listDetailListWidth( - MediaQuery.sizeOf(context).width, - constraints.maxWidth, - ) - : constraints.maxWidth; - return Align( - alignment: AlignmentDirectional.topStart, - heightFactor: 1, - child: SizedBox(width: width, child: bar), - ); - }, + Widget build(BuildContext context) => ListPaneWidth( + split: split, + alignment: AlignmentDirectional.topStart, + child: bar, ); } diff --git a/app/lib/shell/empty_detail_pane.dart b/app/lib/shell/empty_detail_pane.dart new file mode 100644 index 00000000..935718f3 --- /dev/null +++ b/app/lib/shell/empty_detail_pane.dart @@ -0,0 +1,49 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import '../ui/adaptive/host.dart'; +import 'destination.dart'; + +/// The detail pane beside a list before anything is chosen: the +/// destination's own icon above one short muted line, centred. One look for +/// Runs, Chat and Pipelines. +class EmptyDetailPane extends StatelessWidget { + const EmptyDetailPane({ + super.key, + required this.destination, + required this.message, + }); + + final AppDestination destination; + final String message; + + @override + Widget build(BuildContext context) { + final cupertino = usesCupertinoHost(context); + final details = destinationDetails(destination); + final color = cupertino + ? CupertinoColors.secondaryLabel.resolveFrom(context) + : Theme.of(context).colorScheme.onSurfaceVariant; + return Center( + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + cupertino ? details.cupertinoIcon : details.icon, + size: 32, + color: color, + ), + const SizedBox(height: 12), + Text( + message, + textAlign: TextAlign.center, + style: TextStyle(color: color), + ), + ], + ), + ), + ); + } +} diff --git a/app/lib/shell/list_detail.dart b/app/lib/shell/list_detail.dart index 8873294c..0add8deb 100644 --- a/app/lib/shell/list_detail.dart +++ b/app/lib/shell/list_detail.dart @@ -36,14 +36,48 @@ double listDetailBodyWidth(double window, double available) { double listDetailListWidth(double window, double available) => math.max(0, available - 1 - listDetailBodyWidth(window, available)); +/// 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 +/// either way, so a split never remounts it. +class ListPaneWidth extends StatelessWidget { + const ListPaneWidth({ + super.key, + required this.split, + required this.alignment, + required this.child, + }); + + final bool split; + final AlignmentGeometry alignment; + final Widget child; + + @override + Widget build(BuildContext context) => LayoutBuilder( + builder: (context, constraints) { + final width = split + ? listDetailListWidth( + MediaQuery.sizeOf(context).width, + constraints.maxWidth, + ) + : constraints.maxWidth; + return Align( + alignment: alignment, + heightFactor: 1, + child: SizedBox(width: width, child: child), + ); + }, + ); +} + /// One body-priority policy for all destinations, derived from the full window /// and actual available space after navigation. No fixed pixel pane widths. /// -/// Under the shell, the list keeps the shell's bar (narrowed to the list pane -/// through [ShellPaneSplit]) and the open item owns the rest of the top row: -/// the detail starts at the top edge with only the system inset as its top -/// padding, and its own tabs float at its top ([PageTabsEdge]) so they never -/// stack on the shell's tab bar at the bottom. +/// 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]). class ListDetailPanes extends StatelessWidget { const ListDetailPanes({super.key, required this.list, required this.detail}); @@ -71,9 +105,15 @@ class ListDetailPanes extends StatelessWidget { 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. body = MediaQuery( data: media.copyWith( - padding: media.padding.copyWith(top: media.viewPadding.top), + padding: media.padding.copyWith( + top: media.viewPadding.top, + bottom: media.viewPadding.bottom, + ), ), child: PageTabsEdge(edge: FloatingBarEdge.top, child: body), ); diff --git a/app/lib/ui/layout/reading_width.dart b/app/lib/ui/layout/reading_width.dart new file mode 100644 index 00000000..86b50800 --- /dev/null +++ b/app/lib/ui/layout/reading_width.dart @@ -0,0 +1,40 @@ +import 'dart:math' as math; + +import 'package:flutter/widgets.dart'; + +/// The widest a detail's reading body (a run or pipeline Summary, a stage +/// page's sections) grows on a wide window, so its text, trailing copy +/// buttons and facts stay within reach of the title instead of stretching +/// to the window's far edge. +const double kReadingMaxWidth = 840; + +/// Caps [child] at [maxWidth] from the leading edge, where the detail's bar +/// pieces, header strip and tabs start. It passes the full height through +/// unchanged, so a scrollable child fills the height as before; only its +/// width is capped. +class ReadingWidth extends StatelessWidget { + const ReadingWidth({ + super.key, + required this.child, + this.maxWidth = kReadingMaxWidth, + }); + + final Widget child; + final double maxWidth; + + @override + Widget build(BuildContext context) => LayoutBuilder( + // One structure at every width, so resizing across the cap never + // remounts the body (its scroll offset and open sections stay). + builder: (context, constraints) { + return Align( + alignment: AlignmentDirectional.topStart, + child: SizedBox( + width: math.min(maxWidth, constraints.maxWidth), + height: constraints.hasBoundedHeight ? constraints.maxHeight : null, + child: child, + ), + ); + }, + ); +} diff --git a/app/notes/wide-shell-fixes.md b/app/notes/wide-shell-fixes.md new file mode 100644 index 00000000..d37bd758 --- /dev/null +++ b/app/notes/wide-shell-fixes.md @@ -0,0 +1,124 @@ +# Wide shell fixes (review round 2, batches A + K) + +From the second independent review (`/tmp/app-style-review-r2/report-summary.md`): +P1-1, P2-9, P3-6 and P3-14. Follows `notes/app-chrome-fixes.md` and +`notes/floating-tab-bars.md`. + +## P1-1: the destination bar stays over the list pane + +On a wide split window the shell's `FloatingDestinationBar` was laid out over +the whole window and right-aligned, so it sat over the detail pane. There it +stacked with the chat composer (two glass pills bottom-right) and covered the +run and pipeline detail content. + +- `ListPaneWidth` (`lib/shell/list_detail.dart`) narrows a shell bar to the + list pane (`listDetailListWidth`, the split math the panes use) while the + tab is split (`ShellPaneSplit`). It is placed at the pane's leading edge. + When nothing is split it passes the whole width through. The widget tree + is the same either way, so a split never remounts the bar. +- The shell (`lib/shell/adaptive_shell.dart`) wraps both bars in it: the top + bar (`_ListPaneBar`, which used to inline the same math) and the + destination bar (bottom-start). +- The destination bar still judges its own placement on the width it is + given. At 1200 the list pane is 479 wide, so the pill spans the pane minus + 16 per side. At 1600 the pane is 639 wide, so the pill is compact and + right-aligned within the pane. It never crosses into the detail. +- `ListDetailPanes` gives the detail pane only the system bottom inset + (`viewPadding.bottom`), in addition to the top inset it already had. The + composer, or any other bottom control, owns the pane's bottom edge. The + list keeps the bar's height as its bottom padding. +- Unchanged: on phones the bar spans the full width, and on wide windows with + no split (Settings, Search, Schedules, Templates) it is compact and + right-aligned. `floating_destination_bar.dart` needed no change. + +## P2-9: Schedules on a wide window + +- The strip (`schedule_list_toolbar.dart`) now holds the field and the filter, + with the count as a muted label (Material `bodyMedium` / + `onSurfaceVariant`, Cupertino 15pt `secondaryLabel`). The helper paragraph + "Saved run configurations, not pipeline definitions." has moved to the + empty state (`No schedules yet.` keeps its own text). +- If the strip is at least `kScheduleToolbarRowWidth` (520) wide, everything + sits on one row. On narrower strips the field takes the first row, and the + filter and count wrap below it (`Wrap`, so 2x text never overflows). +- Rows are capped at `kScheduleListMaxWidth` (the strip's 720 plus its 12 + inset) from the leading edge, so a row's trailing time ends under the + strip's trailing edge. The `ListView` still spans the pane, so the whole + area scrolls. + +## P3-6: one empty-pane placeholder + +`EmptyDetailPane` (`lib/shell/empty_detail_pane.dart`) shows the destination's +own icon (`destinationDetails`, per host) above one short muted line, centred. +Runs, Chat and Pipelines all use it: + +- "Select a run to open it here." +- "Select a chat to open it here." +- "Select a pipeline to open it here." This was "Select a pipeline.", and the + tests have been updated. + +The chat screen's private `_NoChatSelected` is gone. + +## P3-14: reading width on wide windows + +`ReadingWidth` / `kReadingMaxWidth` = 840 (`lib/ui/layout/reading_width.dart`) +caps a body from the leading edge and passes the full height through. Its +structure is the same at every width, so crossing the cap never remounts the +body or loses its scroll position. + +- Run detail (`run_detail_tabs.dart`): Summary, Input, Output and Timeline + are capped. Graph, Changes and Artifacts keep the whole pane. +- Stage page (`run_detail_visit.dart`): every section except Artifacts and + Changes is capped. +- Pipeline Summary (`pipeline_detail_panel.dart` `_scrolling`): the content + inside the `ListView` is capped, so the whole pane still scrolls. + +The cap is applied around the bodies, so `run_detail_tab_bodies.dart`, +`run_detail_visit_session.dart` and `pipeline_summary_view.dart` are untouched +(other workers own them). + +## Tests + +New: + +- `test/shell/split_destination_bar_test.dart` covers both hosts: + - At 1200 and 1600 split, the pill stays within the list pane and does not + overlap the detail. The detail composer reaches the bottom edge, and the + list still clears the bar. + - 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/ui/layout/reading_width_test.dart`: + - The cap applies from the leading edge, and the body is not remounted + across the cap. + - Run Summary is capped at 1200 and full width at 390 (both hosts). + - The stage page Summary is capped and its copy button sits within the cap. + - Pipeline Summary is capped. +- `test/features/schedules/ui/list/schedules_wide_test.dart`: at 1200, rows + are 732 wide, the time ends inside the strip, and the field, filter and + count are on one row with no helper line (both hosts). +- `test/shell/empty_detail_pane_test.dart`: icon above a muted line, centred, + for each destination on both hosts. + +Updated: + +- `schedules_layout_test.dart` (the helper is no longer in the strip). +- `schedule_screen_harness.dart` (`size:`). +- The pipelines tests (placeholder wording). +- `chat_list_detail_test.dart`, `pipelines_screen_test.dart` and + `runs_screen_test.dart` now assert `EmptyDetailPane`. + +## Evidence + +Captures are in `/tmp/r3-a-evidence/`. They were taken with headless Chrome +using the reviewer's `/tmp/app-style-review-r2/shoot.mjs` over a web build of +`tool/app_host_probe_entry.dart` (`build/r3-app_host`): + +- Runs fixture: runs, run1, stage, chat, thread (`RICH=1`), schedules and + settings at 560, 1200 and 1600, Material and Cupertino, light, with dark at + 1200 and 1600 for run1, stage, thread and schedules. +- Pipelines fixture: plist and pdetail. + +The specs are in `/tmp/r3-a-evidence/scripts/`. + +Known gaps: there was no device run, so Android and iOS are unverified. diff --git a/app/test/features/chat/chat_list_detail_test.dart b/app/test/features/chat/chat_list_detail_test.dart index 523f2841..aab05934 100644 --- a/app/test/features/chat/chat_list_detail_test.dart +++ b/app/test/features/chat/chat_list_detail_test.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/shell/empty_detail_pane.dart'; import 'package:pipelines_app/ui/layout/app_list_row.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; @@ -52,7 +53,10 @@ void main() { testWidgets('a wide window keeps the tab bar and list beside the open chat ' 'at $size', (tester) async { await _pumpShell(tester, size); - expect(find.text('Select a chat to open it here.'), findsOneWidget); + expect( + find.widgetWithText(EmptyDetailPane, 'Select a chat to open it here.'), + findsOneWidget, + ); expect( tester.widget(find.byKey(const Key('chat-row-a'))).selected, isFalse, diff --git a/app/test/features/pipelines/pipeline_deep_link_test.dart b/app/test/features/pipelines/pipeline_deep_link_test.dart index 5f3017bd..2fe1bcd7 100644 --- a/app/test/features/pipelines/pipeline_deep_link_test.dart +++ b/app/test/features/pipelines/pipeline_deep_link_test.dart @@ -112,9 +112,9 @@ void main() { await _pumpPipelines(tester, gateway: gateway, pipelineId: 1, version: 2); - // The detail is open (not the "Select a pipeline." placeholder), and the + // The detail is open (not the "Select a pipeline to open it here." placeholder), and the // detail request names the route's pinned version. - expect(find.text('Select a pipeline.'), findsNothing); + expect(find.text('Select a pipeline to open it here.'), findsNothing); expect(find.text('Alpha review'), findsWidgets); expect( gateway diff --git a/app/test/features/pipelines/pipelines_screen_filter_test.dart b/app/test/features/pipelines/pipelines_screen_filter_test.dart index e9dccc19..4233d6f8 100644 --- a/app/test/features/pipelines/pipelines_screen_filter_test.dart +++ b/app/test/features/pipelines/pipelines_screen_filter_test.dart @@ -116,7 +116,7 @@ void main() { expect(find.text('pipeline 2 was not found'), findsOneWidget); expect(find.text('Retry'), findsOneWidget); - expect(find.text('Select a pipeline.'), findsNothing); + expect(find.text('Select a pipeline to open it here.'), findsNothing); }); testWidgets('the list switches between all and scheduled pipelines', ( diff --git a/app/test/features/pipelines/pipelines_screen_test.dart b/app/test/features/pipelines/pipelines_screen_test.dart index cb8a146b..c5c92354 100644 --- a/app/test/features/pipelines/pipelines_screen_test.dart +++ b/app/test/features/pipelines/pipelines_screen_test.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/shell/empty_detail_pane.dart'; import 'package:pipelines_app/ui/layout/app_list_row.dart'; import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart'; import 'package:pipelines_app/core/api_gateway.dart'; @@ -25,7 +26,13 @@ void main() { expect(find.textContaining('run 42'), findsNothing); // A pipeline that never ran shows its summary alone, with no status dot. expect(find.text('no runs recorded'), findsNothing); - expect(find.text('Select a pipeline.'), findsOneWidget); + expect( + find.widgetWithText( + EmptyDetailPane, + 'Select a pipeline to open it here.', + ), + findsOneWidget, + ); await tester.tap(find.byKey(const Key('pipeline-row-1'))); await tester.pumpAndSettle(); 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 454840e5..cfd0734e 100644 --- a/app/test/features/runs/ui/run_detail_tabs_test.dart +++ b/app/test/features/runs/ui/run_detail_tabs_test.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/ui/layout/reading_width.dart'; import 'package:pipelines_app/features/runs/ui/run_graph_preview.dart'; import 'package:pipelines_app/features/runs/ui/run_more_menu.dart'; import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart'; @@ -113,8 +114,10 @@ void main() { expect(widePill.right, 1000 - 16); expect(widePill.bottom, 844 - 16); expect(widePill.width, lessThan(1000 * 0.6)); - // Beside the bar the content takes taps: the body spans the width. - expect(tester.getRect(body).width, 1000); + // Beside the bar the content takes taps: the body spans the reading + // width from the leading edge (Summary is capped on a wide pane). + expect(tester.getRect(body).left, 0); + expect(tester.getRect(body).width, kReadingMaxWidth); }); testWidgets('${platform.name} missing graph states the exact wording', ( diff --git a/app/test/features/runs/ui/runs_screen_test.dart b/app/test/features/runs/ui/runs_screen_test.dart index 46873a54..9761a61f 100644 --- a/app/test/features/runs/ui/runs_screen_test.dart +++ b/app/test/features/runs/ui/runs_screen_test.dart @@ -8,6 +8,7 @@ import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/runs/screen.dart'; import 'package:pipelines_app/features/runs/ui/run_detail_view.dart'; import 'run_detail_finders.dart'; +import 'package:pipelines_app/shell/empty_detail_pane.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; class _Gateway implements ApiGateway { @@ -154,6 +155,11 @@ void main() { ) async { await tester.pumpWidget(_materialScreen(gateway)); await _mountList(tester, gateway); + // Beside the list, nothing open yet: the shared empty-pane placeholder. + expect( + find.widgetWithText(EmptyDetailPane, 'Select a run to open it here.'), + findsOneWidget, + ); await tester.tap(find.text('Beta run')); await tester.pump(); diff --git a/app/test/features/schedules/ui/list/schedule_screen_harness.dart b/app/test/features/schedules/ui/list/schedule_screen_harness.dart index 607e90bb..963078f3 100644 --- a/app/test/features/schedules/ui/list/schedule_screen_harness.dart +++ b/app/test/features/schedules/ui/list/schedule_screen_harness.dart @@ -13,8 +13,9 @@ Future pumpSchedules( ValueChanged? onOpen, double textScale = 1, bool settle = true, + Size size = const Size(390, 844), }) async { - tester.view.physicalSize = const Size(390, 844); + tester.view.physicalSize = size; tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); diff --git a/app/test/features/schedules/ui/list/schedules_layout_test.dart b/app/test/features/schedules/ui/list/schedules_layout_test.dart index ad53a690..878b6b79 100644 --- a/app/test/features/schedules/ui/list/schedules_layout_test.dart +++ b/app/test/features/schedules/ui/list/schedules_layout_test.dart @@ -29,7 +29,9 @@ void main() { ); expect(find.text('2 schedules'), findsOneWidget); - expect(find.textContaining('not pipeline definitions'), findsOneWidget); + // The strip carries the count only; the helper line lives in the + // empty state. + expect(find.textContaining('not pipeline definitions'), findsNothing); // Two lines per row: the name with its next run, then the timer // and pinned pipeline version. The editor holds the rest. expect(find.text('Research batteries'), findsOneWidget); diff --git a/app/test/features/schedules/ui/list/schedules_wide_test.dart b/app/test/features/schedules/ui/list/schedules_wide_test.dart new file mode 100644 index 00000000..e0dfcb2e --- /dev/null +++ b/app/test/features/schedules/ui/list/schedules_wide_test.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart'; +import 'package:pipelines_app/features/schedules/ui/list/schedule_list_view.dart'; +import 'package:pipelines_app/ui/layout/app_list_row.dart'; + +import 'schedule_list_test_support.dart'; +import 'schedule_screen_harness.dart'; + +/// On a wide window the rows share the toolbar strip's width, and the strip +/// is one row: the field, the filter and the count as a muted label. +void main() { + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + + testWidgets('$host 1200: rows end under the strip and the strip is one ' + 'row', (tester) async { + await pumpSchedules( + tester, + cupertino: cupertino, + size: const Size(1200, 800), + gateway: FakeSchedulesGateway( + (type, fields) async => schedulesReply([ + scheduleRecord(nextDue: '2026-10-22T09:00:00'), + pausedRecord(), + ]), + ), + ); + final strip = tester.getRect(find.byKey(scheduleToolbarKey)); + final row = tester.getRect(find.byKey(appListRowSurfaceKey).first); + expect(row.left, 0); + expect(row.width, kScheduleListMaxWidth); + // The row's trailing time ends inside the strip's trailing edge. + final time = tester.getRect(find.text('22 Oct 09:00')); + expect(time.right, lessThanOrEqualTo(strip.right - 12 + 0.5)); + + // Field, filter and count on one line. + final field = tester.getRect(find.byKey(scheduleSearchFieldKey)); + final filter = tester.getRect(find.byKey(scheduleFilterKey)); + final count = tester.getRect(find.text('2 schedules')); + expect((field.center.dy - filter.center.dy).abs(), lessThan(4)); + expect((count.center.dy - filter.center.dy).abs(), lessThan(4)); + expect(find.textContaining('not pipeline definitions'), findsNothing); + }); + } +} diff --git a/app/test/shell/empty_detail_pane_test.dart b/app/test/shell/empty_detail_pane_test.dart new file mode 100644 index 00000000..81f5eedc --- /dev/null +++ b/app/test/shell/empty_detail_pane_test.dart @@ -0,0 +1,52 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/shell/destination.dart'; +import 'package:pipelines_app/shell/empty_detail_pane.dart'; + +/// One placeholder for an empty detail pane: the destination's icon above a +/// short muted line, centred, on both hosts. +void main() { + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + for (final destination in [ + AppDestination.runs, + AppDestination.chat, + AppDestination.pipelines, + ]) { + testWidgets('$host ${destination.name}: icon over a muted line', ( + tester, + ) async { + final content = EmptyDetailPane( + destination: destination, + message: 'Select one to open it here.', + ); + await tester.pumpWidget( + cupertino + ? CupertinoApp(home: CupertinoPageScaffold(child: content)) + : MaterialApp(home: Scaffold(body: content)), + ); + final details = destinationDetails(destination); + final icon = find.byIcon( + cupertino ? details.cupertinoIcon : details.icon, + ); + expect(icon, findsOneWidget); + final text = find.text('Select one to open it here.'); + expect( + tester.getTopLeft(text).dy, + greaterThan(tester.getRect(icon).bottom), + ); + // Centred in the pane. + final size = tester.view.physicalSize / tester.view.devicePixelRatio; + expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1)); + // Muted: the same secondary colour on the icon and the line. + final context = tester.element(text); + final muted = cupertino + ? CupertinoColors.secondaryLabel.resolveFrom(context) + : Theme.of(context).colorScheme.onSurfaceVariant; + expect(tester.widget(icon).color, muted); + expect(tester.widget(text).style?.color, muted); + }); + } + } +} diff --git a/app/test/shell/split_destination_bar_test.dart b/app/test/shell/split_destination_bar_test.dart new file mode 100644 index 00000000..77efc529 --- /dev/null +++ b/app/test/shell/split_destination_bar_test.dart @@ -0,0 +1,151 @@ +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/list_detail.dart'; +import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; + +/// While a tab shows its list beside an open item, the shell's destination +/// bar floats over the list pane only: it never covers the item, and the +/// item's own bottom control (a composer) owns the pane's bottom edge. +void main() { + Future setSize(WidgetTester tester, Size size) async { + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + } + + /// A detail whose composer sits at the bottom, padded by the media inset + /// the way the chat composer is. + Widget composerDetail() => Builder( + builder: (context) => Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom), + child: const SizedBox( + key: Key('composer'), + height: 56, + width: double.infinity, + ), + ), + ), + ); + + Widget listBody() => Builder( + builder: (context) => ListView( + key: const Key('list'), + children: [ + for (var index = 0; index < 40; index++) + SizedBox(height: 40, child: Text('row $index')), + ], + ), + ); + + Widget shell({ + required bool cupertino, + bool split = true, + double textScale = 1, + }) { + final app = AdaptiveShell( + cupertino: cupertino, + destination: AppDestination.chat, + destinationBodies: { + AppDestination.chat: (_) => split + ? ListDetailPanes(list: listBody(), detail: composerDetail()) + : listBody(), + }, + ); + return MediaQuery( + data: MediaQueryData.fromView( + WidgetsBinding.instance.platformDispatcher.views.first, + ).copyWith(textScaler: TextScaler.linear(textScale)), + child: cupertino ? CupertinoApp(home: app) : MaterialApp(home: app), + ); + } + + Rect destinationPill(WidgetTester tester) => tester.getRect( + find + .ancestor( + of: find.byKey(const ValueKey('shell.destination.chat')).first, + matching: find.byType(GlassPill), + ) + .first, + ); + + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + + for (final width in [1200.0, 1600.0]) { + testWidgets('$host $width split: the destination bar stays over the ' + 'list pane and the composer owns the detail bottom', (tester) async { + await setSize(tester, Size(width, 800)); + await tester.pumpWidget(shell(cupertino: cupertino)); + await tester.pump(); + await tester.pump(); + + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + final pill = destinationPill(tester); + expect(pill.right, lessThanOrEqualTo(list.right)); + expect(pill.left, greaterThanOrEqualTo(list.left)); + expect(pill.overlaps(body), isFalse, reason: 'no overlap with detail'); + expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + + // The detail keeps only the system inset (none here): its composer + // reaches the bottom edge, below the level of the shell's pill. + final composer = tester.getRect(find.byKey(const Key('composer'))); + expect(composer.bottom, 800); + expect(composer.left, body.left); + expect(composer.top, greaterThan(pill.top)); + + // The list still clears the bar. + final listContext = tester.element(find.byKey(const Key('list'))); + expect( + MediaQuery.paddingOf(listContext).bottom, + greaterThanOrEqualTo(pill.height), + ); + }); + } + + testWidgets('$host 1200 unsplit: the bar is compact at the right edge', ( + tester, + ) async { + await setSize(tester, const Size(1200, 800)); + await tester.pumpWidget(shell(cupertino: cupertino, split: false)); + await tester.pump(); + final pill = destinationPill(tester); + expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(pill.width, lessThan(1200 * 0.6)); + }); + + testWidgets('$host 390: the bar spans the phone', (tester) async { + await setSize(tester, const Size(390, 844)); + await tester.pumpWidget(shell(cupertino: cupertino, split: false)); + await tester.pump(); + final pill = destinationPill(tester); + expect(pill.left, closeTo(kFloatingBarMargin, 0.5)); + expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5)); + }); + + for (final width in [600.0, 840.0]) { + testWidgets('$host $width split at 2x: the narrow list pane bar lays ' + 'out without overflow', (tester) async { + await setSize(tester, Size(width, 800)); + await tester.pumpWidget(shell(cupertino: cupertino, textScale: 2)); + await tester.pump(); + await tester.pump(); + expect(tester.takeException(), isNull); + final list = tester.getRect( + find.byKey(const ValueKey('list-detail-list')), + ); + expect(destinationPill(tester).right, lessThanOrEqualTo(list.right)); + }); + } + } +} diff --git a/app/test/ui/layout/reading_width_test.dart b/app/test/ui/layout/reading_width_test.dart new file mode 100644 index 00000000..7de8aa78 --- /dev/null +++ b/app/test/ui/layout/reading_width_test.dart @@ -0,0 +1,115 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/pipelines/pipeline_repository.dart'; +import 'package:pipelines_app/features/pipelines/pipelines_controller.dart'; +import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart'; +import 'package:pipelines_app/features/pipelines/widgets/pipeline_summary_view.dart'; +import 'package:pipelines_app/ui/layout/reading_width.dart'; + +import '../../features/pipelines/fixtures.dart'; +import '../../features/pipelines/test_helpers.dart'; +import '../../features/runs/ui/run_detail_graph_support.dart'; +import '../../features/runs/ui/run_detail_visit_support.dart'; + +/// Reading bodies (run Summary, stage page sections, pipeline Summary) keep +/// [kReadingMaxWidth] from the leading edge on a wide window and the full +/// width on a phone. +void main() { + Future setSize(WidgetTester tester, Size size) async { + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + } + + testWidgets('ReadingWidth caps from the leading edge and keeps its child ' + 'across the cap', (tester) async { + await setSize(tester, const Size(1200, 600)); + final scroll = ScrollController(); + addTearDown(scroll.dispose); + await tester.pumpWidget( + MaterialApp( + home: ReadingWidth( + child: ListView( + key: const Key('body'), + controller: scroll, + children: [ + for (var index = 0; index < 50; index++) + SizedBox(height: 40, child: Text('row $index')), + ], + ), + ), + ), + ); + final wide = tester.getRect(find.byKey(const Key('body'))); + expect(wide.left, 0); + expect(wide.width, kReadingMaxWidth); + expect(wide.height, 600); + scroll.jumpTo(300); + await tester.pump(); + + await setSize(tester, const Size(500, 600)); + await tester.pump(); + expect(tester.getRect(find.byKey(const Key('body'))).width, 500); + expect(scroll.offset, 300, reason: 'the body was not remounted'); + }); + + for (final platform in RunDetailTestPlatform.values) { + testWidgets('${platform.name} 1200: run Summary is capped', (tester) async { + await pumpRunDetail(tester, platform, size: const Size(1200, 800)); + final body = tester.getRect( + find.byKey(const Key('run-detail-tab-body-summary')), + ); + expect(body.left, 0); + expect(body.width, kReadingMaxWidth); + }); + + testWidgets('${platform.name} 390: run Summary keeps the full width', ( + tester, + ) async { + await pumpRunDetail(tester, platform, size: const Size(390, 844)); + final body = tester.getRect( + find.byKey(const Key('run-detail-tab-body-summary')), + ); + expect(body.width, 390); + }); + + testWidgets('${platform.name} 1200: stage page Summary is capped', ( + tester, + ) async { + await openVisit(tester, platform, size: const Size(1200, 900)); + final body = tester.getRect( + find.byKey(const Key('run-visit-body-summary')), + ); + expect(body.left, 0); + expect(body.width, kReadingMaxWidth); + // The section's trailing copy button sits within the cap. + final copy = find.byKey(const ValueKey('run-visit-copy-Input')); + expect(tester.getRect(copy).right, lessThanOrEqualTo(kReadingMaxWidth)); + }); + } + + testWidgets('1200: pipeline Summary is capped, the pane still scrolls', ( + tester, + ) async { + await setSize(tester, const Size(1200, 800)); + final gateway = gatewayFor(PipelineFixture()); + final controller = PipelinesController(PipelinesRepository(gateway)); + addTearDown(controller.dispose); + await controller.openPipeline(1); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: PipelineDetailPanel( + controller: controller, + gateway: gateway, + showBack: false, + ), + ), + ), + ); + await tester.pumpAndSettle(); + final summary = tester.getRect(find.byType(PipelineSummaryView)); + expect(summary.left, 0); + expect(summary.width, kReadingMaxWidth); + }); +} From 1423159839e40cb25503668b82d1082d00042f1d Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 31 Oct 2026 12:20:37 +0000 Subject: [PATCH 2/3] Note the run detail tabs test update --- app/notes/wide-shell-fixes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/notes/wide-shell-fixes.md b/app/notes/wide-shell-fixes.md index d37bd758..ad8277c6 100644 --- a/app/notes/wide-shell-fixes.md +++ b/app/notes/wide-shell-fixes.md @@ -107,6 +107,8 @@ Updated: - The pipelines tests (placeholder wording). - `chat_list_detail_test.dart`, `pipelines_screen_test.dart` and `runs_screen_test.dart` now assert `EmptyDetailPane`. +- `run_detail_tabs_test.dart`: at 1000 the Summary body is now + `kReadingMaxWidth` wide from x=0 instead of spanning the window. ## Evidence From dbfecaa201e6b6245340aa3cd8cd6bab22b7f950 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 31 Oct 2026 12:41:18 +0000 Subject: [PATCH 3/3] Float detail tabs at the bottom of the split detail pane and keep its bars below the status bar --- .../widgets/pipeline_detail_panel.dart | 4 +- .../pipelines/widgets/pipeline_tabs.dart | 5 +- .../runs/ui/run_detail_tab_strip.dart | 4 +- app/lib/features/runs/ui/run_detail_tabs.dart | 2 +- app/lib/shell/adaptive_shell.dart | 37 ++-- app/lib/shell/list_detail.dart | 48 ++++- app/lib/ui/adaptive/floating_bar_layout.dart | 12 +- app/notes/wide-shell-fixes.md | 50 +++++ app/test/shell/pane_bar_row_test.dart | 37 ++-- app/test/shell/split_status_bar_test.dart | 191 ++++++++++++++++++ 10 files changed, 341 insertions(+), 49 deletions(-) create mode 100644 app/test/shell/split_status_bar_test.dart 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), + ); + }); + } +}