From a1c4c1c40253a6dcc66607cbcf2d68af30015581 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 31 Oct 2026 14:57:56 +0000 Subject: [PATCH] feat(app): icon-only tab bars, Settings from the Pipelines bar, main bar bottom right with detail bars above it Settings leaves the tab bar (Pipelines, Runs, Chat, Search) and opens as a page from a gear in the Pipelines bar, keeping /settings, its keys and a Back to Pipelines (also the system Back). Every floating tab bar shows icons only, named for assistive technology. On wide windows the shell's tab bar stays at the bottom right; a split detail learns its height plus a 12px gap, so its tabs or the chat composer float above it, and pages the detail opens (the stage page) stay in its pane through its own navigator. --- app/lib/application/pipelines_app.dart | 5 +- .../application/pipelines_destination.dart | 5 + app/lib/features/pipelines/screen.dart | 35 ++-- .../widgets/pipeline_bar_buttons.dart | 57 +++++++ .../widgets/pipeline_detail_tab.dart | 5 +- .../runs/ui/run_detail_visit_sections.dart | 2 +- app/lib/shell/adaptive_shell.dart | 99 ++++++----- app/lib/shell/destination.dart | 17 ++ app/lib/shell/detail_pane_navigator.dart | 45 +++++ app/lib/shell/list_detail.dart | 42 +++-- app/lib/ui/adaptive/floating_bar_layout.dart | 5 + .../ui/adaptive/floating_destination_bar.dart | 84 ++++----- app/notes/tab-bars-v2.md | 160 ++++++++++++++++++ .../attention_badge_wiring_test.dart | 4 +- .../list_detail_consistency_test.dart | 12 +- app/test/application/pipelines_app_test.dart | 2 +- .../pipelines_registration_test.dart | 2 +- app/test/application/search_wiring_test.dart | 13 +- app/test/application/settings_page_test.dart | 125 ++++++++++++++ .../settings_registration_test.dart | 2 +- .../application/templates_wiring_test.dart | 4 +- .../features/chat/chat_list_detail_test.dart | 10 +- .../pipelines/pipeline_graph_expand_test.dart | 6 +- .../pipelines/pipeline_graph_tab_test.dart | 14 +- .../pipeline_summary_schedules_test.dart | 6 +- .../pipelines/pipeline_tabs_test.dart | 2 +- .../pipelines/pipelines_adaptive_test.dart | 14 +- .../pipelines/pipelines_screen_test.dart | 6 +- .../runs/ui/run_changes_action_test.dart | 5 +- .../runs/ui/run_detail_tabs_test.dart | 20 ++- .../runs/ui/run_detail_widget_test.dart | 7 +- app/test/shell/attention_badge_test.dart | 6 +- app/test/shell/floating_tab_bar_test.dart | 26 +-- app/test/shell/pane_bar_row_test.dart | 9 +- app/test/shell/shell_bar_test.dart | 21 ++- .../shell/split_destination_bar_test.dart | 112 +++++++++--- app/test/shell/split_detail_pages_test.dart | 136 +++++++++++++++ app/test/shell/split_status_bar_test.dart | 27 ++- .../ui/adaptive/icon_only_tab_bars_test.dart | 127 ++++++++++++++ app/test/widget_test.dart | 6 +- 40 files changed, 1057 insertions(+), 228 deletions(-) create mode 100644 app/lib/features/pipelines/widgets/pipeline_bar_buttons.dart create mode 100644 app/lib/shell/detail_pane_navigator.dart create mode 100644 app/notes/tab-bars-v2.md create mode 100644 app/test/application/settings_page_test.dart create mode 100644 app/test/shell/split_detail_pages_test.dart create mode 100644 app/test/ui/adaptive/icon_only_tab_bars_test.dart diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index 1d20559a..49ccbdc9 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -479,6 +479,7 @@ class _PipelinesAppState extends State onViewPipelineRuns: (id) => _delegate.goTo(AppRoute.runsForPipeline(id)), onOpenSchedules: _delegate.openSchedules, + onOpenSettings: () => _delegate.goTo(AppRoute.settings), // The open pipeline is part of the route, so Back steps out of it. onSelectionChanged: (id) { final current = _delegate.route; @@ -529,13 +530,15 @@ class _PipelinesAppState extends State onSessionSelected: (id) => _delegate.goTo(AppRoute.chatSession(id)), onBack: () => _delegate.goTo(AppRoute.chat), ), - // Search is the fifth tab; a result opens its destination. + // Search is the fourth tab; a result opens its destination. AppDestination.search: (_) => SearchDestination( session: _session, server: widget.server, onOpen: _openSearchResult, embedded: true, ), + // Settings is a page of the Pipelines tab (its bar's gear), not a + // tab; the shell shows it with Back to Pipelines. AppDestination.settings: (_) => SettingsScreen( client: _session.client, // A phone signs in at the web login; a browser has its own. diff --git a/app/lib/application/pipelines_destination.dart b/app/lib/application/pipelines_destination.dart index 38776f8b..16219629 100644 --- a/app/lib/application/pipelines_destination.dart +++ b/app/lib/application/pipelines_destination.dart @@ -23,6 +23,7 @@ class PipelinesDestination extends StatelessWidget { this.onRunStarted, this.onViewPipelineRuns, this.onOpenSchedules, + this.onOpenSettings, this.onSelectionChanged, this.initialPipelineId, this.initialVersion = 0, @@ -42,6 +43,9 @@ class PipelinesDestination extends StatelessWidget { final ValueChanged? onRunStarted; final ValueChanged? onViewPipelineRuns; final VoidCallback? onOpenSchedules; + + /// Opens Settings as a page from the Pipelines bar's gear. + final VoidCallback? onOpenSettings; final ValueChanged? onSelectionChanged; /// The pipeline and pinned version a deep link names. @@ -95,6 +99,7 @@ class PipelinesDestination extends StatelessWidget { onRunStarted: onRunStarted, onViewPipelineRuns: onViewPipelineRuns, onOpenSchedules: onOpenSchedules, + onOpenSettings: onOpenSettings, onSelectionChanged: onSelectionChanged, initialPipelineId: initialPipelineId, initialVersion: initialVersion, diff --git a/app/lib/features/pipelines/screen.dart b/app/lib/features/pipelines/screen.dart index 4bceb512..174920af 100644 --- a/app/lib/features/pipelines/screen.dart +++ b/app/lib/features/pipelines/screen.dart @@ -12,6 +12,7 @@ import 'pipeline_models.dart'; import 'pipeline_repository.dart'; import 'pipelines_controller.dart'; import 'pending_run_store.dart'; +import 'widgets/pipeline_bar_buttons.dart'; import 'widgets/pipeline_controls.dart'; import 'widgets/pipeline_detail_panel.dart'; import 'widgets/pipeline_list_panel.dart'; @@ -36,6 +37,7 @@ class PipelinesScreen extends StatefulWidget { this.onViewPipelineRuns, this.onSelectionChanged, this.onOpenSchedules, + this.onOpenSettings, this.initialPipelineId, this.initialVersion = 0, this.initialStageKey, @@ -66,6 +68,9 @@ class PipelinesScreen extends StatefulWidget { /// Opens every schedule; shown in the bar while the list is visible. final VoidCallback? onOpenSchedules; + /// Opens Settings as a page; a gear in the bar while the list is visible. + final VoidCallback? onOpenSettings; + /// The pipeline a deep link names, opened after the list read starts. final int? initialPipelineId; @@ -281,6 +286,8 @@ class _PipelinesScreenState extends State { if (listShown && widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), + if (listShown && widget.onOpenSettings != null) + _settingsButton(context), ], child: body, ); @@ -298,6 +305,7 @@ class _PipelinesScreenState extends State { ...pipelineListActions(context, _controller), if (widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), + if (widget.onOpenSettings != null) _settingsButton(context), ], ), ), @@ -307,26 +315,11 @@ class _PipelinesScreenState extends State { ); } - Widget _schedulesButton(BuildContext context) { - if (useCupertinoControls(context)) { - return Semantics( - button: true, - label: 'Schedules', - child: CupertinoButton( - key: const Key('pipelines-open-schedules'), - padding: EdgeInsets.zero, - onPressed: widget.onOpenSchedules, - child: const Icon(CupertinoIcons.calendar), - ), - ); - } - return IconButton( - key: const Key('pipelines-open-schedules'), - tooltip: 'Schedules', - onPressed: widget.onOpenSchedules, - icon: const Icon(Icons.schedule), - ); - } + Widget _schedulesButton(BuildContext context) => + pipelineSchedulesButton(context, widget.onOpenSchedules); + + Widget _settingsButton(BuildContext context) => + pipelineSettingsButton(context, widget.onOpenSettings); Widget _refreshButton(BuildContext context) { if (useCupertinoControls(context)) { @@ -357,6 +350,7 @@ class _PipelinesScreenState extends State { ...pipelineListActions(context, _controller), if (widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), + if (widget.onOpenSettings != null) _settingsButton(context), ], ), body: SafeArea(top: false, child: body), @@ -372,6 +366,7 @@ class _PipelinesScreenState extends State { ...pipelineListActions(context, _controller), if (widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), + if (widget.onOpenSettings != null) _settingsButton(context), ], ), child: SafeArea(top: false, child: body), diff --git a/app/lib/features/pipelines/widgets/pipeline_bar_buttons.dart b/app/lib/features/pipelines/widgets/pipeline_bar_buttons.dart new file mode 100644 index 00000000..fb79e75d --- /dev/null +++ b/app/lib/features/pipelines/widgets/pipeline_bar_buttons.dart @@ -0,0 +1,57 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'pipeline_controls.dart'; + +/// One icon action in the Pipelines bar's actions pill: a Material +/// [IconButton] with its tooltip, or a Cupertino button named for +/// accessibility. +Widget pipelineBarIconButton( + BuildContext context, { + required Key key, + required String label, + required IconData icon, + required IconData cupertinoIcon, + required VoidCallback? onPressed, +}) { + if (useCupertinoControls(context)) { + return Semantics( + button: true, + label: label, + child: CupertinoButton( + key: key, + padding: EdgeInsets.zero, + onPressed: onPressed, + child: Icon(cupertinoIcon), + ), + ); + } + return IconButton( + key: key, + tooltip: label, + onPressed: onPressed, + icon: Icon(icon), + ); +} + +/// Opens every schedule. +Widget pipelineSchedulesButton(BuildContext context, VoidCallback? onPressed) => + pipelineBarIconButton( + context, + key: const Key('pipelines-open-schedules'), + label: 'Schedules', + icon: Icons.schedule, + cupertinoIcon: CupertinoIcons.calendar, + onPressed: onPressed, + ); + +/// Opens Settings as a page (it is not a tab of the shell). +Widget pipelineSettingsButton(BuildContext context, VoidCallback? onPressed) => + pipelineBarIconButton( + context, + key: const Key('pipelines-open-settings'), + label: 'Settings', + icon: Icons.settings_outlined, + cupertinoIcon: CupertinoIcons.gear, + onPressed: onPressed, + ); diff --git a/app/lib/features/pipelines/widgets/pipeline_detail_tab.dart b/app/lib/features/pipelines/widgets/pipeline_detail_tab.dart index 1960bd8c..9fdcdb50 100644 --- a/app/lib/features/pipelines/widgets/pipeline_detail_tab.dart +++ b/app/lib/features/pipelines/widgets/pipeline_detail_tab.dart @@ -4,14 +4,15 @@ import 'package:flutter/material.dart'; /// The detail sections: Summary, the pinned definition Graph and Source. enum PipelineDetailTab { summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text), - graph('Graph', Icons.account_tree_outlined, CupertinoIcons.arrow_branch), + graph('Graph', Icons.hub_outlined, CupertinoIcons.flowchart), source('Source', Icons.code, CupertinoIcons.chevron_left_slash_chevron_right); const PipelineDetailTab(this.label, this.icon, this.cupertinoIcon); final String label; - /// The tab's glyph, shown above its name in the bottom bar. + /// The tab's glyph, the only thing the bottom bar draws (the label is its + /// accessible name); distinct from the shell's Pipelines tab beneath it. final IconData icon; final IconData cupertinoIcon; } diff --git a/app/lib/features/runs/ui/run_detail_visit_sections.dart b/app/lib/features/runs/ui/run_detail_visit_sections.dart index b2ef6171..ce0ea888 100644 --- a/app/lib/features/runs/ui/run_detail_visit_sections.dart +++ b/app/lib/features/runs/ui/run_detail_visit_sections.dart @@ -29,7 +29,7 @@ enum RunVisitSection { Icons.difference_outlined, CupertinoIcons.arrow_right_arrow_left, ), - session('Session', Icons.forum_outlined, CupertinoIcons.chat_bubble_2), + session('Session', Icons.forum_outlined, CupertinoIcons.text_bubble), definition( 'Definition', Icons.description_outlined, diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index 81ed392a..d267b440 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -117,7 +117,10 @@ class _AdaptiveShellState extends State { // Full-screen detail routes cover the shell themselves. Keep the root tabs // mounted/layout-ready underneath, so Back does not resize or reveal them // only after the outgoing page has finished its native animation. - final index = AppDestination.values.indexOf(_selected); + // Settings is shown as a page of the Pipelines tab: the tab bar keeps + // Pipelines selected and the bar offers Back to it. + final index = shellTabDestinations.indexOf(shellTabFor(_selected)); + final page = !shellTabDestinations.contains(_selected); final details = destinationDetails(_selected); final contents = AppDestination.values.map((destination) { final item = destinationDetails(destination); @@ -144,62 +147,75 @@ class _AdaptiveShellState extends State { // scaffold's structure depends on the width, so resizing never // remounts a destination. // - // While the tab shows its list beside an open item, the bar 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. + // While the tab shows its list beside an open item the bar keeps + // the same place, bottom right near the thumb: the item pane learns + // the bar's height (see ListDetailPanes) and floats its own tabs or + // composer above it, so the two never overlap. 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(), - ), + final bar = FloatingDestinationBar( + cupertino: widget.cupertino, + currentIndex: index, + onTap: (value) => _select(shellTabDestinations[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: split, - bar: _segmentedBar(spec, details.label), + bar: _segmentedBar(spec, details.label, page: page), ); // 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); + // A page (Settings) closes to Pipelines on the system Back too. The + // scope is always there, so opening the page never remounts the shell. + Widget backable(Widget child) => PopScope( + canPop: !page, + onPopInvokedWithResult: (didPop, _) { + if (!didPop) _closePage(); + }, + child: child, + ); if (widget.cupertino) { - return ShellSystemInsets( - padding: system, - child: CupertinoPageScaffold( - navigationBar: topBar, - child: SafeArea( - top: false, - bottom: false, - child: FloatingBarOverlay( - bar: bar, - child: _destinationStack(contents, index), + return backable( + ShellSystemInsets( + padding: system, + child: CupertinoPageScaffold( + navigationBar: topBar, + child: SafeArea( + top: false, + bottom: false, + child: FloatingBarOverlay( + bar: bar, + child: _destinationStack(contents), + ), ), ), ), ); } - return ShellSystemInsets( - padding: system, - child: Scaffold( - extendBodyBehindAppBar: true, - appBar: topBar, - body: _destinationStack(contents, index), - extendBody: true, - bottomNavigationBar: bar, + return backable( + ShellSystemInsets( + padding: system, + child: Scaffold( + extendBodyBehindAppBar: true, + appBar: topBar, + body: _destinationStack(contents), + extendBody: true, + bottomNavigationBar: bar, + ), ), ); }, ); } + /// Leaves a page destination (Settings) for the tab it belongs to. + void _closePage() => _select(shellTabFor(_selected)); + List _destinationItems() => - AppDestination.values.map((destination) { + shellTabDestinations.map((destination) { final item = destinationDetails(destination); return FloatingDestinationItem( key: ValueKey('shell.destination.${destination.name}'), @@ -213,9 +229,13 @@ class _AdaptiveShellState extends State { /// The open screen's own bar: its Back, title and actions, or the tab's /// name with Search. - SegmentedBar _segmentedBar(ShellBarSpec? spec, String label) { + SegmentedBar _segmentedBar( + ShellBarSpec? spec, + String label, { + required bool page, + }) { final cupertino = widget.cupertino; - final onBack = spec?.onBack; + final onBack = spec?.onBack ?? (page ? _closePage : null); final published = spec?.actions ?? const []; final onSearch = widget.onSearch; return SegmentedBar( @@ -251,7 +271,7 @@ class _AdaptiveShellState extends State { ) // A screen whose main pill is its own field (Search) needs no // separate Search action. - else if (onSearch != null && spec?.titleWidget == null) + else if (onSearch != null && spec?.titleWidget == null && !page) cupertino ? CupertinoButton( key: const ValueKey('shell.search'), @@ -272,8 +292,11 @@ class _AdaptiveShellState extends State { ); } - Widget _destinationStack(List contents, int index) => - IndexedStack(key: _destinationStackKey, index: index, children: contents); + Widget _destinationStack(List contents) => IndexedStack( + key: _destinationStackKey, + index: AppDestination.values.indexOf(_selected), + children: contents, + ); } /// The shell's top bar, over the list pane only while the tab shows a list diff --git a/app/lib/shell/destination.dart b/app/lib/shell/destination.dart index 4cff13e3..fd53f6c8 100644 --- a/app/lib/shell/destination.dart +++ b/app/lib/shell/destination.dart @@ -3,6 +3,23 @@ import 'package:flutter/cupertino.dart'; enum AppDestination { pipelines, runs, chat, search, settings } +/// The destinations the shell's tab bar offers, in order. Settings is a +/// destination the shell can show (its route is `/settings`), but it opens +/// as a page from the Pipelines bar's gear instead of being a tab. +const List shellTabDestinations = [ + AppDestination.pipelines, + AppDestination.runs, + AppDestination.chat, + AppDestination.search, +]; + +/// The tab that owns [destination] in the tab bar: itself, or Pipelines for +/// Settings (reached from the Pipelines bar). +AppDestination shellTabFor(AppDestination destination) => + shellTabDestinations.contains(destination) + ? destination + : AppDestination.pipelines; + ({String label, IconData icon, IconData cupertinoIcon}) destinationDetails( AppDestination value, ) => switch (value) { diff --git a/app/lib/shell/detail_pane_navigator.dart b/app/lib/shell/detail_pane_navigator.dart new file mode 100644 index 00000000..62e87203 --- /dev/null +++ b/app/lib/shell/detail_pane_navigator.dart @@ -0,0 +1,45 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import '../ui/adaptive/host.dart'; + +/// The open item's own navigator beside a list on a wide window. +/// +/// A page the item opens (a run's stage page, an artifact, a file) is pushed +/// here, so it fills the item's pane while the list and the shell's tab bar +/// stay in place: the page's own tabs then float above the shell's bar, as +/// the item's tabs do. Dialogs still use the root navigator. +/// +/// The item is this navigator's first page under a fixed key, so a rebuilt +/// item updates in place and is never remounted. The system Back pops a page +/// pushed here before it leaves the item. +class DetailPaneNavigator extends StatefulWidget { + const DetailPaneNavigator({super.key, required this.child}); + + final Widget child; + + @override + State createState() => _DetailPaneNavigatorState(); +} + +class _DetailPaneNavigatorState extends State { + final GlobalKey _navigator = GlobalKey(); + static const _rootKey = ValueKey('list-detail-root'); + + @override + Widget build(BuildContext context) { + final Page root = usesCupertinoHost(context) + ? CupertinoPage(key: _rootKey, child: widget.child) + : MaterialPage(key: _rootKey, child: widget.child); + return NavigatorPopHandler( + onPopWithResult: (_) => _navigator.currentState?.maybePop(), + child: Navigator( + key: _navigator, + pages: [root], + // The item is never popped from here: its pane closes with the + // selection, which the owning screen controls. + onDidRemovePage: (_) {}, + ), + ); + } +} diff --git a/app/lib/shell/list_detail.dart b/app/lib/shell/list_detail.dart index c6f44de4..863a30c1 100644 --- a/app/lib/shell/list_detail.dart +++ b/app/lib/shell/list_detail.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import '../ui/adaptive/floating_bar_layout.dart'; import '../ui/adaptive/host.dart'; +import 'detail_pane_navigator.dart'; import 'shell_bar.dart'; /// At least this wide, a destination keeps its list beside the open item @@ -100,11 +101,14 @@ class ListPaneWidth extends StatelessWidget { /// 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 bars (both narrowed to the list +/// Under the shell, the list keeps the shell's top bar (narrowed to the list /// pane through [ShellPaneSplit], see [ListPaneWidth]) and the open item owns -/// the rest of the window: the detail starts at the top edge and reaches the -/// bottom edge with only the system insets ([ShellSystemInsets]) as its -/// padding, and its own tabs float at its bottom, as on a phone. +/// the rest of the window: the detail starts at the top edge below the status +/// bar ([ShellSystemInsets]). The shell's tab bar stays at the bottom right, +/// over the detail pane, so the detail learns that bar's height plus +/// [kStackedBarGap] as its bottom padding: its own tabs (or the chat +/// composer) float above the shell's bar, never on it, and its content clears +/// both. Pages the item opens stay in its pane ([DetailPaneNavigator]). class ListDetailPanes extends StatelessWidget { const ListDetailPanes({super.key, required this.list, required this.detail}); @@ -129,21 +133,35 @@ class ListDetailPanes extends StatelessWidget { constraints.maxWidth, ); Widget body = detail; + Widget listPane = list; if (split) { - // 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. + // Beside the list the item is not under the shell's top bar (it + // stays over the list pane): it keeps the system's own top inset, + // so its bar sits just below the status bar at the top edge. The + // shell's tab bar floats at the bottom right, over this pane; its + // height (the shell's bottom padding here) plus a gap lifts the + // item's tabs or composer above it. final system = ShellSystemInsets.of(context); body = MediaQuery( data: media.copyWith( padding: media.padding.copyWith( top: system.top, - bottom: system.bottom, + bottom: media.padding.bottom + kStackedBarGap, ), ), - child: PageTabsEdge(edge: FloatingBarEdge.bottom, child: body), + child: PageTabsEdge( + edge: FloatingBarEdge.bottom, + child: DetailPaneNavigator(child: body), + ), + ); + // The tab bar sits over the detail pane, never the list (the + // detail is at least half the window, wider than the bar), so + // the list clears only the system's bottom inset. + listPane = MediaQuery( + data: media.copyWith( + padding: media.padding.copyWith(bottom: system.bottom), + ), + child: list, ); } return Row( @@ -156,7 +174,7 @@ class ListDetailPanes extends StatelessWidget { container: true, explicitChildNodes: true, identifier: 'list-detail-list', - child: list, + child: listPane, ), ), ), diff --git a/app/lib/ui/adaptive/floating_bar_layout.dart b/app/lib/ui/adaptive/floating_bar_layout.dart index ed08aef4..b3e06c8f 100644 --- a/app/lib/ui/adaptive/floating_bar_layout.dart +++ b/app/lib/ui/adaptive/floating_bar_layout.dart @@ -7,6 +7,11 @@ const double kFloatingBarWideWidth = 600; /// The gap between a floating tab bar and the edges (and bottom safe area). const double kFloatingBarMargin = 16; +/// The gap between two floating bars stacked at the bottom right of a wide +/// window: the shell's tab bar and, above it, an open item's own tabs (the +/// chat composer adds its own padding on top of this). +const double kStackedBarGap = 12; + /// [padding] with the floating bar's clearance added at the bottom. /// /// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell) diff --git a/app/lib/ui/adaptive/floating_destination_bar.dart b/app/lib/ui/adaptive/floating_destination_bar.dart index 11e8e1f7..13edb089 100644 --- a/app/lib/ui/adaptive/floating_destination_bar.dart +++ b/app/lib/ui/adaptive/floating_destination_bar.dart @@ -17,6 +17,10 @@ import 'glass_pill.dart'; /// way it keeps [kFloatingBarMargin] above the bottom safe area. Only the pill /// takes taps: the space beside it reaches the content behind. /// +/// The tabs show icons only. Each tab's label stays its accessible name (and +/// the Material tooltip), so screen readers still announce it; the icons must +/// be distinct within a bar. +/// /// The controls inside remain the platform navigation controls (Material /// [NavigationBar], Cupertino [CupertinoTabBar]), so tab semantics (selected /// state, "tab n of m") come from the host. The Cupertino path builds no @@ -41,11 +45,17 @@ class FloatingDestinationBar extends StatelessWidget { final ValueChanged onTap; final List items; - /// Height of the Material bar inside the pill (the stock bar is 80). - static const double materialHeight = 64; + /// Height of the Material bar inside the pill (the stock bar is 80; with + /// labels hidden the icon and its indicator need less). + static const double materialHeight = 56; - /// Height of the Cupertino bar inside the pill (the stock bar is 50). - static const double cupertinoHeight = 54; + /// Height of the Cupertino bar inside the pill (the stock bar's 50). + static const double cupertinoHeight = 50; + + /// Width of one icon-only tab on a wide window: a comfortable touch target + /// around the Material indicator (64) or the Cupertino selection capsule. + static const double materialTabWidth = 72; + static const double cupertinoTabWidth = 64; /// The side margin at [FloatingBarEdge.top], matching the top bar's own. static const double topMargin = 12; @@ -114,41 +124,10 @@ class FloatingDestinationBar extends StatelessWidget { ); } - /// The width the tabs need side by side: every tab as wide as the widest - /// label (as the host lays them out), never narrower than a comfortable - /// touch target. - double _tabsWidth(BuildContext context) { - final TextStyle? style; - final TextScaler scaler; - final double minimum; - if (cupertino) { - style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle; - scaler = TextScaler.noScaling; - minimum = 76; - } else { - final theme = Theme.of(context); - style = - theme.navigationBarTheme.labelTextStyle?.resolve(const { - WidgetState.selected, - }) ?? - theme.textTheme.labelMedium; - // NavigationBar clamps its labels at 1.3x. - scaler = MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.3); - minimum = 88; - } - var widest = 0.0; - for (final item in items) { - final painter = TextPainter( - text: TextSpan(text: item.label, style: style), - textScaler: scaler, - textDirection: Directionality.of(context), - maxLines: 1, - )..layout(); - widest = math.max(widest, painter.width); - painter.dispose(); - } - return math.max(minimum, widest + 24) * items.length; - } + /// The width the icon-only tabs need side by side. Icons do not scale with + /// text, so the pill keeps its size at any text scale. + double _tabsWidth(BuildContext context) => + (cupertino ? cupertinoTabWidth : materialTabWidth) * items.length; Widget _materialBar(BuildContext context) { final scheme = Theme.of(context).colorScheme; @@ -159,7 +138,9 @@ class FloatingDestinationBar extends StatelessWidget { surfaceTintColor: Colors.transparent, indicatorColor: scheme.secondaryContainer, height: materialHeight, - labelBehavior: NavigationDestinationLabelBehavior.alwaysShow, + // Icons only; the label remains each tab's accessible name and its + // tooltip. + labelBehavior: NavigationDestinationLabelBehavior.alwaysHide, ), child: NavigationBar( selectedIndex: currentIndex, @@ -177,10 +158,10 @@ class FloatingDestinationBar extends StatelessWidget { ); } - /// The stock Cupertino bar, transparent inside the pill. Each tab's label is - /// drawn with its icon (in the bar's own label style and colours) so the - /// item's key covers the whole tab, and the selected tab's icon sits in a - /// tinted capsule so the selection reads at a glance, not by colour alone. + /// The stock Cupertino bar, transparent inside the pill. Each tab shows its + /// icon only, named by its label for accessibility; the item's key covers + /// the whole tab, and the selected tab's icon sits in a tinted capsule so + /// the selection reads at a glance, not by colour alone. Widget _cupertinoBar(BuildContext context) { final active = CupertinoTheme.of(context).primaryColor; Widget tab(FloatingDestinationItem item, {required bool selected}) { @@ -199,14 +180,7 @@ class FloatingDestinationBar extends StatelessWidget { } return KeyedSubtree( key: item.key, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - icon, - const SizedBox(height: 2), - Text(item.label, maxLines: 1, softWrap: false), - ], - ), + child: Semantics(label: item.label, child: icon), ); } @@ -218,7 +192,7 @@ class FloatingDestinationBar extends StatelessWidget { // Secondary-label translucency over glass falls below text contrast // requirements. The host label role remains readable in both themes. inactiveColor: CupertinoColors.label.resolveFrom(context), - iconSize: 24, + iconSize: 26, height: cupertinoHeight, currentIndex: currentIndex, onTap: onTap, @@ -244,9 +218,11 @@ class FloatingDestinationItem { }); final Widget icon; + + /// The tab's accessible name (and Material tooltip); not drawn. final String label; final Widget? selectedIcon; - /// Identifies the whole tab (icon and label), for tests and automation. + /// Identifies the whole tab, for tests and automation. final Key? key; } diff --git a/app/notes/tab-bars-v2.md b/app/notes/tab-bars-v2.md new file mode 100644 index 00000000..d6898821 --- /dev/null +++ b/app/notes/tab-bars-v2.md @@ -0,0 +1,160 @@ +# Tab bars v2 (operator feedback) + +Follows `notes/floating-tab-bars.md` and `notes/wide-shell-fixes.md`. Where they +disagree, this note wins: the shell's tab bar no longer stays over the list +pane. + +## 1. Settings is a page, not a tab + +- `shellTabDestinations` (`lib/shell/destination.dart`) is the tab bar: + Pipelines, Runs, Chat, Search. `AppDestination.settings` still exists, so the + shell can show it. The `/settings` route, deep link, `SettingsScreen` and its + keys are unchanged, and Templates and Schedules still open above it. +- Pipelines bar: there is a gear action after Refresh (key + `pipelines-open-settings`, `PipelinesScreen.onOpenSettings` / + `PipelinesDestination.onOpenSettings`). It is shown while the list is + visible. The Schedules and Settings buttons live in + `features/pipelines/widgets/pipeline_bar_buttons.dart`. +- While Settings is shown, the shell keeps Pipelines selected in the tab bar + (`shellTabFor`), so Settings reads as a page of Pipelines. + - The top bar gets a Back button (`shell.back`) and no Search action. + - The system Back (`PopScope` around the shell, present at all times so + nothing remounts) also returns to Pipelines, instead of leaving the app. + - Tapping the Pipelines tab returns to Pipelines as well. + +## 2. Icons only + +`FloatingDestinationBar` no longer draws labels. + +- Material uses `NavigationDestinationLabelBehavior.alwaysHide`. The label is + still the tab's semantics label and its tooltip. +- Cupertino draws the icon alone, inside `Semantics(label:)`. It has no + tooltip, because a tooltip would be a Material widget. +- Selected state, "tab n of m", badges and every test key are unchanged. +- Sizes: + - Pill height is 56 for Material and 50 for Cupertino. + - On a wide window each tab is 72 wide (Material) or 64 (Cupertino), so the + pill no longer depends on text scale. +- Icons changed so that no detail tab repeats a shell tab it can float above: + - Pipeline Graph: `Icons.hub_outlined` / `CupertinoIcons.flowchart`. The old + icon was the Pipelines tab's. + - Stage Session (Cupertino): `CupertinoIcons.text_bubble`. The old icon was + the Chat tab's. + +## 3–4. Main bar bottom right; detail bars above it + +- The shell no longer wraps its bottom bar in `ListPaneWidth`. The bar gets the + full window width, so at 600 and wider it is compact at the bottom right, + whether the list is split or not. +- In `ListDetailPanes` (split, under a shell): + - **Detail pane:** its bottom padding is the shell bar's height (the shell's + own bottom padding) plus `kStackedBarGap` (12). As a result: + - The item's floating tabs sit 12 above the main pill, trailing-aligned. + - The chat composer's box starts 12 above the pill, and its pill adds + another 12 inside. + - Content clears both bars. + - **Top inset:** this is still `ShellSystemInsets` (status bar). + - **List pane:** gets only the system bottom inset. The bar never covers the + list, because the detail is at least half the window and wider than the + pill. +- `DetailPaneNavigator` (`lib/shell/detail_pane_navigator.dart`): + - The split detail now has its own `Navigator`. The item is its first page, + under a fixed key, so it updates in place. + - Pages the item pushes (the stage page from the timeline, artifact/diff + viewers, the expanded graph) open inside the pane. The list and the main + bar stay visible, and the stage page's tabs float above the main bar like + the run tabs do. + - `NavigatorPopHandler` makes the system Back pop such a page first. + - Dialogs still use the root navigator. +- Phones are unchanged. A detail is a pushed full-screen page, with its tabs at + the bottom and no shell bar. + +## 5. Kept + +- `ShellSystemInsets`, the status-bar inset in the split detail. +- Content scrolling behind both bars. +- No remount when the width changes. The shell's scaffold structure, the + `PopScope` and the bar do not depend on width or split. +- The Cupertino bar still builds no Material widget. +- 320px at 2x text: the existing tests pass, and icon tabs do not scale. + +## Tests + +Full suite: 2233 passed (`flutter test`); `flutter analyze` clean; +`flutter build web` OK. + +New: + +- `test/application/settings_page_test.dart`, on both hosts at 390 and 1200: + - The gear opens `/settings`. + - Settings shows Back and has no Search, and Pipelines stays selected. + - Back returns to `/pipelines`. + - The tab bar labels are exactly Pipelines/Runs/Chat/Search. + - The `/settings` deep link opens Settings, and the system Back is handled + and returns to Pipelines. +- `test/shell/split_detail_pages_test.dart`: the real run detail in a 1200 + split under the shell, on both hosts. + - The run tabs are trailing-aligned and sit 12 above the main pill, which + keeps the bottom right. + - The stage page opens inside the pane: the root navigator cannot pop and the + list stays visible. Its tabs are 12 above the main pill, with no overlap. + - The stage page's Back returns to the run. +- `test/ui/adaptive/icon_only_tab_bars_test.dart`, covering the run detail, + stage page and pipeline detail bars on both hosts: + - No label is drawn (Cupertino has no `Text`; Material uses `alwaysHide`). + - Each tab's semantics label starts with its name, and the selected state is + correct. + - The icons are distinct, and no detail icon equals a shell tab icon. +- `test/shell/split_destination_bar_test.dart` (rewritten), at 1200 and 1600 on + both hosts: + - The main pill is at the bottom right, over the detail, never the list. + - The composer box is 12 above it. + - Detail tabs are 12 above it, no overlap, and the item list clears both. + - The list pane pads only the system inset. + - At 600 and 840 split with 2x text, there is no overflow. + +Updated for the intentional changes: + +- `shell_bar_test`: Search is the fourth tab and Settings is not a tab. +- `floating_tab_bar_test`: the wide pill is exactly 4 tab widths, and the + semantics test uses tab keys and the label. +- `split_status_bar_test`: a 24px bottom inset; the item tabs sit 12 above the + main pill, which is at 800 − 24. +- `pane_bar_row_test`: the item tabs are above the main pill. +- `attention_badge_test`: tabs are tapped by key. +- Tests that tapped tab label text now tap tab keys: + - Pipeline tests use `pipeline-detail-tab-*`. + - App tests use `shell.destination.*`; Settings is opened by + `pipelines-open-settings`. + - Run detail tests use `run-detail-tab-*`. +- `list_detail_consistency_test` and `chat_list_detail_test` use the root + navigator (`find.byType(Navigator).first`), because the split pane now has + its own. + +## Evidence + +`/tmp/tabs-v2-evidence/` holds 84 PNGs taken with headless Chrome, using +`/tmp/app-style-review-r2/shoot.mjs` over a web build of +`tool/app_host_probe_entry.dart` (`build/tabs2-app_host`). The specs are in +`scripts/`. + +- Runs fixture (wave2-e, `RICH=1`): `{m,c}-{runs,run1,stage,thread}-{560,1200,1600}-{light,dark}`. +- Pipelines fixture (`pipelines_wiring_probe_server`): `{m,c}-{plist,pdetail}-…`. +- Settings opened by clicking the gear: `{m,c}-settings-via-bar-…`. + +What the captures show: + +- At 1200 and 1600: + - The main pill is at the bottom right. + - The run, stage and pipeline tabs sit above it with a visible gap. + - The chat composer sits above it. + - The stage page opens in the detail pane, beside the list. +- At 560 the bars are full width and icon-only. +- Settings shows Back, with Pipelines selected. + +Known gaps: + +- There was no device run, so the Android and iOS hardware Back for the + Settings page and the in-pane pages are covered by widget tests only. +- Headless Chrome has no status bar, so the status-bar inset is again covered + by tests only. diff --git a/app/test/application/attention_badge_wiring_test.dart b/app/test/application/attention_badge_wiring_test.dart index ba4fd01c..107efc18 100644 --- a/app/test/application/attention_badge_wiring_test.dart +++ b/app/test/application/attention_badge_wiring_test.dart @@ -52,7 +52,9 @@ void main() { expect(tester.widget(find.byType(Badge)).isLabelVisible, isFalse); expect(find.bySemanticsLabel(needingAttention), findsNothing); - await tester.tap(find.text('Pipelines').last); + await tester.tap( + find.byKey(const ValueKey('shell.destination.pipelines')), + ); await tester.pump(); expect(provider.value.uri.path, '/pipelines'); await waitForRequest(tester, channel, 'list_pipelines'); diff --git a/app/test/application/list_detail_consistency_test.dart b/app/test/application/list_detail_consistency_test.dart index ddc34efd..819e63ee 100644 --- a/app/test/application/list_detail_consistency_test.dart +++ b/app/test/application/list_detail_consistency_test.dart @@ -159,7 +159,9 @@ void main() { expect(tester.getSize(list).width, closeTo(before, 0.01)); expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01)); expect( - tester.state(find.byType(Navigator)).canPop(), + tester + .state(find.byType(Navigator).first) + .canPop(), isFalse, ); for (final rowKey in rowKeys) { @@ -224,7 +226,9 @@ void main() { tester.view.physicalSize = const Size(390, 900); await tester.pumpAndSettle(); expect( - tester.state(find.byType(Navigator)).canPop(), + tester + .state(find.byType(Navigator).first) + .canPop(), isTrue, reason: '$destination should push its selected item on a phone', ); @@ -235,7 +239,9 @@ void main() { tester.view.physicalSize = Size(width, 900); await tester.pumpAndSettle(); expect( - tester.state(find.byType(Navigator)).canPop(), + tester + .state(find.byType(Navigator).first) + .canPop(), isFalse, ); expect(tester.getSize(list).width, closeTo(before, 0.01)); diff --git a/app/test/application/pipelines_app_test.dart b/app/test/application/pipelines_app_test.dart index 0defd93a..2a50d42e 100644 --- a/app/test/application/pipelines_app_test.dart +++ b/app/test/application/pipelines_app_test.dart @@ -239,7 +239,7 @@ void main() { final pipelinesRunsId = pipelineRequest(channel, 'list_runs')!['id'] as String; - await tester.tap(find.text('Runs').last); + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); await tester.pump(); expect(provider.value.uri.path, '/runs'); diff --git a/app/test/application/pipelines_registration_test.dart b/app/test/application/pipelines_registration_test.dart index d76ef6f1..291c8c17 100644 --- a/app/test/application/pipelines_registration_test.dart +++ b/app/test/application/pipelines_registration_test.dart @@ -77,7 +77,7 @@ void main() { await tester.pump(); expect(find.text('hash-alpha'), findsOneWidget); - await tester.tap(find.text('Source')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pump(); expect( selectableText( diff --git a/app/test/application/search_wiring_test.dart b/app/test/application/search_wiring_test.dart index b4ca51df..07942aa6 100644 --- a/app/test/application/search_wiring_test.dart +++ b/app/test/application/search_wiring_test.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter_test/flutter_test.dart'; import '../features/runs/ui/run_detail_finders.dart'; import '../native_back.dart'; @@ -87,15 +86,11 @@ Future replyRun7List(WidgetTester tester, FakeChannel channel) => reply( }, ); -/// Taps a tab by its label: the bottom bar or, on a wide window, the rail. +/// Taps a shell tab by its label (the tabs show icons only, keyed by name). Future tapTab(WidgetTester tester, String label) async { - final bar = find.byWidgetPredicate( - (widget) => - widget is NavigationBar || - widget is NavigationRail || - widget is CupertinoTabBar, + await tester.tap( + find.byKey(ValueKey('shell.destination.${label.toLowerCase()}')), ); - await tester.tap(find.descendant(of: bar, matching: find.text(label))); } /// Opens Search, sends `report` and answers with the artifact hit for run 7. @@ -300,7 +295,7 @@ void main() { // On a phone an open run fills the screen and the tabs step aside, so // switching tabs with a run open is a wide-window move. - // Search is the fifth tab. + // Search is the fourth tab. await tapTab(tester, 'Search'); await tester.pump(); await tester.pump(const Duration(milliseconds: 600)); diff --git a/app/test/application/settings_page_test.dart b/app/test/application/settings_page_test.dart new file mode 100644 index 00000000..6737fd19 --- /dev/null +++ b/app/test/application/settings_page_test.dart @@ -0,0 +1,125 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/application/pipelines_app.dart'; +import 'package:pipelines_app/core/transport/pipelines_client.dart'; +import 'package:pipelines_app/features/settings/settings_screen.dart'; +import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../core/transport/pipelines_client_test.dart' show FakeChannel; +import '../features/pipelines/fixtures.dart'; +import 'pipelines_app_test.dart' show webServer; +import 'pipelines_replies.dart'; + +/// Settings is not a tab: it opens as a page from the gear in the Pipelines +/// bar, keeps its `/settings` route (and deep link), and closes back to +/// Pipelines. The tab bar keeps Pipelines selected meanwhile. +void main() { + Future pumpApp( + WidgetTester tester, { + required bool cupertino, + required String location, + required Size size, + }) async { + SharedPreferences.setMockInitialValues({}); + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + final channel = FakeChannel()..readyCompleter.complete(); + final provider = PlatformRouteInformationProvider( + initialRouteInformation: RouteInformation(uri: Uri.parse(location)), + ); + addTearDown(provider.dispose); + await tester.pumpWidget( + PipelinesApp( + server: webServer(), + client: PipelinesClient(channelFactory: (_) => channel), + cupertino: cupertino, + routeInformationProvider: provider, + ), + ); + await tester.pump(); + if (location == '/pipelines') { + await replyPipelines(tester, channel, PipelineFixture()); + } + return provider; + } + + int selectedTab(WidgetTester tester) => tester + .widget(find.byType(FloatingDestinationBar)) + .currentIndex; + + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + for (final size in [const Size(390, 844), const Size(1200, 800)]) { + testWidgets('$host ${size.width}: the Pipelines bar gear opens Settings ' + 'as a page and Back returns', (tester) async { + final provider = await pumpApp( + tester, + cupertino: cupertino, + location: '/pipelines', + size: size, + ); + // Four tabs; Settings is none of them. + expect( + tester + .widget( + find.byType(FloatingDestinationBar), + ) + .items + .map((item) => item.label), + ['Pipelines', 'Runs', 'Chat', 'Search'], + ); + expect( + find.byKey(const ValueKey('shell.destination.settings')), + findsNothing, + ); + expect(find.byKey(const ValueKey('shell.back')), findsNothing); + + await tester.tap(find.byKey(const Key('pipelines-open-settings'))); + await tester.pump(); + await tester.pump(); + expect(provider.value.uri.path, '/settings'); + expect(find.byType(SettingsScreen), findsOneWidget); + expect(find.text('Server URL'), findsOneWidget); + // A page of Pipelines: Back in its bar, Pipelines still selected. + expect(find.byKey(const ValueKey('shell.back')), findsOneWidget); + expect(find.byKey(const ValueKey('shell.search')), findsNothing); + expect(selectedTab(tester), 0); + expect(tester.takeException(), isNull); + + await tester.tap(find.byKey(const ValueKey('shell.back'))); + await tester.pump(); + await tester.pump(); + expect(provider.value.uri.path, '/pipelines'); + expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets); + expect(find.byKey(const ValueKey('shell.back')), findsNothing); + await tester.pumpWidget(const SizedBox.shrink()); + await tester.pump(); + }); + } + + testWidgets('$host: the /settings deep link opens the Settings page and ' + 'the system Back closes it to Pipelines', (tester) async { + final provider = await pumpApp( + tester, + cupertino: cupertino, + location: '/settings', + size: const Size(390, 844), + ); + await tester.pump(); + expect(find.byType(SettingsScreen), findsOneWidget); + expect(find.byKey(const ValueKey('shell.back')), findsOneWidget); + expect(selectedTab(tester), 0); + + final handled = await tester.binding.handlePopRoute(); + expect(handled, isTrue, reason: 'Back closes the page, not the app'); + await tester.pump(); + await tester.pump(); + expect(provider.value.uri.path, '/pipelines'); + await tester.pumpWidget(const SizedBox.shrink()); + await tester.pump(); + }); + } +} diff --git a/app/test/application/settings_registration_test.dart b/app/test/application/settings_registration_test.dart index d4a6243b..08d70fdd 100644 --- a/app/test/application/settings_registration_test.dart +++ b/app/test/application/settings_registration_test.dart @@ -51,7 +51,7 @@ void main() { ); await replyPipelines(tester, channel, PipelineFixture()); - await tester.tap(find.text('Settings').last); + await tester.tap(find.byKey(const Key('pipelines-open-settings'))); await tester.pump(); await tester.pump(); expect(provider.value.uri.path, '/settings'); diff --git a/app/test/application/templates_wiring_test.dart b/app/test/application/templates_wiring_test.dart index 7aaf2aac..51265d09 100644 --- a/app/test/application/templates_wiring_test.dart +++ b/app/test/application/templates_wiring_test.dart @@ -93,7 +93,7 @@ Future openSettings( FakeChannel channel, PlatformRouteInformationProvider provider, ) async { - await tester.tap(find.text('Settings').last); + await tester.tap(find.byKey(const Key('pipelines-open-settings'))); await tester.pump(); await tester.pump(); expect(provider.value.uri.path, '/settings'); @@ -354,7 +354,7 @@ void main() { await tester.pump(); await tester.tap(find.byKey(templatesPageBackKey)); await tester.pumpAndSettle(); - await tester.tap(find.text('Pipelines').last); + await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines'))); await tester.pumpAndSettle(); expect(provider.value.uri.path, '/pipelines'); diff --git a/app/test/features/chat/chat_list_detail_test.dart b/app/test/features/chat/chat_list_detail_test.dart index aab05934..fa4945cc 100644 --- a/app/test/features/chat/chat_list_detail_test.dart +++ b/app/test/features/chat/chat_list_detail_test.dart @@ -64,7 +64,9 @@ void main() { await tester.tap(find.text('First chat')); await tester.pumpAndSettle(); - final navigator = tester.state(find.byType(Navigator)); + final navigator = tester.state( + find.byType(Navigator).first, + ); expect(navigator.canPop(), isFalse, reason: 'No page covers the shell'); expect(find.byType(NavigationRail), findsNothing); expect(find.byType(FloatingDestinationBar), findsOneWidget); @@ -106,7 +108,7 @@ void main() { expect(navigator.canPop(), isFalse); // The rail still switches destinations with a chat open. - await tester.tap(find.text('Runs')); + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); await tester.pumpAndSettle(); expect(find.byKey(const ValueKey('chat-thread-b')), findsNothing); @@ -120,7 +122,9 @@ void main() { await tester.tap(find.text('First chat')); await tester.pumpAndSettle(); - final navigator = tester.state(find.byType(Navigator)); + final navigator = tester.state( + find.byType(Navigator).first, + ); expect(navigator.canPop(), isTrue); expect(findNativeBack(), findsOneWidget); expect(find.byType(NavigationBar), findsNothing); diff --git a/app/test/features/pipelines/pipeline_graph_expand_test.dart b/app/test/features/pipelines/pipeline_graph_expand_test.dart index 1c33dfde..570cda80 100644 --- a/app/test/features/pipelines/pipeline_graph_expand_test.dart +++ b/app/test/features/pipelines/pipeline_graph_expand_test.dart @@ -46,9 +46,11 @@ Future _pumpScreen(WidgetTester tester) async { Future _openGraphTab(WidgetTester tester, int pipelineId) async { await tester.tap(find.byKey(Key('pipeline-row-$pipelineId'))); await tester.pumpAndSettle(); - await tester.ensureVisible(find.text('Graph')); + await tester.ensureVisible( + find.byKey(const Key('pipeline-detail-tab-graph')), + ); await tester.pumpAndSettle(); - await tester.tap(find.text('Graph')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph'))); await tester.pump(); await tester.pump(); } diff --git a/app/test/features/pipelines/pipeline_graph_tab_test.dart b/app/test/features/pipelines/pipeline_graph_tab_test.dart index d7a226f8..c32af319 100644 --- a/app/test/features/pipelines/pipeline_graph_tab_test.dart +++ b/app/test/features/pipelines/pipeline_graph_tab_test.dart @@ -61,9 +61,11 @@ Future _openGraphTab(WidgetTester tester, int pipelineId) async { // The detail header scrolls when content-driven title/tab height needs it // (the header gained the native Run action), so reach the tab like an // operator would instead of requiring it to fit without scrolling. - await tester.ensureVisible(find.text('Graph')); + await tester.ensureVisible( + find.byKey(const Key('pipeline-detail-tab-graph')), + ); await tester.pumpAndSettle(); - await tester.tap(find.text('Graph')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph'))); await tester.pump(); await tester.pump(); } @@ -203,9 +205,9 @@ void main() { // The selection belongs to the panel, so an in-place tab round trip keeps // the same node marked (the web keeps its graph selection across tabs). - await tester.tap(find.text('Summary')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary'))); await tester.pumpAndSettle(); - await tester.tap(find.text('Graph')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph'))); await tester.pump(); await tester.pump(); expect(tester.widget(_node('review')).selected, isTrue); @@ -227,14 +229,14 @@ void main() { // The selection belongs to the pinned definition: changing version must not // carry a same-named node's mark into the other version. - await tester.tap(find.text('Summary')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary'))); await tester.pumpAndSettle(); await tester.ensureVisible(find.byKey(const Key('pipeline-version-1'))); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('pipeline-version-1'))); await tester.pumpAndSettle(); expect(find.text('Viewing v1 (latest v2).'), findsOneWidget); - await tester.tap(find.text('Graph')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph'))); await tester.pump(); await tester.pump(); expect(tester.widget(_node('review')).selected, isFalse); diff --git a/app/test/features/pipelines/pipeline_summary_schedules_test.dart b/app/test/features/pipelines/pipeline_summary_schedules_test.dart index afe6179e..a0717d96 100644 --- a/app/test/features/pipelines/pipeline_summary_schedules_test.dart +++ b/app/test/features/pipelines/pipeline_summary_schedules_test.dart @@ -75,14 +75,14 @@ void main() { await tester.pumpAndSettle(); expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1}); - await tester.tap(find.text('Source')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pump(); expect(find.text('name: alpha'), findsOneWidget); - await tester.tap(find.text('Graph')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph'))); await tester.pump(); await tester.pump(); expect(find.byKey(scheduleAddKey), findsNothing); - await tester.tap(find.text('Summary')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary'))); await tester.pumpAndSettle(); expect(find.text('Research batteries'), findsOneWidget); }); diff --git a/app/test/features/pipelines/pipeline_tabs_test.dart b/app/test/features/pipelines/pipeline_tabs_test.dart index 2129cafc..91980d52 100644 --- a/app/test/features/pipelines/pipeline_tabs_test.dart +++ b/app/test/features/pipelines/pipeline_tabs_test.dart @@ -81,7 +81,7 @@ void main() { expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name); expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name); } - await tester.tap(find.text('Source')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pumpAndSettle(); expect(selected, PipelineDetailTab.source); expect(tester.takeException(), isNull); diff --git a/app/test/features/pipelines/pipelines_adaptive_test.dart b/app/test/features/pipelines/pipelines_adaptive_test.dart index 8bf67e6d..08487c8b 100644 --- a/app/test/features/pipelines/pipelines_adaptive_test.dart +++ b/app/test/features/pipelines/pipelines_adaptive_test.dart @@ -68,9 +68,11 @@ void main() { await tester.tap(find.byKey(const Key('pipeline-row-1'))); await tester.pumpAndSettle(); expect(tester.takeException(), isNull); - await tester.ensureVisible(find.text('Source')); + await tester.ensureVisible( + find.byKey(const Key('pipeline-detail-tab-source')), + ); await tester.pumpAndSettle(); - await tester.tap(find.text('Source')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pumpAndSettle(); expect(tester.takeException(), isNull); expect( @@ -153,7 +155,7 @@ void main() { await tester.tap(find.byKey(const Key('pipeline-version-1'))); await tester.pumpAndSettle(); expect(find.text('Viewing v1 (latest v2).'), findsOneWidget); - await tester.tap(find.text('Source')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pump(); expect( selectableText( @@ -199,9 +201,11 @@ void main() { // The header scrolls instead of squeezing the tab out; the tabs stay // reachable inside it and the tab keeps a bounded slot. expect(tester.takeException(), isNull); - await tester.ensureVisible(find.text('Graph')); + await tester.ensureVisible( + find.byKey(const Key('pipeline-detail-tab-graph')), + ); await tester.pumpAndSettle(); - await tester.tap(find.text('Graph')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-graph'))); await tester.pump(); await tester.pump(); expect(tester.takeException(), isNull); diff --git a/app/test/features/pipelines/pipelines_screen_test.dart b/app/test/features/pipelines/pipelines_screen_test.dart index c5c92354..91c1f61a 100644 --- a/app/test/features/pipelines/pipelines_screen_test.dart +++ b/app/test/features/pipelines/pipelines_screen_test.dart @@ -45,7 +45,7 @@ void main() { 'version': 2, }); - await tester.tap(find.text('Source')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pump(); expect( selectableText('name: Alpha review\nstages:\n review:\n type: model'), @@ -73,7 +73,7 @@ void main() { }); expect(find.text('Viewing v1 (latest v2).'), findsOneWidget); - await tester.tap(find.text('Source')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pump(); expect( selectableText( @@ -83,7 +83,7 @@ void main() { findsOneWidget, ); - await tester.tap(find.text('Summary')); + await tester.tap(find.byKey(const Key('pipeline-detail-tab-summary'))); await tester.pump(); await tester.tap(find.byKey(const Key('pipeline-latest-version'))); await tester.pumpAndSettle(); diff --git a/app/test/features/runs/ui/run_changes_action_test.dart b/app/test/features/runs/ui/run_changes_action_test.dart index 0089d38e..f1fdf160 100644 --- a/app/test/features/runs/ui/run_changes_action_test.dart +++ b/app/test/features/runs/ui/run_changes_action_test.dart @@ -112,7 +112,10 @@ void main() { await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes'))); await tester.pumpAndSettle(); - expect(find.text('Changes'), findsOneWidget); + expect( + find.byKey(const ValueKey('run-detail-tab-changes')), + findsOneWidget, + ); expect(find.text('lib/feature.dart'), findsOneWidget); expect( find.text('1 file changed · +2 -2 · capture incomplete'), 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 be44a2ac..8c1113da 100644 --- a/app/test/features/runs/ui/run_detail_tabs_test.dart +++ b/app/test/features/runs/ui/run_detail_tabs_test.dart @@ -25,21 +25,31 @@ void main() { RunDetailTab.changes, ]); final strip = find.byKey(const Key('run-detail-tabs')); - for (final label in ['Summary', 'Timeline', 'Artifacts', 'Changes']) { + // Icon-only tabs, each keyed by its name. + for (final name in ['summary', 'timeline', 'artifacts', 'changes']) { expect( - find.descendant(of: strip, matching: find.text(label)), + find.descendant( + of: strip, + matching: find.byKey(ValueKey('run-detail-tab-$name')), + ), findsOneWidget, ); } expect( - find.descendant(of: strip, matching: find.text('Graph')), + find.descendant( + of: strip, + matching: find.byKey(const ValueKey('run-detail-tab-graph')), + ), findsNothing, ); expect(find.byKey(runGraphPreviewKey), findsOneWidget); // Input and Output are Summary sections now, never separate tabs. - for (final label in ['Input', 'Output']) { + for (final name in ['input', 'output']) { expect( - find.descendant(of: strip, matching: find.text(label)), + find.descendant( + of: strip, + matching: find.byKey(ValueKey('run-detail-tab-$name')), + ), findsNothing, ); } diff --git a/app/test/features/runs/ui/run_detail_widget_test.dart b/app/test/features/runs/ui/run_detail_widget_test.dart index 8adfd687..af3d96e0 100644 --- a/app/test/features/runs/ui/run_detail_widget_test.dart +++ b/app/test/features/runs/ui/run_detail_widget_test.dart @@ -165,9 +165,12 @@ void main() { } Future tapTab(String label) async { - await tester.ensureVisible(find.text(label)); + final tab = find.byKey( + ValueKey('run-detail-tab-${label.toLowerCase()}'), + ); + await tester.ensureVisible(tab); await tester.pumpAndSettle(); - await tester.tap(find.text(label)); + await tester.tap(tab); await tester.pumpAndSettle(); } diff --git a/app/test/shell/attention_badge_test.dart b/app/test/shell/attention_badge_test.dart index ef331c03..961dbe24 100644 --- a/app/test/shell/attention_badge_test.dart +++ b/app/test/shell/attention_badge_test.dart @@ -92,13 +92,13 @@ void main() { testWidgets('the badge stays visible from every destination', (tester) async { await pumpShell(tester, width: 1000, cupertino: false, count: 2); - for (final label in ['Runs', 'Chat', 'Settings']) { - await tester.tap(find.text(label).last); + for (final name in ['runs', 'chat', 'search']) { + await tester.tap(find.byKey(ValueKey('shell.destination.$name'))); await tester.pumpAndSettle(); expect( find.descendant(of: find.byType(Badge), matching: find.text('2')), findsOneWidget, - reason: 'badge missing on $label', + reason: 'badge missing on $name', ); } }); diff --git a/app/test/shell/floating_tab_bar_test.dart b/app/test/shell/floating_tab_bar_test.dart index 6de8dff2..b9aec69b 100644 --- a/app/test/shell/floating_tab_bar_test.dart +++ b/app/test/shell/floating_tab_bar_test.dart @@ -14,11 +14,6 @@ void main() { matching: find.byType(GlassPill), ); - Finder barText(String label) => find.descendant( - of: find.byType(FloatingDestinationBar), - matching: find.text(label), - ); - Future setSize(WidgetTester tester, Size size) async { tester.view.physicalSize = size; tester.view.devicePixelRatio = 1; @@ -74,7 +69,14 @@ void main() { expect(rect.right, 1200 - 16); expect(rect.bottom, 800 - 16); expect(rect.width, lessThan(1200 * 0.6)); - expect(rect.width, greaterThan(5 * 72)); + // Four icon-only tabs (Settings opens from the Pipelines bar). + expect( + rect.width, + 4 * + (cupertino + ? FloatingDestinationBar.cupertinoTabWidth + : FloatingDestinationBar.materialTabWidth), + ); // No rail or sidebar: the content starts at the left edge. expect(find.byType(NavigationRail), findsNothing); expect(find.byType(CupertinoListTile), findsNothing); @@ -143,12 +145,16 @@ void main() { await tester.pumpWidget(shell(cupertino: cupertino)); await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); await tester.pumpAndSettle(); - expect( - tester.getSemantics(barText('Runs')), - isSemantics(isSelected: true), + final runs = tester.getSemantics( + find.byKey(const ValueKey('shell.destination.runs')), ); + expect(runs, isSemantics(isSelected: true)); + // Icon-only, yet the tab keeps its name for assistive technology. + expect(runs.label, startsWith('Runs')); expect( - tester.getSemantics(barText('Chat')), + tester.getSemantics( + find.byKey(const ValueKey('shell.destination.chat')), + ), isNot(isSemantics(isSelected: true)), ); semantics.dispose(); diff --git a/app/test/shell/pane_bar_row_test.dart b/app/test/shell/pane_bar_row_test.dart index 2f24dfef..af4a57d0 100644 --- a/app/test/shell/pane_bar_row_test.dart +++ b/app/test/shell/pane_bar_row_test.dart @@ -151,7 +151,7 @@ void main() { }); testWidgets('$host 1200: the item\'s tabs float at the bottom of its ' - 'pane, beside the shell\'s tab bar', (tester) async { + 'pane, above the shell\'s tab bar', (tester) async { await setSize(tester, const Size(1200, 800)); await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pump(); @@ -174,8 +174,11 @@ void main() { 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)); + // The shell's tabs keep the bottom right; the item's float a gap + // above them in the detail pane, never on them. + expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(itemTabs.bottom, closeTo(shellTabs.top - kStackedBarGap, 0.5)); expect(itemTabs.left, greaterThanOrEqualTo(body.left)); expect(itemTabs.overlaps(shellTabs), isFalse); // The item's list starts below its bar and clears its tabs at rest. diff --git a/app/test/shell/shell_bar_test.dart b/app/test/shell/shell_bar_test.dart index 2a6c889d..82702b9a 100644 --- a/app/test/shell/shell_bar_test.dart +++ b/app/test/shell/shell_bar_test.dart @@ -52,13 +52,28 @@ void main() { expect(find.byKey(const Key('run-more')), findsNothing); }); - testWidgets('$host: Search is the fifth tab', (tester) async { + testWidgets('$host: Search is the fourth tab; Settings is not a tab', ( + tester, + ) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.reset); await tester.pumpWidget(_app(cupertino: cupertino, open: false)); expect(AppDestination.values, hasLength(5)); - expect(find.text('Search'), findsOneWidget); + expect(shellTabDestinations, [ + AppDestination.pipelines, + AppDestination.runs, + AppDestination.chat, + AppDestination.search, + ]); + expect( + find.byKey(const ValueKey('shell.destination.search')), + findsOneWidget, + ); + expect( + find.byKey(const ValueKey('shell.destination.settings')), + findsNothing, + ); expect(find.byKey(const ValueKey('shell.search')), findsNothing); expect(find.byType(FloatingDestinationBar), findsOneWidget); }); @@ -76,7 +91,7 @@ void main() { matching: find.byType(GlassPill), ); expect(tester.getSize(destinationPill).width, 358); - await tester.tap(find.text('Chat')); + await tester.tap(find.byKey(const ValueKey('shell.destination.chat'))); await tester.pump(); expect(find.text('Chat — Not implemented'), findsOneWidget); }); diff --git a/app/test/shell/split_destination_bar_test.dart b/app/test/shell/split_destination_bar_test.dart index 77efc529..abebf894 100644 --- a/app/test/shell/split_destination_bar_test.dart +++ b/app/test/shell/split_destination_bar_test.dart @@ -5,11 +5,13 @@ 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/floating_destination_bar.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. +/// bar keeps its place at the bottom right (near the thumb). The item's own +/// bottom control (its tabs, or a composer) floats above it with a gap, and +/// the item's content clears both. void main() { Future setSize(WidgetTester tester, Size size) async { tester.view.physicalSize = size; @@ -43,9 +45,36 @@ void main() { ), ); + /// A detail with its own floating tabs over a list, like run detail. + Widget tabsDetail(bool cupertino) => FloatingBarOverlay( + bar: KeyedSubtree( + key: const Key('detail-tabs'), + child: FloatingDestinationBar( + cupertino: cupertino, + currentIndex: 0, + onTap: (_) {}, + items: const [ + FloatingDestinationItem(icon: Icon(Icons.summarize), label: 'One'), + FloatingDestinationItem(icon: Icon(Icons.timeline), label: 'Two'), + FloatingDestinationItem(icon: Icon(Icons.inventory), label: 'Three'), + ], + ), + ), + child: Builder( + builder: (context) => ListView( + key: const Key('detail-list'), + children: [ + for (var index = 0; index < 40; index++) + SizedBox(height: 40, child: Text('item $index')), + ], + ), + ), + ); + Widget shell({ required bool cupertino, bool split = true, + bool tabs = false, double textScale = 1, }) { final app = AdaptiveShell( @@ -53,7 +82,10 @@ void main() { destination: AppDestination.chat, destinationBodies: { AppDestination.chat: (_) => split - ? ListDetailPanes(list: listBody(), detail: composerDetail()) + ? ListDetailPanes( + list: listBody(), + detail: tabs ? tabsDetail(cupertino) : composerDetail(), + ) : listBody(), }, ); @@ -78,8 +110,8 @@ void main() { 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 { + testWidgets('$host $width split: the destination bar stays bottom ' + 'right and the composer floats above it', (tester) async { await setSize(tester, Size(width, 800)); await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pump(); @@ -92,23 +124,59 @@ void main() { 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'); + // Compact at the window's right edge, over the detail pane only. + expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5)); expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + expect(pill.width, lessThan(body.width / 2)); + expect(pill.overlaps(list), isFalse, reason: 'never over the list'); + expect(pill.left, greaterThan(body.left)); - // The detail keeps only the system inset (none here): its composer - // reaches the bottom edge, below the level of the shell's pill. + // The composer's box starts a gap above the shell's pill (the real + // composer pads its pill by another 12 inside that box). final composer = tester.getRect(find.byKey(const Key('composer'))); - expect(composer.bottom, 800); expect(composer.left, body.left); - expect(composer.top, greaterThan(pill.top)); + expect(composer.overlaps(pill), isFalse); + expect(pill.top - composer.bottom, closeTo(kStackedBarGap, 0.5)); - // The list still clears the bar. + // The list is not under the bar: it clears only the system inset. final listContext = tester.element(find.byKey(const Key('list'))); + expect(MediaQuery.paddingOf(listContext).bottom, 0); + }); + + testWidgets('$host $width split: the item tabs float above the ' + 'destination bar with a gap, and its content clears both', ( + tester, + ) async { + await setSize(tester, Size(width, 800)); + await tester.pumpWidget(shell(cupertino: cupertino, tabs: true)); + await tester.pump(); + await tester.pump(); + + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + final pill = destinationPill(tester); + final tabs = tester.getRect( + find + .descendant( + of: find.byKey(const Key('detail-tabs')), + matching: find.byType(GlassPill), + ) + .first, + ); + expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5)); + expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5)); + expect(tabs.left, greaterThan(body.left)); + expect(tabs.overlaps(pill), isFalse); + expect(pill.top - tabs.bottom, closeTo(kStackedBarGap, 0.5)); + + // The item's list pads its end clear of both pills. + final listContext = tester.element( + find.byKey(const Key('detail-list')), + ); expect( MediaQuery.paddingOf(listContext).bottom, - greaterThanOrEqualTo(pill.height), + closeTo(800 - tabs.top, 0.5), ); }); } @@ -134,17 +202,21 @@ void main() { }); 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 { + testWidgets('$host $width split at 2x: both bars lay out over the ' + 'detail pane without overflow', (tester) async { await setSize(tester, Size(width, 800)); - await tester.pumpWidget(shell(cupertino: cupertino, textScale: 2)); + await tester.pumpWidget( + shell(cupertino: cupertino, tabs: true, textScale: 2), + ); await tester.pump(); await tester.pump(); expect(tester.takeException(), isNull); - final list = tester.getRect( - find.byKey(const ValueKey('list-detail-list')), + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), ); - expect(destinationPill(tester).right, lessThanOrEqualTo(list.right)); + final pill = destinationPill(tester); + expect(pill.left, greaterThanOrEqualTo(body.left)); + expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5)); }); } } diff --git a/app/test/shell/split_detail_pages_test.dart b/app/test/shell/split_detail_pages_test.dart new file mode 100644 index 00000000..8a507cb3 --- /dev/null +++ b/app/test/shell/split_detail_pages_test.dart @@ -0,0 +1,136 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/runs/data/runs_repository.dart'; +import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart'; +import 'package:pipelines_app/features/runs/ui/run_detail_view.dart'; +import 'package:pipelines_app/features/runs/ui/runs_controller.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/ui/adaptive/floating_bar_layout.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; + +import '../features/runs/ui/run_detail_graph_support.dart'; +import '../features/runs/ui/run_detail_visit_support.dart'; + +/// On a wide split window (unfolded foldable, desktop) the real run detail +/// and the stage page it opens keep the shell's tab bar at the bottom right +/// and float their own tabs above it with a gap; the stage page opens inside +/// the detail pane instead of covering the shell. +void main() { + Rect pillOf(WidgetTester tester, Finder owner) => tester.getRect( + find.descendant(of: owner, matching: find.byType(GlassPill)).first, + ); + + Rect shellPill(WidgetTester tester) => tester.getRect( + find + .ancestor( + of: find.byKey(const ValueKey('shell.destination.runs')).first, + matching: find.byType(GlassPill), + ) + .first, + ); + + Future pumpSplitRun(WidgetTester tester, bool cupertino) async { + tester.view.physicalSize = const Size(1200, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + final gateway = RunDetailFakeGateway(visitRunFixture()); + final controller = RunsController(RunsRepository(gateway)); + addTearDown(controller.dispose); + await controller.select(77); + final shell = AdaptiveShell( + cupertino: cupertino, + destination: AppDestination.runs, + destinationBodies: { + AppDestination.runs: (_) => ListDetailPanes( + list: ListView( + children: [for (var i = 0; i < 30; i++) Text('run row $i')], + ), + detail: DetailPane( + destination: AppDestination.runs, + implyBack: false, + builder: (_) => RunDetailView( + controller: controller, + gateway: gateway, + onBack: () {}, + ), + ), + ), + }, + ); + await tester.pumpWidget( + cupertino + ? CupertinoApp(home: shell) + : MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: shell, + ), + ); + await tester.pumpAndSettle(); + } + + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + + testWidgets('$host 1200: run tabs float above the shell bar, and the ' + 'stage page opens in the pane with its tabs above it too', ( + tester, + ) async { + await pumpSplitRun(tester, cupertino); + final body = tester.getRect( + find.byKey(const ValueKey('list-detail-body')), + ); + var main = shellPill(tester); + expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(main.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); + + final runTabs = pillOf(tester, find.byKey(const Key('run-detail-tabs'))); + expect(runTabs.left, greaterThanOrEqualTo(body.left)); + expect(runTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(runTabs.overlaps(main), isFalse); + expect(main.top - runTabs.bottom, closeTo(kStackedBarGap, 0.5)); + + // Open the stage page from the timeline. + await openRunDetailTab(tester, RunDetailTab.timeline); + final row = find.byKey(const ValueKey('run-timeline-visit-1')); + await tester.ensureVisible(row); + await tester.pumpAndSettle(); + await tester.tap(row); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('run-visit-back')), findsOneWidget); + // The page covers only the detail pane: the root navigator has nothing + // pushed, and the list and the shell's tab bar stay in place. + expect( + tester.state(find.byType(Navigator).first).canPop(), + isFalse, + ); + expect(find.text('run row 0'), findsOneWidget); + final back = tester.getRect(find.byKey(const Key('run-visit-back'))); + expect(back.left, greaterThanOrEqualTo(body.left)); + main = shellPill(tester); + expect(main.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + final visitTabs = pillOf( + tester, + find.byKey(const Key('run-visit-tabs')).last, + ); + expect(visitTabs.left, greaterThanOrEqualTo(body.left)); + expect(visitTabs.overlaps(main), isFalse); + expect(main.top - visitTabs.bottom, closeTo(kStackedBarGap, 0.5)); + expect(tester.takeException(), isNull); + + // The shell's tabs still work over the open stage page. + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); + await tester.pumpAndSettle(); + + // Back closes the page inside the pane, back to the run. + await tester.tap(find.byKey(const Key('run-visit-back'))); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('run-visit-back')), findsNothing); + expect(find.byKey(const Key('run-detail-tabs')), findsOneWidget); + }); + } +} diff --git a/app/test/shell/split_status_bar_test.dart b/app/test/shell/split_status_bar_test.dart index 299204b8..6e3f5796 100644 --- a/app/test/shell/split_status_bar_test.dart +++ b/app/test/shell/split_status_bar_test.dart @@ -15,15 +15,19 @@ 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. +/// detail pane, above (never on) the shell's tab bar at the bottom right. void main() { const statusBar = 40.0; - Future setUp(WidgetTester tester, Size size) async { + Future setUp( + WidgetTester tester, + Size size, { + double bottom = 0, + }) async { tester.view.physicalSize = size; tester.view.devicePixelRatio = 1; - tester.view.padding = const FakeViewPadding(top: statusBar); - tester.view.viewPadding = const FakeViewPadding(top: statusBar); + tester.view.padding = FakeViewPadding(top: statusBar, bottom: bottom); + tester.view.viewPadding = FakeViewPadding(top: statusBar, bottom: bottom); addTearDown(tester.view.reset); } @@ -156,9 +160,10 @@ void main() { 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)); + testWidgets('$host split: the item tabs float above the shell tab bar ' + 'at the bottom right of the detail pane', (tester) async { + // A gesture-navigation inset as on the unfolded foldable. + await setUp(tester, const Size(1200, 800), bottom: 24); await tester.pumpWidget(shell(cupertino, tabbedItem)); await tester.pump(); await tester.pump(); @@ -167,7 +172,6 @@ void main() { 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( @@ -178,8 +182,13 @@ void main() { ) .first, ); + // The shell's bar keeps the bottom right, above the system inset; the + // item's tabs sit a gap above it, both at the trailing edge. + expect(shellTabs.bottom, closeTo(800 - 24, 0.5)); + expect(shellTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); expect(shellTabs.overlaps(tabs), isFalse); - expect(shellTabs.right, lessThanOrEqualTo(body.left)); + expect(shellTabs.top - tabs.bottom, closeTo(kStackedBarGap, 0.5)); // The item's list clears its tabs at rest. final list = tester.element(find.byKey(const Key('item-list'))); expect( diff --git a/app/test/ui/adaptive/icon_only_tab_bars_test.dart b/app/test/ui/adaptive/icon_only_tab_bars_test.dart new file mode 100644 index 00000000..6f82a8d5 --- /dev/null +++ b/app/test/ui/adaptive/icon_only_tab_bars_test.dart @@ -0,0 +1,127 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart'; +import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart'; +import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart'; +import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart'; +import 'package:pipelines_app/shell/destination.dart'; +import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; + +/// Every bottom tab bar shows icons only, yet each tab keeps its name for +/// assistive technology (and a Material tooltip), its selected state and its +/// test key; the icons within a bar, and against the shell's tabs a detail's +/// bar floats above, are distinct. +void main() { + Widget host(bool cupertino, Widget bar) { + final body = Align(alignment: Alignment.bottomCenter, child: bar); + return cupertino + ? CupertinoApp(home: CupertinoPageScaffold(child: body)) + : MaterialApp(home: Scaffold(body: body)); + } + + final bars = )>{ + 'run detail': ( + RunDetailTabStrip(selected: RunDetailTab.summary, onSelected: (_) {}), + [ + for (final tab in renderedRunDetailTabs) + ('run-detail-tab-${tab.name}', tab.label), + ], + ), + 'stage page': ( + RunVisitSectionStrip( + selected: RunVisitSection.summary, + onSelected: (_) {}, + ), + [ + for (final section in shownVisitSections) + ('run-visit-tab-${section.name}', section.label), + ], + ), + 'pipeline detail': ( + PipelineDetailTabs( + selected: PipelineDetailTab.summary, + onSelected: (_) {}, + ), + [ + for (final tab in PipelineDetailTab.values) + ('pipeline-detail-tab-${tab.name}', tab.label), + ], + ), + }; + + for (final cupertino in [false, true]) { + final name = cupertino ? 'Cupertino' : 'Material'; + for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) { + testWidgets('$name $label tabs are icons named for assistive ' + 'technology', (tester) async { + final semantics = tester.ensureSemantics(); + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(host(cupertino, bar)); + await tester.pumpAndSettle(); + + final floating = find.byType(FloatingDestinationBar); + if (cupertino) { + // No label is drawn at all. + expect( + find.descendant(of: floating, matching: find.byType(Text)), + findsNothing, + ); + } else { + // NavigationBar keeps its label hidden (for semantics only). + expect( + NavigationBarTheme.of( + tester.element(find.byType(NavigationDestination).first), + ).labelBehavior, + NavigationDestinationLabelBehavior.alwaysHide, + ); + } + for (final (index, (key, tabLabel)) in tabs.indexed) { + final node = tester.getSemantics(find.byKey(ValueKey(key))); + expect(node.label, startsWith(tabLabel), reason: key); + expect( + node, + index == 0 + ? isSemantics(isSelected: true) + : isNot(isSemantics(isSelected: true)), + reason: key, + ); + } + // Distinct glyphs within the bar. + final icons = tester + .widgetList( + find.descendant(of: floating, matching: find.byType(Icon)), + ) + .map((icon) => icon.icon) + .toSet(); + expect(icons.length, greaterThanOrEqualTo(tabs.length)); + semantics.dispose(); + }); + } + } + + test('detail tab icons differ from the shell tabs they float above', () { + final shell = { + for (final destination in shellTabDestinations) ...[ + destinationDetails(destination).icon, + destinationDetails(destination).cupertinoIcon, + ], + }; + final details = [ + for (final tab in renderedRunDetailTabs) ...[tab.icon, tab.cupertinoIcon], + for (final section in shownVisitSections) ...[ + section.icon, + section.cupertinoIcon, + ], + for (final tab in PipelineDetailTab.values) ...[ + tab.icon, + tab.cupertinoIcon, + ], + ]; + for (final icon in details) { + expect(shell.contains(icon), isFalse, reason: '$icon'); + } + }); +} diff --git a/app/test/widget_test.dart b/app/test/widget_test.dart index 7ad71f1b..154c5137 100644 --- a/app/test/widget_test.dart +++ b/app/test/widget_test.dart @@ -28,7 +28,7 @@ void main() { expect(find.byType(NavigationBar), findsOneWidget); expect(find.byType(NavigationRail), findsNothing); expect(tester.takeException(), isNull); - await tester.tap(find.text('Runs').last); + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); await tester.pumpAndSettle(); expect(find.text('Runs — Not implemented'), findsOneWidget); }, @@ -104,9 +104,9 @@ void main() { ); await tester.tap(find.text('Builds: 0')); await tester.pump(); - await tester.tap(find.text('Runs').last); + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); await tester.pumpAndSettle(); - await tester.tap(find.text('Pipelines').last); + await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines'))); await tester.pumpAndSettle(); expect(find.text('Builds: 1'), findsOneWidget); });