Merge commit 'ad064754873b463c7168742a4b30513986ce4ca8' into pipelines/run-20261112-1043-new-background-tasks-indicator-in-the-co-b095
This commit is contained in:
@@ -41,7 +41,6 @@ import '../shell/windows/window_host.dart';
|
||||
import '../shell/windows/window_kind.dart';
|
||||
import '../shell/windows/window_manager.dart';
|
||||
import '../shell/windows/window_store.dart';
|
||||
import '../shell/windows/windows_menu_button.dart';
|
||||
import 'app_terminals.dart';
|
||||
import '../features/chat/chat_runtime.dart';
|
||||
import '../features/chat/windows/chat_windows.dart';
|
||||
@@ -706,6 +705,16 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
}
|
||||
|
||||
void _selectDestination(AppDestination destination) {
|
||||
// Settings is shown from its own nav item and has no Back, so its route
|
||||
// (filed under the Pipelines tab) must not trap the Pipelines item: that
|
||||
// item leaves Settings for the Pipelines body it showed before.
|
||||
if (destination == AppDestination.pipelines &&
|
||||
_delegate.shellRoute.kind == AppRouteKind.settings) {
|
||||
_delegate.goTo(
|
||||
_bodyRoutes[AppDestination.pipelines] ?? AppRoute.pipelines,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final last = _tabRoutes[destination];
|
||||
_delegate.goTo(last ?? _routeOf(destination));
|
||||
}
|
||||
@@ -845,9 +854,10 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
// The terminal button sits on the Chat tab's shell bar on wide layouts;
|
||||
// a narrow layout has it in the chat's own bar instead. The keyboard
|
||||
// shortcut still toggles the terminal everywhere.
|
||||
// The Windows button (shown on every tab while the app has floating
|
||||
// windows) is the shell's: it lists the manager's windows.
|
||||
windowManager: _windows,
|
||||
barActions: [
|
||||
// Shown on every tab while the app has floating windows.
|
||||
WindowsMenuButton(manager: _windows),
|
||||
if (_destinationOf(route.kind) == AppDestination.chat)
|
||||
?_terminals.barToggle(context),
|
||||
],
|
||||
|
||||
@@ -2,7 +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 '../../shell/navigation_rail.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
@@ -289,9 +289,10 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
if (listShown && widget.onOpenSchedules != null)
|
||||
_schedulesButton(context),
|
||||
_refreshButton(context),
|
||||
// A wide window's rail offers Settings; the gear stays on a phone.
|
||||
// The phone's bar and the rail both offer Settings; the gear is only
|
||||
// left where the floating tab bar (tabs only) is the shell's nav.
|
||||
if (listShown &&
|
||||
!ShellRailScope.isShown(context) &&
|
||||
showsFloatingTabBarOnly(context) &&
|
||||
widget.onOpenSettings != null)
|
||||
_settingsButton(context),
|
||||
],
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -77,6 +85,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 = {};
|
||||
@@ -100,6 +113,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);
|
||||
}
|
||||
@@ -109,12 +125,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.
|
||||
@@ -124,6 +151,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);
|
||||
}
|
||||
|
||||
@@ -134,6 +168,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
if (destination != _selected) _noteShown(destination);
|
||||
_history.record(_selected, destination);
|
||||
_selected = destination;
|
||||
_visited.add(destination);
|
||||
@@ -241,7 +276,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),
|
||||
@@ -440,9 +479,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
|
||||
@@ -477,6 +519,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,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -2,10 +2,11 @@ import 'package:flutter/material.dart';
|
||||
|
||||
enum AppDestination { pipelines, runs, chat, search, settings }
|
||||
|
||||
/// The destinations the shell's tab bar (or, on a wide window, its rail) offers,
|
||||
/// The tabs the shell's floating 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.
|
||||
/// `/settings`) and the rail and phone bar offer it too; it is a page of the
|
||||
/// Pipelines tab, not a tab. Only the floating bar's width leaves Settings to
|
||||
/// the Pipelines bar's gear.
|
||||
const List<AppDestination> shellTabDestinations = [
|
||||
AppDestination.pipelines,
|
||||
AppDestination.runs,
|
||||
|
||||
@@ -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