Files
pipelines/app/lib/shell/detail_pane_navigator.dart
T
alan 40e94cc3da Shell: on wide split layouts the destination tabs sit under the list pane
The four destination buttons move from the bottom right over the detail
pane to the bottom of the list pane, centred in the (dragged) list width.
The list now keeps the bar's height as bottom clearance; the detail pane
clears only the system inset, so its tabs, the chat composer and the
artifact actions sit at its bottom edge. Phone layout is unchanged.
kStackedBarGap is gone with the stacked bars.
2026-11-03 12:30:56 +00:00

59 lines
2.2 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/host.dart';
/// The open item's own navigator beside a list on a wide window.
///
/// A page the item opens (a run's stage page, an artifact, a file) is pushed
/// here, so it fills the item's pane while the list and the shell's tab bar
/// stay in place: the page's own tabs then float at the bottom of the pane,
/// as the item's tabs do (the shell's bar stays under the list). Dialogs still use the root navigator.
///
/// The item is this navigator's first page under a fixed key, so a rebuilt
/// item updates in place and is never remounted. The system Back pops a page
/// pushed here before it leaves the item. Opening a different item
/// ([identity] changes) closes any page the previous item had pushed, so the
/// pane shows the newly selected item.
class DetailPaneNavigator extends StatefulWidget {
const DetailPaneNavigator({super.key, required this.child, this.identity});
final Widget child;
/// Which item the pane shows (a run, chat or pipeline id).
final Object? identity;
@override
State<DetailPaneNavigator> createState() => _DetailPaneNavigatorState();
}
class _DetailPaneNavigatorState extends State<DetailPaneNavigator> {
final GlobalKey<NavigatorState> _navigator = GlobalKey();
static const _rootKey = ValueKey<String>('list-detail-root');
@override
void didUpdateWidget(covariant DetailPaneNavigator oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.identity != widget.identity) {
_navigator.currentState?.popUntil((route) => route.isFirst);
}
}
@override
Widget build(BuildContext context) {
final Page<void> root = usesCupertinoHost(context)
? CupertinoPage<void>(key: _rootKey, child: widget.child)
: MaterialPage<void>(key: _rootKey, child: widget.child);
return NavigatorPopHandler(
onPopWithResult: (_) => _navigator.currentState?.maybePop(),
child: Navigator(
key: _navigator,
pages: [root],
// The item is never popped from here: its pane closes with the
// selection, which the owning screen controls.
onDidRemovePage: (_) {},
),
);
}
}