Make Settings a first-class destination

Keep Settings location, selection, history, and persistence separate from Pipelines so /settings restores and navigates independently. Update focused navigation coverage and defer notification loading to avoid a mid-build Runs-tab update.
This commit is contained in:
2026-11-12 11:12:49 +00:00
parent 82418d31a7
commit 95902e3e49
12 changed files with 370 additions and 128 deletions
+17 -20
View File
@@ -26,7 +26,6 @@ class AdaptiveShell extends StatefulWidget {
this.destination,
this.onDestinationSelected,
this.onDestinationReselected,
this.onClosePage,
this.onSearch,
this.onOpenChat,
this.attentionCount = 0,
@@ -53,7 +52,6 @@ class AdaptiveShell extends StatefulWidget {
/// already shown (a re-select). The host decides what it means; Chat reopens
/// its active chats. Null keeps re-selects as plain selections.
final ValueChanged<AppDestination>? onDestinationReselected;
final VoidCallback? onClosePage;
/// Opens the transient Search page. Null hides the action, so the plain
/// shell tests and compositions without routing keep their tab set only.
@@ -166,8 +164,8 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
// Full-screen detail routes cover the shell themselves. Keep the root tabs
// mounted/layout-ready underneath, so Back does not resize or reveal them
// only after the outgoing page has finished its native animation.
// Settings is shown as a page of the Pipelines tab: the tab bar keeps
// Pipelines selected and the bar offers Back to it.
// Settings is a destination of its own: a page with no tab of the bar
// selected, and Back returns to the destination opened before it.
final page = !shellTabDestinations.contains(_selected);
final details = destinationDetails(_selected);
final contents = AppDestination.values.map((destination) {
@@ -227,7 +225,8 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
alignment: AlignmentDirectional.bottomStart,
child: FloatingDestinationBar(
showLabels: true,
currentIndex: shellTabDestinations.indexOf(shellTabFor(_selected)),
// A page (Settings) selects no tab: -1 highlights none.
currentIndex: shellTabDestinations.indexOf(_selected),
onTap: (value) => _tapDestination(shellTabDestinations[value]),
items: _destinationItems(),
alignment: split ? AlignmentDirectional.bottomStart : null,
@@ -252,12 +251,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
// heights; panes beside a list read the real ones from here.
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
// app only from the first tab. Pages pushed over the shell (an item,
// Search, a dialog) pop before this scope is asked. The scope is always
// there, so opening the page never remounts the shell.
// A page (Settings) closes to the destination opened before it on the
// system Back too; at a tab's root Back returns to the destination opened
// before it. Only with neither does Back reach the platform, so Android's
// (predictive) Back closes the app only from the first destination. Pages
// pushed over the shell (an item, Search, a dialog) pop before this scope
// is asked. The scope is always there, so opening the page never remounts
// the shell.
Widget backable(Widget child) => PopScope(
canPop: !page && _history.isEmpty,
onPopInvokedWithResult: (didPop, _) {
@@ -326,24 +326,21 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
);
}
/// Leaves a page destination (Settings) for the tab it belongs to.
/// Leaves a page destination (Settings) for the destination selected before
/// it. With none recorded (a launch straight onto Settings) it opens Pipelines.
void _closePage() {
final close = widget.onClosePage;
if (close != null) {
close();
} else {
_select(shellTabFor(_selected));
}
_select(_history.takePrevious() ?? AppDestination.pipelines);
}
/// The system Back the shell handles: it closes a page, or else returns to
/// the previous tab unless the open item's own pane closes a page first.
/// the previous destination unless the open item's own pane closes a page
/// first.
void _back({required bool page}) {
if (page) {
_closePage();
return;
}
if (_nestedCanPop[shellTabFor(_selected)] ?? false) return;
if (_nestedCanPop[_selected] ?? false) return;
final previous = _history.takePrevious();
if (previous != null) _select(previous);
}