From 547d15c842dda9d5ce8100efc6335f3532ad803e Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 12 Nov 2026 02:27:41 +0000 Subject: [PATCH] Add desktop navigation rail with Settings Replace wide-layout floating destination controls with a full-height Material navigation rail, keeping badges and existing navigation behavior. Pin Settings to the rail and preserve the phone layout and pane/window clearance. --- app/lib/application/pipelines_app.dart | 2 +- app/lib/features/pipelines/screen.dart | 6 +- app/lib/shell/adaptive_shell.dart | 62 +++- app/lib/shell/destination.dart | 7 +- app/lib/shell/list_detail.dart | 5 +- app/lib/shell/list_detail_policy.dart | 4 +- app/lib/shell/navigation_rail.dart | 145 +++++++++ app/lib/shell/shell_rail_scope.dart | 35 +++ app/lib/shell/windows/window_host.dart | 60 ++-- app/notes/navigation-rail.md | 124 ++++++++ .../application/chat_registration_test.dart | 10 +- app/test/application/settings_page_test.dart | 61 +++- .../tab_location_navigation_test.dart | 8 +- .../features/chat/chat_list_detail_test.dart | 8 +- .../chat/chat_sidebar_clearance_test.dart | 10 +- .../chat/chat_split_integration_test.dart | 11 +- app/test/shell/attention_badge_test.dart | 9 +- app/test/shell/floating_tab_bar_test.dart | 15 +- app/test/shell/list_pane_resize_test.dart | 21 +- app/test/shell/navigation_rail_test.dart | 283 ++++++++++++++++++ app/test/shell/pane_bar_row_test.dart | 6 +- .../shell/split_destination_bar_test.dart | 23 +- app/test/shell/split_detail_pages_test.dart | 6 +- app/test/shell/split_status_bar_test.dart | 4 +- 24 files changed, 835 insertions(+), 90 deletions(-) create mode 100644 app/lib/shell/navigation_rail.dart create mode 100644 app/lib/shell/shell_rail_scope.dart create mode 100644 app/notes/navigation-rail.md create mode 100644 app/test/shell/navigation_rail_test.dart diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index f3a52b45..6c39eb78 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -801,7 +801,7 @@ class _PipelinesAppState extends State builder: (context, count, _) => _terminals.surround( _shellFor(route, count), onChat: route.kind == AppRouteKind.chat, - windows: WindowHost(manager: _windows), + windows: WindowHost(manager: _windows, reservesRail: true), ), ); diff --git a/app/lib/features/pipelines/screen.dart b/app/lib/features/pipelines/screen.dart index f6a1a810..fb0ea904 100644 --- a/app/lib/features/pipelines/screen.dart +++ b/app/lib/features/pipelines/screen.dart @@ -2,6 +2,7 @@ import '../../ui/adaptive/segmented_bar.dart'; import '../../shell/destination.dart'; import '../../shell/detail_page.dart'; import '../../shell/list_detail.dart'; +import '../../shell/shell_rail_scope.dart'; import 'package:flutter/material.dart'; import '../../core/api_gateway.dart'; @@ -288,7 +289,10 @@ class _PipelinesScreenState extends State { if (listShown && widget.onOpenSchedules != null) _schedulesButton(context), _refreshButton(context), - if (listShown && widget.onOpenSettings != null) + // A wide window's rail offers Settings; the gear stays on a phone. + if (listShown && + !ShellRailScope.isShown(context) && + widget.onOpenSettings != null) _settingsButton(context), ], child: body, diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index 60a97fa4..3cd8a5e5 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -7,6 +7,8 @@ import '../ui/adaptive/floating_destination_bar.dart'; import 'attention_badge.dart'; import 'destination.dart'; import 'list_detail.dart'; +import 'navigation_rail.dart'; +import 'shell_rail_scope.dart'; import 'list_pane_widths.dart'; import 'shell_bar.dart'; import 'shell_chat_shortcut.dart'; @@ -223,7 +225,8 @@ class _AdaptiveShellState extends State { ); // 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); + final media = MediaQuery.of(context); + final system = media.padding; // A page (Settings) closes to Pipelines on the system Back too; at a // tab's root Back returns to the tab opened before it. Only with neither // does Back reach the platform, so Android's (predictive) Back closes the @@ -237,15 +240,60 @@ class _AdaptiveShellState extends State { }, child: child, ); + // On a wide window the destinations sit in a rail at the left edge, and + // the floating bar is not built; the scaffold gets the rest of the window. + // The tree has the same shape at every width (an empty rail slot on a + // phone), so resizing across the rail's threshold never remounts a + // destination. + final rail = showsNavigationRail(context); + final scaffold = Scaffold( + extendBodyBehindAppBar: true, + appBar: topBar, + body: _destinationStack(contents), + extendBody: true, + bottomNavigationBar: rail ? null : bar, + ); return backable( ShellSystemInsets( padding: system, - child: Scaffold( - extendBodyBehindAppBar: true, - appBar: topBar, - body: _destinationStack(contents), - extendBody: true, - bottomNavigationBar: bar, + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // Badges (running runs, unread chats) rebuild the rail alone. + ListenableBuilder( + listenable: _bar.badges, + builder: (context, _) => rail + ? ShellNavigationRail( + selected: _selected, + icon: (destination) => _icon( + destination, + destinationDetails(destination).icon, + ), + onSelected: _select, + padding: EdgeInsets.only( + top: system.top, + bottom: system.bottom, + ), + ) + : const SizedBox.shrink(), + ), + // Three children at every width, so the body keeps its slot. + rail + ? const VerticalDivider(width: 1, thickness: 1) + : const SizedBox.shrink(), + Expanded( + // Beside the rail the panes lay out in the width the rail leaves, + // which the window's width fixes here (not in a layout pass), so + // the panes and their pages rebuild with the window. + child: ShellRailScope( + shown: rail, + bodyWidth: rail + ? media.size.width - kNavigationRailSpace + : null, + child: scaffold, + ), + ), + ], ), ), ); diff --git a/app/lib/shell/destination.dart b/app/lib/shell/destination.dart index a62eb13e..9fe91835 100644 --- a/app/lib/shell/destination.dart +++ b/app/lib/shell/destination.dart @@ -2,9 +2,10 @@ import 'package:flutter/material.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. +/// The destinations the shell's tab bar (or, on a wide window, its rail) offers, +/// in order. Settings is a destination the shell can show (its route is +/// `/settings`), but it opens as a page, from the rail's foot on a wide window +/// or the Pipelines bar's gear on a phone, instead of being a tab. const List shellTabDestinations = [ AppDestination.pipelines, AppDestination.runs, diff --git a/app/lib/shell/list_detail.dart b/app/lib/shell/list_detail.dart index 13a0a3cd..ce992640 100644 --- a/app/lib/shell/list_detail.dart +++ b/app/lib/shell/list_detail.dart @@ -7,6 +7,7 @@ import 'detail_pane_navigator.dart'; import 'list_detail_policy.dart'; import 'list_pane_divider.dart'; import 'list_pane_widths.dart'; +import 'shell_rail_scope.dart'; import 'shell_bar.dart'; export 'list_detail_policy.dart'; @@ -64,7 +65,7 @@ class ListPaneWidth extends StatelessWidget { builder: (context, constraints) { final width = split ? listDetailListWidth( - MediaQuery.sizeOf(context).width, + ShellRailScope.windowWidth(context), constraints.maxWidth, preferredWidth, ) @@ -143,7 +144,7 @@ class _ListDetailPanesState extends State { listenable: widths, builder: (context, _) => LayoutBuilder( builder: (context, constraints) { - final window = media.size.width; + final window = ShellRailScope.windowWidth(context); final available = constraints.maxWidth; final preferred = widths.widthFor(key); final resizable = diff --git a/app/lib/shell/list_detail_policy.dart b/app/lib/shell/list_detail_policy.dart index ffb1589f..fa760f25 100644 --- a/app/lib/shell/list_detail_policy.dart +++ b/app/lib/shell/list_detail_policy.dart @@ -2,6 +2,8 @@ import 'dart:math' as math; import 'package:flutter/widgets.dart'; +import 'shell_rail_scope.dart'; + /// At least this wide, a destination keeps its list beside the open item /// (with the destination rail) instead of pushing the item as its own page. const double kListDetailMinWidth = 600; @@ -15,7 +17,7 @@ const double kListPaneMaxWidth = 440; /// Whether the window at [context] shows list and detail side by side. bool showsListBesideDetail(BuildContext context) => - MediaQuery.sizeOf(context).width >= kListDetailMinWidth; + ShellRailScope.windowWidth(context) >= kListDetailMinWidth; /// The narrowest list pane a drag leaves. const double kListPaneMinWidth = 240; diff --git a/app/lib/shell/navigation_rail.dart b/app/lib/shell/navigation_rail.dart new file mode 100644 index 00000000..93f6deec --- /dev/null +++ b/app/lib/shell/navigation_rail.dart @@ -0,0 +1,145 @@ +import 'package:flutter/material.dart'; + +import 'destination.dart'; +import 'list_detail_policy.dart'; + +/// The width of the destination rail on a wide window. +const double kNavigationRailWidth = 96; + +/// The rail with its divider: what the rail takes from a wide window's width. +const double kNavigationRailSpace = kNavigationRailWidth + 1; + +/// The narrowest window that shows the destination rail: the list-detail +/// minimum for the body beside it, plus the rail and its divider (the space the +/// shell takes from the window). Narrower windows keep the floating destination +/// bar, unchanged. +const double kNavigationRailMinWindowWidth = + kListDetailMinWidth + kNavigationRailSpace; + +/// Whether the window at [context] shows the destination rail. Read from the +/// window's own [MediaQuery], so the shell and the floating windows layer +/// (which sits above the shell) agree. +bool showsNavigationRail(BuildContext context) => + MediaQuery.sizeOf(context).width >= kNavigationRailMinWindowWidth; + +/// The wide layout's left-edge navigation: a Material [NavigationRail] with +/// an icon and a label per tab, the selected tab marked by the rail's +/// indicator, and Settings pinned to its bottom. +/// +/// [icon] builds each tab's icon (its running or unread badge included), so +/// the rail shows the same counts the floating bar did. [selected] is the +/// shell's destination: Settings (a page, not a tab) selects no tab but its +/// own item. +class ShellNavigationRail extends StatelessWidget { + const ShellNavigationRail({ + super.key, + required this.selected, + required this.icon, + required this.onSelected, + this.padding = EdgeInsets.zero, + }); + + final AppDestination selected; + final Widget Function(AppDestination destination) icon; + final ValueChanged onSelected; + + /// The system insets the rail keeps clear of: the status bar above and the + /// navigation bar below. + final EdgeInsets padding; + + @override + Widget build(BuildContext context) { + final index = shellTabDestinations.indexOf(selected); + return Padding( + padding: padding, + child: SizedBox( + width: kNavigationRailWidth, + child: NavigationRail( + key: const ValueKey('shell.navigation-rail'), + minWidth: kNavigationRailWidth, + labelType: NavigationRailLabelType.all, + selectedIndex: index < 0 ? null : index, + onDestinationSelected: (value) => + onSelected(shellTabDestinations[value]), + destinations: [ + for (final destination in shellTabDestinations) + NavigationRailDestination( + icon: KeyedSubtree( + key: ValueKey('shell.destination.${destination.name}'), + // The bar it replaces named each tab in a tooltip too. + child: Tooltip( + message: destinationDetails(destination).label, + child: icon(destination), + ), + ), + label: Text(destinationDetails(destination).label), + ), + ], + trailingAtBottom: true, + trailing: _SettingsRailItem( + selected: selected == AppDestination.settings, + onTap: () => onSelected(AppDestination.settings), + ), + ), + ), + ); + } +} + +/// Settings at the rail's foot, drawn as a [NavigationRailDestination] is: an +/// icon on a stadium indicator with its label under it, and the same colours. +/// It is not a [NavigationRailDestination] itself because the rail's +/// destination list is the tabs, and `trailing` is what the rail pins. +class _SettingsRailItem extends StatelessWidget { + const _SettingsRailItem({required this.selected, required this.onTap}); + + final bool selected; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + final scheme = Theme.of(context).colorScheme; + final item = destinationDetails(AppDestination.settings); + final foreground = selected + ? scheme.onSecondaryContainer + : scheme.onSurfaceVariant; + final textStyle = Theme.of(context).textTheme.labelMedium?.copyWith( + color: foreground, + fontWeight: selected ? FontWeight.w600 : FontWeight.w500, + ); + return Semantics( + button: true, + selected: selected, + label: item.label, + child: ExcludeSemantics( + child: InkWell( + key: const ValueKey('shell.destination.settings'), + onTap: onTap, + child: SizedBox( + width: kNavigationRailWidth, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 12), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 56, + height: 32, + alignment: Alignment.center, + decoration: ShapeDecoration( + shape: const StadiumBorder(), + color: selected ? scheme.secondaryContainer : null, + ), + child: Icon(item.icon, color: foreground), + ), + const SizedBox(height: 4), + Text(item.label, style: textStyle), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/app/lib/shell/shell_rail_scope.dart b/app/lib/shell/shell_rail_scope.dart new file mode 100644 index 00000000..024f0a28 --- /dev/null +++ b/app/lib/shell/shell_rail_scope.dart @@ -0,0 +1,35 @@ +import 'package:flutter/widgets.dart'; + +/// Marks the content beside the destination rail. A wide window's content +/// lays out in the width left beside the rail, so list and detail panes read +/// that width ([windowWidth]) instead of the window's. Outside the scope (a +/// phone, a route pushed over the shell) the window's own width applies. +class ShellRailScope extends InheritedWidget { + const ShellRailScope({ + super.key, + required this.shown, + required this.bodyWidth, + required super.child, + }); + + /// Whether the rail is shown beside this content. + final bool shown; + + /// The width beside the rail; null when no rail is shown. + final double? bodyWidth; + + /// Whether the rail is shown beside [context]'s content. + static bool isShown(BuildContext context) => + context.dependOnInheritedWidgetOfExactType()?.shown ?? + false; + + /// The width the panes of [context] lay out in: the body beside the rail, + /// or else the window. + static double windowWidth(BuildContext context) => + context.dependOnInheritedWidgetOfExactType()?.bodyWidth ?? + MediaQuery.sizeOf(context).width; + + @override + bool updateShouldNotify(ShellRailScope oldWidget) => + shown != oldWidget.shown || bodyWidth != oldWidget.bodyWidth; +} diff --git a/app/lib/shell/windows/window_host.dart b/app/lib/shell/windows/window_host.dart index f4fc1f84..682d9b4b 100644 --- a/app/lib/shell/windows/window_host.dart +++ b/app/lib/shell/windows/window_host.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import '../navigation_rail.dart'; import 'window_focus.dart'; import 'window_layer.dart'; import 'window_manager.dart'; @@ -18,7 +19,16 @@ import 'window_shortcuts.dart'; /// /// The host fills its parent and takes no input between windows. class WindowHost extends StatefulWidget { - const WindowHost({super.key, required this.manager}); + const WindowHost({ + super.key, + required this.manager, + this.reservesRail = false, + }); + + /// Whether the shell beside this host shows the destination rail on the + /// window's left edge; the windows then keep to the right of it while the + /// window is wide enough for the rail (see [showsNavigationRail]). + final bool reservesRail; final WindowManager manager; @@ -119,24 +129,36 @@ class _WindowHostState extends State { ]), builder: (context, _) => LayoutBuilder( builder: (context, constraints) { - final bounds = constraints.biggest; - return Stack( - fit: StackFit.expand, - children: [ - for (final entry in windows) - if (manager.kinds[entry.kind] case final kind?) - WindowLayer( - key: ValueKey(entry.id), - manager: manager, - kind: kind, - entry: entry, - visible: - manager.isVisible(entry) && - bounds.width >= kind.minHostWidth, - bounds: bounds, - focus: _focus, - ), - ], + // Beside the destination rail the windows keep to the page's + // right, so they never sit under the rail. + // The shell takes the rail and its divider (kNavigationRailSpace). + final leading = widget.reservesRail && showsNavigationRail(context) + ? kNavigationRailSpace + : 0.0; + final bounds = Size( + constraints.maxWidth - leading, + constraints.maxHeight, + ); + return Padding( + padding: EdgeInsetsDirectional.only(start: leading), + child: Stack( + fit: StackFit.expand, + children: [ + for (final entry in windows) + if (manager.kinds[entry.kind] case final kind?) + WindowLayer( + key: ValueKey(entry.id), + manager: manager, + kind: kind, + entry: entry, + visible: + manager.isVisible(entry) && + bounds.width >= kind.minHostWidth, + bounds: bounds, + focus: _focus, + ), + ], + ), ); }, ), diff --git a/app/notes/navigation-rail.md b/app/notes/navigation-rail.md new file mode 100644 index 00000000..544302a5 --- /dev/null +++ b/app/notes/navigation-rail.md @@ -0,0 +1,124 @@ +# Wide destination rail with Settings + +On a wide window the shell's four destinations (Pipelines, Runs, Chat, Search) +move from the floating bottom-left pill to a Material `NavigationRail` at the +left edge, with Settings pinned to its foot. The rail keeps the running and +unread badges. The Pipelines toolbar's Settings gear is removed where the rail +shows. Phone and narrow layouts are unchanged. + +## Design + +- **Threshold.** The rail shows at window width >= 697 + (`kNavigationRailMinWindowWidth` = `kListDetailMinWidth` 600 + + `kNavigationRailSpace` 97, the rail plus its divider). The body beside the + rail therefore still meets the list/detail split threshold at 697 px. Between + 600 and 696 px the floating bar and split layout stay as before. +- **Layout.** `AdaptiveShell.build` returns the same tree at every width: + `Row[rail slot, divider slot, Expanded(ShellRailScope(Scaffold))]`. On a + phone the first two slots are empty. Resizing across the threshold does not + remount a destination, and pages pushed over a tab keep their state. +- **Body width.** `ShellRailScope.bodyWidth` is the window width less the rail + and its divider (`kNavigationRailSpace` = 97), computed in `build`. The + list/detail policy reads it through `ShellRailScope.windowWidth` + (`list_detail.dart`, `list_detail_policy.dart`), so `showsListBesideDetail` + and the pane widths follow the body. Outside the scope the window width still + applies. +- **Rail items** (`navigation_rail.dart`). Four `NavigationRailDestination`s + with `labelType: all`, `trailingAtBottom: true`. Each tab's icon keeps its + badge (`_icon`), a `Tooltip` with its label, and the `shell.destination.` + key the floating bar used. Settings is a custom `_SettingsRailItem` in + `trailing`, styled like a rail destination (stadium indicator, same colours). + A `NavigationRailDestination` cannot be pinned, so it is not one. +- **Window host.** Floating windows overlay the whole app, so `WindowHost` takes + `reservesRail` (set by `pipelines_app.dart`) and starts its bounds after the + rail and divider (`kNavigationRailSpace`, 97 px, the same inset the shell + uses) when the window is wide enough. Tests that mount the host without a + shell keep the full width. +- **Pipelines gear.** `ShellRailScope.isShown` hides `pipelines-open-settings` + in the shell's toolbar while the rail shows. On a phone it stays. + +## Changed paths + +- `app/lib/shell/navigation_rail.dart` (new): rail widget, Settings item, + threshold constants. +- `app/lib/shell/shell_rail_scope.dart` (new): body-width scope. +- `app/lib/shell/adaptive_shell.dart`: rail layout and constant tree shape. +- `app/lib/shell/list_detail.dart`, `app/lib/shell/list_detail_policy.dart`: + read the body width through the scope. +- `app/lib/shell/windows/window_host.dart`: `reservesRail` inset (97 px). +- `app/lib/shell/destination.dart`: comment only. +- `app/lib/features/pipelines/screen.dart`: gear hidden beside the rail. +- `app/lib/application/pipelines_app.dart`: `WindowHost(reservesRail: true)`. + +## Focused results + +Review fix (off-by-one at the threshold): the rail threshold and the +`WindowHost` inset both use `kNavigationRailSpace` (97). Re-run from `app/` +with `tool/memwatch/full.sh`: + +- Rail and window-host files (`navigation_rail_test`, `windows/window_host_test`, + `windows/window_layering_test`): `PASS: 21 passed` earlier, then covered by the + run below. +- All 18 changed test files plus the rail and window-host tests + (`application/`, `features/chat/`, `shell/`, `shell/windows/`): + `memwatch: PASS: 108 passed, 0 failed, 0 skipped; exit 0`. The verdict names + only the intended paths. +- `tool/analyze.sh` (whole app, run after the focused tests): `analyze: clean`. + +New tests (`test/shell/navigation_rail_test.dart`): + +- Wide: labelled rail, full height, left edge, Settings pinned below the tabs. +- Selection marks the tab and one tap selects another. +- Settings opens as a page from the rail foot; no tab is selected meanwhile; + Back returns to Pipelines. +- Running count on the Runs item of the rail. +- A list and its open item lay out to the right of the rail. +- The rail appears at 697 and not at 696; at 697 the list and detail sit side by + side (list starts at 97, detail ends at 697); phone and 640 keep the floating bar. +- Floating windows start after the rail (97) with `reservesRail`, and at 500 px + they use the full width. +- Crossing the threshold keeps a destination mounted with its state. + +Updated expectations (each one is a consequence of the rail, not a behaviour +change the task did not ask for): + +- Wide-window floating-bar tests moved to 640 px, where the bar still sits + beside the list (`floating_tab_bar_test`, `split_destination_bar_test`, + `split_detail_pages_test`, `split_status_bar_test`, `pane_bar_row_test`, + `chat_sidebar_clearance_test`). The width-driven policy numbers + (`list_pane_resize_test`) now use the body width. +- `settings_page_test`: the gear case runs on a phone; a wide case opens + Settings from the rail. `tab_location_navigation_test` uses the rail's + Settings item at 1100 px. +- `chat_registration_test`, `chat_list_detail_test`, `attention_badge_test`: + the rail replaces the bottom bar at wide widths. +- `list_pane_resize_test` (grip): one `pumpAndSettle` instead of one `pump`. + The focus emphasis reaches the grip one frame later beside the rail. The + expectation (emphasised on focus) is unchanged. +- `chat_sidebar_clearance_test`: the scroll offset is kept up to the new + maximum extent. At 640 px the list is narrower than beside the rail, so its + rows re-wrap and the content is shorter. +- `chat_split_integration_test`: the compact menu's "Runs" is picked by + element, not by text, because the rail also labels Runs. The rail's tooltips + keep `byTooltip('Chat')` working. +- Floating-window expectation (`navigation_rail_test`): the probe window starts at + `100 + kNavigationRailSpace` (97), not 96. + +## Affected states + +- Wide, rail shown (>= 697 px): rail with badges, Settings pinned, lists beside + the rail, floating windows beside it, no Pipelines gear, Settings page with + Back. +- 600-696 px: floating bar and split layout as before (no rail). +- Phone: unchanged, including the Pipelines gear. + +## Limitations + +- Not verified in a browser or on a device. `ui-review` owns captures. The + visual match of the rail and the Settings item is by reading the Material + sources, not by a capture. +- The terminal panel is laid over the app's bottom edge (`TerminalStage`), not + inside the shell. When it is open on a wide window it may cover the rail's + foot and Settings. This follows from the stack layout; it was not captured. +- The compact list's "Menu" sheet (`ShellDestinationMenu`) still offers the + destinations beside the rail. It is a duplicate, not a removed feature. diff --git a/app/test/application/chat_registration_test.dart b/app/test/application/chat_registration_test.dart index 07901af5..e29fe066 100644 --- a/app/test/application/chat_registration_test.dart +++ b/app/test/application/chat_registration_test.dart @@ -285,12 +285,12 @@ void main() { expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget); expect(find.text('Kept behind a native disclosure.'), findsNothing); - // The shell bar stays over the list and tabs; the open chat draws its - // own floating bar in its pane, with no Back: the list beside it is the - // way out. + // The destination rail sits at the left edge; the shell bar stays over + // the list, and the open chat draws its own floating bar in its pane, + // with no Back: the list beside it is the way out. expect(find.byType(ChatSessionsScreen), findsOneWidget); - expect(find.byType(NavigationRail), findsNothing); - expect(find.byType(FloatingDestinationBar), findsOneWidget); + expect(find.byType(NavigationRail), findsOneWidget); + expect(find.byType(FloatingDestinationBar), findsNothing); // The shell's bar and the conversation's own header. expect(find.byType(SegmentedBar), findsNWidgets(2)); expect(find.byType(AppBar), findsNothing); diff --git a/app/test/application/settings_page_test.dart b/app/test/application/settings_page_test.dart index 73606176..e27df3ca 100644 --- a/app/test/application/settings_page_test.dart +++ b/app/test/application/settings_page_test.dart @@ -13,9 +13,9 @@ 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. +/// Settings is not a tab: it opens as a page (from the gear in the Pipelines +/// bar on a phone, from the rail's foot on a wide window), 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, { @@ -50,7 +50,9 @@ void main() { .widget(find.byType(FloatingDestinationBar)) .currentIndex; - for (final size in [const Size(390, 844), const Size(1200, 800)]) { + // A phone's Pipelines bar keeps the gear; a wide window's rail offers + // Settings instead (see the wide test below). + for (final size in [const Size(390, 844)]) { testWidgets('${size.width}: the Pipelines bar gear opens Settings ' 'as a page and Back returns', (tester) async { final provider = await pumpApp( @@ -101,6 +103,57 @@ void main() { }); } + testWidgets('1200: the rail offers Settings at its foot and no gear is ' + 'left in the Pipelines toolbar; Settings is a page and Back returns', ( + tester, + ) async { + final provider = await pumpApp( + tester, + location: '/pipelines', + size: const Size(1200, 800), + ); + expect(find.byType(NavigationRail), findsOneWidget); + expect(find.byKey(const Key('pipelines-open-settings')), findsNothing); + expect(find.byType(FloatingDestinationBar), findsNothing); + final rail = tester.widget(find.byType(NavigationRail)); + expect(rail.selectedIndex, 0); + for (final label in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) { + expect( + find.descendant( + of: find.byType(NavigationRail), + matching: find.text(label), + ), + findsOneWidget, + reason: label, + ); + } + + await tester.tap(find.byKey(const ValueKey('shell.destination.settings'))); + await tester.pump(); + await tester.pump(); + expect(provider.value.uri.path, '/settings'); + expect(find.byType(SettingsScreen), findsOneWidget); + // Settings is a page of Pipelines: the rail marks Settings, not a tab. + expect( + tester.widget(find.byType(NavigationRail)).selectedIndex, + isNull, + ); + expect(find.byKey(const ValueKey('shell.back')), findsOneWidget); + 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')), findsNothing); + expect( + tester.widget(find.byType(NavigationRail)).selectedIndex, + 0, + ); + await tester.pumpWidget(const SizedBox.shrink()); + await tester.pump(); + }); + testWidgets('the /settings deep link opens the Settings page and ' 'the system Back closes it to Pipelines', (tester) async { final provider = await pumpApp( diff --git a/app/test/application/tab_location_navigation_test.dart b/app/test/application/tab_location_navigation_test.dart index 1197cd27..55de9dbf 100644 --- a/app/test/application/tab_location_navigation_test.dart +++ b/app/test/application/tab_location_navigation_test.dart @@ -179,11 +179,9 @@ void main() { final before = tester.widget(find.byType(PipelinesScreen)); expect(before.initialPipelineId, 1); final pipelineState = tester.state(find.byType(PipelinesScreen)); - await tapBarAction( - tester, - find.byKey(const Key('pipelines-open-settings')), - 'Settings', - ); + // Wide: the rail offers Settings (the toolbar gear is gone). + expect(find.byKey(const Key('pipelines-open-settings')), findsNothing); + await tester.tap(find.byKey(const ValueKey('shell.destination.settings'))); await tester.pumpAndSettle(); expect(app.provider.value.uri.path, '/settings'); final hidden = find.byType(PipelinesScreen, skipOffstage: false); diff --git a/app/test/features/chat/chat_list_detail_test.dart b/app/test/features/chat/chat_list_detail_test.dart index 9e3703b3..a96c93ee 100644 --- a/app/test/features/chat/chat_list_detail_test.dart +++ b/app/test/features/chat/chat_list_detail_test.dart @@ -50,7 +50,7 @@ Future _pumpShell(WidgetTester tester, Size size) async { void main() { for (final size in [const Size(1280, 800), const Size(800, 830)]) { - testWidgets('a wide window keeps the tab bar and list beside the open chat ' + testWidgets('a wide window keeps the rail and list beside the open chat ' 'at $size', (tester) async { await _pumpShell(tester, size); expect( @@ -68,8 +68,10 @@ void main() { find.byType(Navigator).first, ); expect(navigator.canPop(), isFalse, reason: 'No page covers the shell'); - expect(find.byType(NavigationRail), findsNothing); - expect(find.byType(FloatingDestinationBar), findsOneWidget); + // Both sizes are wide enough for the rail (the shell's own bar and list + // beside the open chat sit to its right). + expect(find.byType(NavigationRail), findsOneWidget); + expect(find.byType(FloatingDestinationBar), findsNothing); expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget); expect(find.text('Second chat'), findsOneWidget); expect( diff --git a/app/test/features/chat/chat_sidebar_clearance_test.dart b/app/test/features/chat/chat_sidebar_clearance_test.dart index 2ed3b3be..c9f9c624 100644 --- a/app/test/features/chat/chat_sidebar_clearance_test.dart +++ b/app/test/features/chat/chat_sidebar_clearance_test.dart @@ -11,7 +11,7 @@ void main() { testWidgets('chat list stays above labeled navigation ($scale)', ( tester, ) async { - tester.view.physicalSize = const Size(1200, 900); + tester.view.physicalSize = const Size(640, 900); tester.view.devicePixelRatio = 1; tester.platformDispatcher.textScaleFactorTestValue = scale; addTearDown(tester.view.reset); @@ -87,7 +87,13 @@ void main() { ), same(scrollable), ); - expect(scrollable.position.pixels, closeTo(retainedOffset, .5)); + // The list is narrower at 640 (no rail) than beside the rail, so its + // rows re-wrap into a shorter scroll extent: the offset is kept up to + // that extent, and no further. + final kept = retainedOffset < scrollable.position.maxScrollExtent + ? retainedOffset + : scrollable.position.maxScrollExtent; + expect(scrollable.position.pixels, closeTo(kept, .5)); expect(tester.takeException(), isNull); }); } diff --git a/app/test/features/chat/chat_split_integration_test.dart b/app/test/features/chat/chat_split_integration_test.dart index 4d3eb558..c10ea315 100644 --- a/app/test/features/chat/chat_split_integration_test.dart +++ b/app/test/features/chat/chat_split_integration_test.dart @@ -106,7 +106,16 @@ void main() { expect(find.text('Menu'), findsOneWidget); await tester.tap(find.text('Menu')); await tester.pumpAndSettle(); - await tester.tap(find.text('Runs')); + // The menu's own row: the rail labels Runs too, so take the text that + // is not in the rail. + await tester.tap( + find.byElementPredicate( + (element) => + element.widget is Text && + (element.widget as Text).data == 'Runs' && + element.findAncestorWidgetOfExactType() == null, + ), + ); await tester.pumpAndSettle(); expect(find.text('Runs destination'), findsOneWidget); await tester.tap(find.byTooltip('Chat')); diff --git a/app/test/shell/attention_badge_test.dart b/app/test/shell/attention_badge_test.dart index 66348283..fd70c6d0 100644 --- a/app/test/shell/attention_badge_test.dart +++ b/app/test/shell/attention_badge_test.dart @@ -22,13 +22,16 @@ void main() { } for (final width in [390.0, 1000.0]) { - final mount = width < 600 ? 'bottom bar' : 'wide bar'; + final mount = width < 600 ? 'bottom bar' : 'rail'; + // The rail (wide) or the floating bar (phone) carries the same counts. + final navigation = width < 600 + ? find.byType(FloatingDestinationBar) + : find.byType(NavigationRail); testWidgets('$mount shows the count on the Runs tab', (tester) async { final semantics = tester.ensureSemantics(); await pumpShell(tester, width: width, count: 3); - expect(find.byType(FloatingDestinationBar), findsOneWidget); - expect(find.byType(NavigationRail), findsNothing); + expect(navigation, findsOneWidget); final badge = find.byKey(const ValueKey('shell.badge.runs.running')); expect(badge, findsOneWidget); expect( diff --git a/app/test/shell/floating_tab_bar_test.dart b/app/test/shell/floating_tab_bar_test.dart index ff55d732..6a0a8dfc 100644 --- a/app/test/shell/floating_tab_bar_test.dart +++ b/app/test/shell/floating_tab_bar_test.dart @@ -110,22 +110,23 @@ void main() { testWidgets('wide leading bar under the list, content ' 'keeps the width and taps beside the bar reach it', (tester) async { taps = 0; - await setSize(tester, const Size(1200, 800)); + await setSize(tester, const Size(640, 800)); await tester.pumpWidget(shell()); final rect = tester.getRect(pill()); // With no item open the bar still sits under the list column, where it // sits beside an open item, so it never jumps sides. expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5)); expect(rect.bottom, 800 - 16); - expect(rect.width, lessThan(1200 * 0.6)); + expect(rect.width, lessThan(640 * 0.6)); // Captions participate in the bar's content-driven width. await expectLabeledTargets(tester, rect); await expectNoSharedBackdrop(tester); expect( rect.width, - lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16), + lessThanOrEqualTo(listDetailListWidth(640, 640, null) - 2 * 16), ); - // No rail or sidebar: the content starts at the left edge. + // Below the rail's window width (see kNavigationRailMinWindowWidth) the + // floating bar still sits under the list: no rail, content at the left edge. expect(find.byType(NavigationRail), findsNothing); expect(tester.getRect(find.byKey(const Key('content'))).left, 0); // Beside the bar, at the bar's height, the content takes the tap. @@ -141,7 +142,7 @@ void main() { testWidgets('content learns the bar height as bottom padding', ( tester, ) async { - for (final size in const [Size(390, 844), Size(1200, 800)]) { + for (final size in const [Size(390, 844), Size(640, 800)]) { await setSize(tester, size); await tester.pumpWidget(shell()); await tester.pump(); @@ -166,13 +167,13 @@ void main() { expect(find.text('taps 1'), findsOneWidget); final state = tester.state(find.byType(StatefulBuilder)); - tester.view.physicalSize = const Size(1200, 800); + tester.view.physicalSize = const Size(640, 800); await tester.pump(); expect( tester.getRect(pill()).left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5), ); - expect(tester.getRect(pill()).width, lessThan(1200 * 0.6)); + expect(tester.getRect(pill()).width, lessThan(640 * 0.6)); expect(tester.state(find.byType(StatefulBuilder)), same(state)); tester.view.physicalSize = const Size(390, 844); diff --git a/app/test/shell/list_pane_resize_test.dart b/app/test/shell/list_pane_resize_test.dart index 1e961bfb..a43c516b 100644 --- a/app/test/shell/list_pane_resize_test.dart +++ b/app/test/shell/list_pane_resize_test.dart @@ -8,6 +8,7 @@ import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/list_detail.dart'; import 'package:pipelines_app/shell/list_pane_divider.dart'; import 'package:pipelines_app/shell/list_pane_widths.dart'; +import 'package:pipelines_app/shell/navigation_rail.dart'; import 'package:pipelines_app/shell/shell_bar.dart'; import 'package:pipelines_app/ui/adaptive/resize_grip.dart'; @@ -66,6 +67,7 @@ void main() { testWidgets('dragging resizes the list live, the shell bar ' 'follows, and the width clamps', (tester) async { await setSize(tester, const Size(1200, 800)); + const body = 1200 - kNavigationRailSpace; final store = MemoryListPaneWidthStore(); await tester.pumpWidget(shell(store: store)); await settle(tester); @@ -79,7 +81,7 @@ void main() { // Live, before the drag ends; nothing saved yet. expect(listWidth(tester), closeTo(340, 0.5)); expect(shellBarWidth(tester), closeTo(340, 0.5)); - expect(bodyWidth(tester), closeTo(1200 - 1 - 340, 0.5)); + expect(bodyWidth(tester), closeTo(body - 1 - 340, 0.5)); expect(store.values, isEmpty); await gesture.up(); await tester.pump(); @@ -92,9 +94,10 @@ void main() { // ...nor wider than leaves the open item half the window. await tester.drag(divider, const Offset(900, 0)); await settle(tester); - expect(listWidth(tester), closeTo(1200 - 1 - 600, 0.5)); - expect(shellBarWidth(tester), closeTo(599, 0.5)); - expect(store.values['runs'], closeTo(599, 0.5)); + // Half of the body for the open item, the list the rest. + expect(listWidth(tester), closeTo(body - 1 - body * 0.5, 0.5)); + expect(shellBarWidth(tester), closeTo(body - 1 - body * 0.5, 0.5)); + expect(store.values['runs'], closeTo(body - 1 - body * 0.5, 0.5)); }); testWidgets('a double tap returns to the default policy', (tester) async { @@ -143,8 +146,11 @@ void main() { final store = MemoryListPaneWidthStore({'runs': 600}); await tester.pumpWidget(shell(store: store)); await settle(tester); - expect(listWidth(tester), closeTo(1000 - 1 - 500, 0.5)); - expect(shellBarWidth(tester), closeTo(499, 0.5)); + // Beside the destination rail the panes lay out in the window's width + // less the rail, so the clamp is the body's: half of it for the open item. + const body = 1000 - kNavigationRailSpace; + expect(listWidth(tester), closeTo(body - 1 - body * 0.5, 0.5)); + expect(shellBarWidth(tester), closeTo(body - 1 - body * 0.5, 0.5)); expect(store.values['runs'], 600); await setSize(tester, const Size(1600, 800)); @@ -212,7 +218,8 @@ void main() { expect(grip().emphasized, isFalse); Focus.of(tester.element(divider)).requestFocus(); - await tester.pump(); + // The focus change reaches the grip one frame later beside the rail. + await tester.pumpAndSettle(); expect(grip().emphasized, isTrue); }); diff --git a/app/test/shell/navigation_rail_test.dart b/app/test/shell/navigation_rail_test.dart new file mode 100644 index 00000000..3b6030f7 --- /dev/null +++ b/app/test/shell/navigation_rail_test.dart @@ -0,0 +1,283 @@ +import 'dart:ui' show Tristate; + +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/shell/navigation_rail.dart'; +import 'package:pipelines_app/shell/shell_bar.dart'; +import 'package:pipelines_app/shell/windows/window_host.dart'; +import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; + +import 'windows/window_test_harness.dart'; + +/// On a wide window the destinations sit in a Material navigation rail at the +/// left edge (Settings pinned to its foot); narrower windows keep the floating +/// bar. The rail keeps the badges and the keys of the bar it replaces. +void main() { + Future pumpShell( + WidgetTester tester, { + required double width, + double height = 800, + int runningRunCount = 0, + bool withPanes = false, + }) async { + tester.view.physicalSize = Size(width, height); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + final shell = AdaptiveShell( + destination: withPanes ? AppDestination.runs : AppDestination.pipelines, + runningRunCount: runningRunCount, + destinationBodies: { + AppDestination.pipelines: (_) => const Text('pipelines body'), + AppDestination.runs: (_) => withPanes + ? ListDetailPanes( + list: const ShellBar(child: Text('runs list')), + detail: const Center(child: Text('runs detail')), + ) + : const Text('runs body'), + AppDestination.chat: (_) => const Text('chat body'), + AppDestination.search: (_) => const Text('search body'), + AppDestination.settings: (_) => const Text('settings body'), + }, + ); + await tester.pumpWidget(MaterialApp(home: shell)); + await tester.pumpAndSettle(); + } + + Finder rail() => find.byType(NavigationRail); + + Finder inRail(Finder finder) => find.descendant(of: rail(), matching: finder); + + testWidgets('a wide window shows a labelled rail at the left edge, full ' + 'height, with Settings pinned to its foot', (tester) async { + await pumpShell(tester, width: 1000); + + expect(rail(), findsOneWidget); + expect(find.byType(FloatingDestinationBar), findsNothing); + for (final label in ['Pipelines', 'Runs', 'Chat', 'Search', 'Settings']) { + expect(inRail(find.text(label)), findsOneWidget, reason: label); + } + final railRect = tester.getRect(rail()); + expect(railRect.left, 0); + expect(railRect.top, 0); + expect(railRect.height, 800); + expect(railRect.width, kNavigationRailWidth); + + // Settings sits below every tab, at the bottom of the rail. + final settings = tester.getRect( + find.byKey(const ValueKey('shell.destination.settings')), + ); + final runs = tester.getRect( + find.byKey(const ValueKey('shell.destination.runs')), + ); + expect(settings.top, greaterThan(runs.bottom)); + expect(settings.bottom, closeTo(railRect.bottom, 1)); + }); + + testWidgets('the rail marks the selected tab and one tap selects another', ( + tester, + ) async { + await pumpShell(tester, width: 1000); + expect(tester.widget(rail()).selectedIndex, 0); + expect(find.text('pipelines body'), findsOneWidget); + + await tester.tap(find.byKey(const ValueKey('shell.destination.runs'))); + await tester.pumpAndSettle(); + expect(tester.widget(rail()).selectedIndex, 1); + expect(find.text('runs body'), findsOneWidget); + }); + + testWidgets('Settings opens from the rail foot as a page and no tab is ' + 'selected meanwhile', (tester) async { + final semantics = tester.ensureSemantics(); + await pumpShell(tester, width: 1000); + + await tester.tap(find.byKey(const ValueKey('shell.destination.settings'))); + await tester.pumpAndSettle(); + expect(find.text('settings body'), findsOneWidget); + expect(tester.widget(rail()).selectedIndex, isNull); + expect( + tester + .getSemantics(inRail(find.bySemanticsLabel('Settings'))) + .flagsCollection + .isSelected, + Tristate.isTrue, + ); + // The page's own Back returns to Pipelines, the tab it belongs to. + await tester.tap(find.byKey(const ValueKey('shell.back'))); + await tester.pumpAndSettle(); + expect(tester.widget(rail()).selectedIndex, 0); + semantics.dispose(); + }); + + testWidgets('the running count stays on the Runs item of the rail', ( + tester, + ) async { + await pumpShell(tester, width: 1000, runningRunCount: 3); + final badge = find.byKey(const ValueKey('shell.badge.runs.running')); + expect( + find.descendant(of: badge, matching: find.text('3')), + findsOneWidget, + ); + expect( + find.descendant( + of: find.byKey(const ValueKey('shell.destination.runs')), + matching: badge, + ), + findsOneWidget, + ); + }); + + testWidgets('a list and its open item lay out to the right of the rail', ( + tester, + ) async { + await pumpShell(tester, width: 1000, withPanes: true); + final list = tester.getRect(find.byKey(const ValueKey('list-detail-list'))); + final body = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + expect(list.left, closeTo(kNavigationRailSpace, 0.5)); + expect(body.right, closeTo(1000, 0.5)); + expect(body.left, greaterThan(list.right)); + }); + + testWidgets('the rail appears from the threshold width, and below it the ' + 'floating bar stays', (tester) async { + expect( + kNavigationRailMinWindowWidth, + kListDetailMinWidth + kNavigationRailSpace, + ); + + await pumpShell(tester, width: kNavigationRailMinWindowWidth - 1); + expect(rail(), findsNothing); + expect(find.byType(FloatingDestinationBar), findsOneWidget); + + await pumpShell(tester, width: kNavigationRailMinWindowWidth); + expect(rail(), findsOneWidget); + expect(find.byType(FloatingDestinationBar), findsNothing); + }); + + testWidgets('at the threshold the body beside the rail meets the list-detail ' + 'minimum, so the list sits beside its detail', (tester) async { + await pumpShell( + tester, + width: kNavigationRailMinWindowWidth, + withPanes: true, + ); + final list = tester.getRect(find.byKey(const ValueKey('list-detail-list'))); + final body = tester.getRect(find.byKey(const ValueKey('list-detail-body'))); + // The list and detail fill the window beside the rail, at the split + // threshold: the list starts after the rail and the detail ends at the + // window's right edge, with the detail to the right of the list. + expect(list.left, closeTo(kNavigationRailSpace, 0.5)); + expect(body.right, closeTo(kNavigationRailMinWindowWidth, 0.5)); + expect(body.left, greaterThan(list.right)); + }); + + testWidgets('phone and narrow windows keep the floating bar and no rail', ( + tester, + ) async { + for (final width in [390.0, 640.0]) { + await pumpShell(tester, width: width); + expect(rail(), findsNothing, reason: '$width'); + expect( + find.byKey(const ValueKey('shell.destination.settings')), + findsNothing, + reason: '$width', + ); + expect( + find.byType(FloatingDestinationBar), + findsOneWidget, + reason: '$width', + ); + } + }); + + testWidgets('floating windows keep to the right of the rail on a wide ' + 'window, and use the whole window without one', (tester) async { + final manager = probeManager(); + manager.open('probe', 'a'); + Future pumpWindows(double width) async { + tester.view.physicalSize = Size(width, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Stack( + fit: StackFit.expand, + children: [ + const SizedBox.expand(), + Positioned.fill( + child: WindowHost(manager: manager, reservesRail: true), + ), + ], + ), + ), + ), + ); + await tester.pumpAndSettle(); + } + + await pumpWindows(1280); + // The probe window opens at x=100; beside the rail it starts after it. + expect( + windowRect(tester, 'Probe a').left, + closeTo(100 + kNavigationRailSpace, 0.5), + ); + await pumpWindows(500); + expect(windowRect(tester, 'Probe a').left, closeTo(100, 0.5)); + }); + + testWidgets('crossing the rail threshold keeps the destination mounted and ' + 'its state', (tester) async { + tester.view.physicalSize = Size(kNavigationRailMinWindowWidth - 1, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget( + MaterialApp( + home: AdaptiveShell( + destination: AppDestination.runs, + destinationBodies: {AppDestination.runs: (_) => const _Counter()}, + ), + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const ValueKey('counter.increment'))); + await tester.pump(); + final state = tester.state(find.byType(_Counter)); + + for (final width in [kNavigationRailMinWindowWidth, 390.0]) { + tester.view.physicalSize = Size(width, 800); + await tester.pumpAndSettle(); + expect( + tester.state(find.byType(_Counter)), + same(state), + reason: '$width', + ); + expect(find.text('count 1'), findsOneWidget, reason: '$width'); + } + }); +} + +class _Counter extends StatefulWidget { + const _Counter(); + + @override + State<_Counter> createState() => _CounterState(); +} + +class _CounterState extends State<_Counter> { + int _count = 0; + + @override + Widget build(BuildContext context) => Center( + child: TextButton( + key: const ValueKey('counter.increment'), + onPressed: () => setState(() => _count += 1), + child: Text('count $_count'), + ), + ); +} diff --git a/app/test/shell/pane_bar_row_test.dart b/app/test/shell/pane_bar_row_test.dart index 35955a87..f1387469 100644 --- a/app/test/shell/pane_bar_row_test.dart +++ b/app/test/shell/pane_bar_row_test.dart @@ -140,9 +140,9 @@ void main() { expect(find.text('Its context'), findsOneWidget); }); - testWidgets('1200: the item\'s tabs float at the bottom of its ' + testWidgets('640: the item\'s tabs float at the bottom of its ' 'pane, the shell\'s tab bar under the list', (tester) async { - await setSize(tester, const Size(1200, 800)); + await setSize(tester, const Size(640, 800)); await tester.pumpWidget(shell()); await tester.pump(); await tester.pump(); @@ -168,7 +168,7 @@ void main() { expect(shellTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); expect(shellTabs.right, lessThanOrEqualTo(list.right)); expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); - expect(itemTabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(itemTabs.right, closeTo(640 - kFloatingBarMargin, 0.5)); expect(itemTabs.left, greaterThanOrEqualTo(body.left)); expect(itemTabs.overlaps(shellTabs), isFalse); // The item's list starts below its bar and clears its tabs at rest. diff --git a/app/test/shell/split_destination_bar_test.dart b/app/test/shell/split_destination_bar_test.dart index 5da220a7..c0e7c2e9 100644 --- a/app/test/shell/split_destination_bar_test.dart +++ b/app/test/shell/split_destination_bar_test.dart @@ -106,7 +106,7 @@ void main() { .first, ); - for (final width in [1200.0, 1600.0]) { + for (final width in [600.0, 640.0]) { testWidgets('$width split: the destination bar sits under the ' 'list and the composer at the detail\'s bottom edge', (tester) async { await setSize(tester, Size(width, 800)); @@ -211,11 +211,12 @@ void main() { }); } - testWidgets('1200 split: the bar follows a dragged list width', ( + testWidgets('640 split: the bar follows a dragged list width', ( tester, ) async { - await setSize(tester, const Size(1200, 800)); - for (final width in [300.0, 520.0]) { + await setSize(tester, const Size(640, 800)); + // Within a 640 window's list bounds (at most 0.6 of it, less the body). + for (final width in [260.0, 300.0]) { final store = MemoryListPaneWidthStore({'chat': width}); await tester.pumpWidget( KeyedSubtree( @@ -235,26 +236,26 @@ void main() { } }); - testWidgets('1200 Settings: a page without a list keeps the bar ' + testWidgets('640 Settings: a page without a list keeps the bar ' 'at the right edge', (tester) async { - await setSize(tester, const Size(1200, 800)); + await setSize(tester, const Size(640, 800)); await tester.pumpWidget(shell(destination: AppDestination.settings)); await tester.pump(); final pill = destinationPill(tester); - expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(pill.right, closeTo(640 - kFloatingBarMargin, 0.5)); }); - testWidgets('1200 unsplit: the bar stays under the list column', ( + testWidgets('640 unsplit: the bar stays under the list column', ( tester, ) async { - await setSize(tester, const Size(1200, 800)); + await setSize(tester, const Size(640, 800)); await tester.pumpWidget(shell(split: false)); await tester.pump(); final pill = destinationPill(tester); // Same place as beside an open item (Search has no split), so opening // or closing an item never moves the bar across the window. expect(pill.left, closeTo(kFloatingBarMargin, 0.5)); - expect(pill.width, lessThan(1200 * 0.6)); + expect(pill.width, lessThan(640 * 0.6)); }); testWidgets('390: the bar hugs its tabs at the phone\'s bottom ' @@ -277,7 +278,7 @@ void main() { expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5)); }); - for (final width in [600.0, 840.0]) { + for (final width in [600.0, 640.0]) { testWidgets('$width split at 2x: the bar fits the list pane and ' 'the item tabs the detail, without overflow', (tester) async { await setSize(tester, Size(width, 800)); diff --git a/app/test/shell/split_detail_pages_test.dart b/app/test/shell/split_detail_pages_test.dart index cef81444..5ed854c6 100644 --- a/app/test/shell/split_detail_pages_test.dart +++ b/app/test/shell/split_detail_pages_test.dart @@ -36,7 +36,7 @@ void main() { ); Future pumpSplitRun(WidgetTester tester) async { - tester.view.physicalSize = const Size(1200, 800); + tester.view.physicalSize = const Size(640, 800); tester.view.devicePixelRatio = 1; addTearDown(tester.view.reset); final gateway = RunDetailFakeGateway(visitRunFixture()); @@ -71,7 +71,7 @@ void main() { await tester.pumpAndSettle(); } - testWidgets('1200: run tabs float at the pane\'s bottom beside the ' + testWidgets('640: run tabs float at the pane\'s bottom beside the ' 'shell bar under the list, and the stage page opens in the pane', ( tester, ) async { @@ -84,7 +84,7 @@ void main() { 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.right, closeTo(640 - kFloatingBarMargin, 0.5)); expect(runTabs.overlaps(main), isFalse); expect(runTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5)); diff --git a/app/test/shell/split_status_bar_test.dart b/app/test/shell/split_status_bar_test.dart index 382b4fc5..40432fd3 100644 --- a/app/test/shell/split_status_bar_test.dart +++ b/app/test/shell/split_status_bar_test.dart @@ -158,7 +158,7 @@ void main() { testWidgets('split: the item tabs sit at the bottom right of the ' 'detail pane, the shell tab bar under the list', (tester) async { // A gesture-navigation inset as on the unfolded foldable. - await setUp(tester, const Size(1200, 800), bottom: 24); + await setUp(tester, const Size(640, 800), bottom: 24); await tester.pumpWidget(shell(tabbedItem())); await tester.pump(); await tester.pump(); @@ -188,7 +188,7 @@ void main() { expect(shellTabs.bottom, closeTo(800 - 24, 0.5)); expect(shellTabs.right, lessThanOrEqualTo(listPane.right)); expect(tabs.bottom, closeTo(800 - 24, 0.5)); - expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5)); + expect(tabs.right, closeTo(640 - kFloatingBarMargin, 0.5)); expect(shellTabs.overlaps(tabs), isFalse); // The item's list clears its tabs at rest. final list = tester.element(find.byKey(const Key('item-list')));