Fix shell rail surface and empty action island
Paint the navigation rail through its top inset and only add the floating-windows action when a listed window exists. Add focused widget coverage and document the reviewed UI states so the shell no longer shows a white strip or empty trailing pill.
This commit is contained in:
@@ -17,6 +17,8 @@ import 'shell_list_shortcuts.dart';
|
||||
import 'shell_runs_pipelines_shortcut.dart';
|
||||
import 'shell_search_shortcut_labels.dart';
|
||||
import 'tab_history.dart';
|
||||
import 'windows/window_manager.dart';
|
||||
import 'windows/windows_menu_button.dart';
|
||||
import '../ui/input/keyboard_owner.dart';
|
||||
|
||||
class AdaptiveShell extends StatefulWidget {
|
||||
@@ -33,12 +35,18 @@ class AdaptiveShell extends StatefulWidget {
|
||||
this.runningRunCount,
|
||||
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
|
||||
this.barActions = const [],
|
||||
this.windowManager,
|
||||
});
|
||||
|
||||
/// Actions every destination's bar ends with (the Terminal toggle), after
|
||||
/// the screen's own or Search.
|
||||
final List<Widget> barActions;
|
||||
|
||||
/// The floating windows the bar's Windows button lists. The button is shown
|
||||
/// only while one is open, so the bar draws no empty action island; null
|
||||
/// (plain shells) shows none.
|
||||
final WindowManager? windowManager;
|
||||
|
||||
/// Where each destination's dragged list-pane width is kept on this device.
|
||||
final ListPaneWidthStore listPaneWidthStore;
|
||||
|
||||
@@ -241,7 +249,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
SegmentedBar currentBar() =>
|
||||
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
|
||||
final topBar = _ListPaneBar(
|
||||
listenable: Listenable.merge([_bar.bar, _paneWidths]),
|
||||
listenable: Listenable.merge([
|
||||
_bar.bar,
|
||||
_paneWidths,
|
||||
?widget.windowManager,
|
||||
]),
|
||||
initial: currentBar(),
|
||||
split: () => _bar.split(_selected),
|
||||
preferredWidth: () => _paneWidths.widthFor(_selected.name),
|
||||
@@ -443,6 +455,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
final onBack = spec?.onBack ?? (page ? _closePage : null);
|
||||
final published = spec?.actions ?? const <Widget>[];
|
||||
final onSearch = widget.onSearch;
|
||||
final windows = widget.windowManager;
|
||||
return SegmentedBar(
|
||||
automaticallyImplyLeading: false,
|
||||
leading: onBack == null
|
||||
@@ -477,6 +490,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
tooltip: 'Search (${shellSearchShortcutLabels().join(', ')})',
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
// The Windows button leads the shell's own actions, only while a
|
||||
// floating window is listed; an empty button would draw an empty island.
|
||||
if (windows != null && WindowsMenuButton.hasWindows(windows))
|
||||
WindowsMenuButton(manager: windows),
|
||||
...widget.barActions,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -50,35 +50,44 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
@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),
|
||||
final surface = Theme.of(context).colorScheme.surface;
|
||||
// The surface runs under the top inset too: the padding only moves the
|
||||
// rail's content below the system's top, so no unpainted strip shows above
|
||||
// the rail's background.
|
||||
return ColoredBox(
|
||||
key: const ValueKey('shell.navigation-rail.surface'),
|
||||
color: surface,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: SizedBox(
|
||||
width: kNavigationRailWidth,
|
||||
child: NavigationRail(
|
||||
key: const ValueKey('shell.navigation-rail'),
|
||||
backgroundColor: surface,
|
||||
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),
|
||||
),
|
||||
label: Text(destinationDetails(destination).label),
|
||||
),
|
||||
],
|
||||
trailingAtBottom: true,
|
||||
trailing: _SettingsRailItem(
|
||||
selected: selected == AppDestination.settings,
|
||||
onTap: () => onSelected(AppDestination.settings),
|
||||
],
|
||||
trailingAtBottom: true,
|
||||
trailing: _SettingsRailItem(
|
||||
selected: selected == AppDestination.settings,
|
||||
onTap: () => onSelected(AppDestination.settings),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -12,6 +12,11 @@ class WindowsMenuButton extends StatelessWidget {
|
||||
|
||||
final WindowManager manager;
|
||||
|
||||
/// Whether [manager] has a window to list: the shell bar keeps the button
|
||||
/// out of its actions otherwise, so no empty action island is drawn.
|
||||
static bool hasWindows(WindowManager manager) =>
|
||||
manager.windows.any((w) => manager.kinds[w.kind] != null);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: Listenable.merge([
|
||||
|
||||
Reference in New Issue
Block a user