Refine Settings destination shell integration
Keep Settings navigation independent while preserving shell actions and destination-specific state. Add the reviewed chat, run-entry, layout, and regression-test updates needed by the destination behavior.
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 {
|
||||
@@ -32,12 +34,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;
|
||||
|
||||
@@ -75,6 +83,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
late AppDestination _selected;
|
||||
final Set<AppDestination> _visited = {};
|
||||
final TabHistory _history = TabHistory();
|
||||
// The destination a shell control (rail, bar, floating bar) asked for and
|
||||
// that is not shown yet. Settings reached this way is a destination; any
|
||||
// other way in (a route, a deep link, the Pipelines gear) is a page to Back.
|
||||
AppDestination? _navigatingTo;
|
||||
bool _settingsPushed = false;
|
||||
// Whether a navigator inside each destination (an open item's pane) has a
|
||||
// page of its own for the system Back to close first.
|
||||
final Map<AppDestination, bool> _nestedCanPop = {};
|
||||
@@ -98,6 +111,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
super.initState();
|
||||
_bar.onNavigate = _select;
|
||||
_selected = widget.destination ?? AppDestination.pipelines;
|
||||
// A first load that opens Settings (a deep link, a restored page) was not
|
||||
// reached from a shell control, so its Back closes the page.
|
||||
_settingsPushed = _selected == AppDestination.settings;
|
||||
_visited.add(_selected);
|
||||
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
|
||||
}
|
||||
@@ -107,12 +123,23 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
final destination = widget.destination;
|
||||
if (destination != null) {
|
||||
if (destination != _selected) _noteShown(destination);
|
||||
_history.record(_selected, destination);
|
||||
_selected = destination;
|
||||
_visited.add(destination);
|
||||
}
|
||||
}
|
||||
|
||||
/// Records that [destination] is becoming the shown one. Settings opened by
|
||||
/// a shell control is a destination (no Back); opened any other way it is a
|
||||
/// page that Back closes.
|
||||
void _noteShown(AppDestination destination) {
|
||||
if (destination == AppDestination.settings) {
|
||||
_settingsPushed = _navigatingTo != AppDestination.settings;
|
||||
}
|
||||
_navigatingTo = null;
|
||||
}
|
||||
|
||||
/// The entry every tab control calls when tapped: a destination shown
|
||||
/// already is re-selected (see [AdaptiveShell.onDestinationReselected]), any
|
||||
/// other is selected.
|
||||
@@ -122,6 +149,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
reselected(destination);
|
||||
return;
|
||||
}
|
||||
if (destination != _selected) {
|
||||
_navigatingTo = destination;
|
||||
// A selection the route never applies must not mark a later route.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted && _navigatingTo == destination) _navigatingTo = null;
|
||||
});
|
||||
}
|
||||
_select(destination);
|
||||
}
|
||||
|
||||
@@ -132,6 +166,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
if (destination != _selected) _noteShown(destination);
|
||||
_history.record(_selected, destination);
|
||||
_selected = destination;
|
||||
_visited.add(destination);
|
||||
@@ -240,7 +275,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),
|
||||
@@ -437,9 +476,12 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
String label, {
|
||||
required bool page,
|
||||
}) {
|
||||
final onBack = spec?.onBack ?? (page ? _closePage : null);
|
||||
// Settings reached from a shell control has no Back: it is a destination.
|
||||
final onBack =
|
||||
spec?.onBack ?? (page && _settingsPushed ? _closePage : null);
|
||||
final published = spec?.actions ?? const <Widget>[];
|
||||
final onSearch = widget.onSearch;
|
||||
final windows = widget.windowManager;
|
||||
return SegmentedBar(
|
||||
automaticallyImplyLeading: false,
|
||||
leading: onBack == null
|
||||
@@ -474,6 +516,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,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -22,6 +22,12 @@ const double kNavigationRailMinWindowWidth =
|
||||
bool showsNavigationRail(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width >= kNavigationRailMinWindowWidth;
|
||||
|
||||
/// Whether the window shows the floating tab bar alone: wide enough for a list
|
||||
/// beside an open item, too narrow for the rail. That bar lists the tabs only,
|
||||
/// so there Settings is reached from the Pipelines bar's gear.
|
||||
bool showsFloatingTabBarOnly(BuildContext context) =>
|
||||
showsListBesideDetail(context) && !showsNavigationRail(context);
|
||||
|
||||
/// 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.
|
||||
@@ -50,35 +56,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