From 1106adbce2941d93e81066b6cffeb4bde5c3a5fb Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 6 Nov 2026 19:11:28 +0000 Subject: [PATCH] Support compact and hidden list panes in the shell --- app/lib/shell/adaptive_shell.dart | 3 ++ app/lib/shell/list_detail.dart | 55 ++++++++++++++++++++++++------- app/lib/shell/shell_bar.dart | 5 +++ 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index 811adc4e..ca8ebfa1 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -179,6 +179,9 @@ class _AdaptiveShellState extends State { final bar = ListenableBuilder( listenable: Listenable.merge([_bar.badges, _bar.bar, _paneWidths]), builder: (context, _) { + if (_bar.specFor(_selected)?.hideNavigation ?? false) { + return const SizedBox.shrink(); + } // On a wide window the bar stays under the list column even when no // item is open (Search, a list alone), so it never jumps sides. A page // (Settings) has no list column, so its bar stays at the right edge. diff --git a/app/lib/shell/list_detail.dart b/app/lib/shell/list_detail.dart index 01cbea0f..0e4d9530 100644 --- a/app/lib/shell/list_detail.dart +++ b/app/lib/shell/list_detail.dart @@ -95,9 +95,13 @@ class ListDetailPanes extends StatefulWidget { required this.list, required this.detail, this.detailIdentity, + this.listWidthOverride, }); final Widget list; + + /// Focus layouts may retain the list offstage at zero/compact width. + final double? listWidthOverride; final Widget detail; /// Which item [detail] shows; selecting another item closes any page the @@ -135,9 +139,22 @@ class _ListDetailPanesState extends State { final window = media.size.width; final available = constraints.maxWidth; final preferred = widths.widthFor(key); - final listWidth = listDetailListWidth(window, available, preferred); - final bodyWidth = math.max(0.0, available - 1 - listWidth); - final bounds = listPaneWidthBounds(window, available); + final normalWidth = listDetailListWidth( + window, + available, + preferred, + ); + final listWidth = (widget.listWidthOverride ?? normalWidth) + .clamp(0.0, math.max(0.0, available - kDetailPaneMinWidth)) + .toDouble(); + final lineWidth = listWidth > 0 ? 1.0 : 0.0; + final bodyWidth = math.max(0.0, available - lineWidth - listWidth); + final retainedWidth = widget.listWidthOverride == null + ? listWidth + : math.max(normalWidth, kListPaneMinWidth); + final bounds = widget.listWidthOverride == null + ? listPaneWidthBounds(window, available) + : null; Widget body = widget.detail; if (split) { // Beside the list the item is not under the shell's top bar (it @@ -171,18 +188,32 @@ class _ListDetailPanesState extends State { Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Expanded( - child: SizedBox.expand( - key: const ValueKey('list-detail-list'), - child: Semantics( - container: true, - explicitChildNodes: true, - identifier: 'list-detail-list', - child: widget.list, + SizedBox( + width: listWidth, + child: ClipRect( + child: OverflowBox( + alignment: AlignmentDirectional.topStart, + minWidth: retainedWidth, + maxWidth: retainedWidth, + child: ExcludeFocus( + excluding: listWidth == 0, + child: ExcludeSemantics( + excluding: listWidth == 0, + child: SizedBox.expand( + key: const ValueKey('list-detail-list'), + child: Semantics( + container: true, + explicitChildNodes: true, + identifier: 'list-detail-list', + child: widget.list, + ), + ), + ), + ), ), ), ), - const ListPaneDividerLine(), + if (lineWidth > 0) const ListPaneDividerLine(), SizedBox( width: bodyWidth, child: SizedBox.expand( diff --git a/app/lib/shell/shell_bar.dart b/app/lib/shell/shell_bar.dart index 5c63a149..b36fc701 100644 --- a/app/lib/shell/shell_bar.dart +++ b/app/lib/shell/shell_bar.dart @@ -19,6 +19,7 @@ class ShellBarSpec { this.onBack, this.actions = const [], this.barless = false, + this.hideNavigation = false, this.titleWidget, this.titleWidgetMaxWidth = double.infinity, this.backgroundColor, @@ -52,6 +53,7 @@ class ShellBarSpec { /// The content draws its own floating bar: a detail page shows no bar of /// its own and lets the content reach the top edge. final bool barless; + final bool hideNavigation; } /// The bar contents each tab's open screen has published. @@ -190,6 +192,7 @@ class ShellBar extends StatefulWidget { this.actions = const [], this.active = true, this.barless = false, + this.hideNavigation = false, this.titleWidget, this.titleWidgetMaxWidth = double.infinity, this.backgroundColor, @@ -205,6 +208,7 @@ class ShellBar extends StatefulWidget { /// See [ShellBarSpec.barless]. final bool barless; + final bool hideNavigation; /// False while the screen is kept mounted but hidden (a list under an open /// detail): it then gives the bar up. @@ -264,6 +268,7 @@ class _ShellBarState extends State { onBack: widget.onBack, actions: widget.actions, barless: widget.barless, + hideNavigation: widget.hideNavigation, titleWidget: widget.titleWidget, titleWidgetMaxWidth: widget.titleWidgetMaxWidth, backgroundColor: widget.backgroundColor,