08b2540ec2
Use the phone NavigationBar as a real Scaffold bottom slot so destination content ends at the bar rather than scrolling beneath it. Update shell regression coverage and document the focused verification.
604 lines
23 KiB
Dart
604 lines
23 KiB
Dart
import '../ui/motion/fade_through_stack.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import '../ui/adaptive/segmented_bar.dart';
|
|
import '../ui/adaptive/floating_destination_bar.dart';
|
|
import 'attention_badge.dart';
|
|
import 'destination.dart';
|
|
import 'list_detail.dart';
|
|
import 'navigation_rail.dart';
|
|
import 'shell_navigation_bar.dart';
|
|
import 'shell_rail_scope.dart';
|
|
import 'list_pane_widths.dart';
|
|
import 'shell_bar.dart';
|
|
import 'shell_chat_shortcut.dart';
|
|
import 'shell_cheatsheet.dart';
|
|
import 'shell_cheatsheet_shortcut.dart';
|
|
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 {
|
|
const AdaptiveShell({
|
|
super.key,
|
|
this.destinationBodies = const {},
|
|
this.destination,
|
|
this.onDestinationSelected,
|
|
this.onDestinationReselected,
|
|
this.onSearch,
|
|
this.onOpenChat,
|
|
this.attentionCount = 0,
|
|
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;
|
|
|
|
final Map<AppDestination, WidgetBuilder> destinationBodies;
|
|
|
|
/// The destination a route owner selected. When null the shell keeps its own
|
|
/// selection, which preserves the plain-shell tests and native composition.
|
|
final AppDestination? destination;
|
|
final ValueChanged<AppDestination>? onDestinationSelected;
|
|
|
|
/// Runs when a destination's control is tapped while that destination is
|
|
/// 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;
|
|
|
|
/// Opens the transient Search page. Null hides the action, so the plain
|
|
/// shell tests and compositions without routing keep their tab set only.
|
|
final VoidCallback? onSearch;
|
|
|
|
/// Runs after Ctrl+K or Alt+K has shown the Chat destination (also when it
|
|
/// was already shown), so the open chat's composer can take the keyboard.
|
|
final VoidCallback? onOpenChat;
|
|
|
|
/// Runs needing the operator today, retained in the tab's accessible label.
|
|
final int attentionCount;
|
|
|
|
/// App-wide counts when available; standalone screens publish their own.
|
|
final int? runningRunCount;
|
|
|
|
@override
|
|
State<AdaptiveShell> createState() => _AdaptiveShellState();
|
|
}
|
|
|
|
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 = {};
|
|
final ShellBarRegistry _bar = ShellBarRegistry();
|
|
final ShellCheatsheet _cheatsheet = ShellCheatsheet();
|
|
late final ListPaneWidths _paneWidths = ListPaneWidths(
|
|
store: widget.listPaneWidthStore,
|
|
);
|
|
// Keeps every destination's state if the stack's parent ever changes.
|
|
final GlobalKey _destinationStackKey = GlobalKey();
|
|
|
|
@override
|
|
void dispose() {
|
|
HardwareKeyboard.instance.removeHandler(_handleDestinationKeyEvent);
|
|
_bar.dispose();
|
|
_paneWidths.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
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);
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(covariant AdaptiveShell oldWidget) {
|
|
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.
|
|
void _tapDestination(AppDestination destination) {
|
|
final reselected = widget.onDestinationReselected;
|
|
if (destination == _selected && reselected != null) {
|
|
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);
|
|
}
|
|
|
|
void _select(AppDestination destination) {
|
|
final callback = widget.onDestinationSelected;
|
|
if (callback != null) {
|
|
callback(destination);
|
|
return;
|
|
}
|
|
setState(() {
|
|
if (destination != _selected) _noteShown(destination);
|
|
_history.record(_selected, destination);
|
|
_selected = destination;
|
|
_visited.add(destination);
|
|
});
|
|
}
|
|
|
|
/// Runs has independent status counts; Chat has its unread count.
|
|
Widget _icon(AppDestination destination, IconData data) {
|
|
Widget icon = Icon(data);
|
|
if (destination == AppDestination.chat) {
|
|
return ActivityBadge(
|
|
key: const ValueKey('shell.badge.chat.unread'),
|
|
count: _bar.badge(destination, ShellBadgeKind.unread),
|
|
label: 'unread chats',
|
|
child: icon,
|
|
);
|
|
}
|
|
if (destination != AppDestination.runs) return icon;
|
|
return RunsDestinationIcon(
|
|
running:
|
|
widget.runningRunCount ??
|
|
_bar.badge(destination, ShellBadgeKind.running),
|
|
attention: widget.attentionCount,
|
|
child: icon,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 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 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) {
|
|
final item = destinationDetails(destination);
|
|
return KeyedSubtree(
|
|
key: ValueKey(destination),
|
|
child: NotificationListener<NavigationNotification>(
|
|
onNotification: (notification) {
|
|
_nestedCanPop[destination] = notification.canHandlePop;
|
|
return false;
|
|
},
|
|
child: ShellBarScope(
|
|
registry: _bar,
|
|
destination: destination,
|
|
child: _visited.contains(destination)
|
|
? widget.destinationBodies[destination]?.call(context) ??
|
|
Center(child: Text('${item.label} — Not implemented'))
|
|
: const SizedBox.shrink(),
|
|
),
|
|
),
|
|
);
|
|
}).toList();
|
|
// Only the bar shows the registry's state, so a published bar or badge
|
|
// rebuilds its bar alone; the destinations and scaffold stay as built.
|
|
_bar.focus = _selected;
|
|
// A phone (narrower than the list-detail split) gets a full-width Material
|
|
// NavigationBar at the bottom, with Settings as its last destination. Wider
|
|
// windows without the rail keep the floating glass tab bar, which the list
|
|
// beside an open item needs (see below). On phones the NavigationBar is a
|
|
// real Scaffold bottom child, so content is laid out above its surface.
|
|
// Neither scaffold's structure depends on the width, so resizing never
|
|
// remounts a destination. Pushed detail routes cover the shell, and a
|
|
// bar-less spec (a chat workspace) hides the bar.
|
|
final phone = !showsListBesideDetail(context);
|
|
final bar = ListenableBuilder(
|
|
listenable: Listenable.merge([_bar.badges, _bar.bar, _paneWidths]),
|
|
builder: (context, _) {
|
|
if (_bar.specFor(_selected)?.hideNavigation ?? false) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
if (phone) {
|
|
return ShellNavigationBar(
|
|
selected: _selected,
|
|
icon: (destination) =>
|
|
_icon(destination, destinationDetails(destination).icon),
|
|
onSelected: _tapDestination,
|
|
);
|
|
}
|
|
// On a wide window the bar stays under the list column even when no
|
|
// item is open (Search, a list alone), so it never jumps sides. A page
|
|
// (Settings) has no list column, so its bar stays at the right edge.
|
|
final split =
|
|
_bar.split(_selected) || (!page && showsListBesideDetail(context));
|
|
return ListPaneWidth(
|
|
split: split,
|
|
preferredWidth: _paneWidths.widthFor(_selected.name),
|
|
alignment: AlignmentDirectional.bottomStart,
|
|
child: FloatingDestinationBar(
|
|
showLabels: true,
|
|
// 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,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
// Destinations may still reach the top edge and scroll behind the floating
|
|
// top bar; the bottom phone bar is different because Scaffold reserves its
|
|
// complete height rather than overlaying the body.
|
|
SegmentedBar currentBar() =>
|
|
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
|
|
final topBar = _ListPaneBar(
|
|
listenable: Listenable.merge([
|
|
_bar.bar,
|
|
_paneWidths,
|
|
?widget.windowManager,
|
|
]),
|
|
initial: currentBar(),
|
|
split: () => _bar.split(_selected),
|
|
preferredWidth: () => _paneWidths.widthFor(_selected.name),
|
|
bar: currentBar,
|
|
visible: () => !(_bar.specFor(_selected)?.barless ?? false),
|
|
);
|
|
// The scaffolds below swap the system insets for their bars'
|
|
// 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 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, _) {
|
|
if (!didPop) _back(page: page);
|
|
},
|
|
child: child,
|
|
);
|
|
// On a wide window the destinations sit in a rail at the left edge, and
|
|
// the floating bar is not built; the scaffold gets the rest of the window.
|
|
// The tree has the same shape at every width (an empty rail slot on a
|
|
// phone), so resizing across the rail's threshold never remounts a
|
|
// destination.
|
|
final rail = showsNavigationRail(context);
|
|
final scaffold = Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: topBar,
|
|
body: _destinationStack(contents),
|
|
// Only phone destinations use the Scaffold's real bottom slot. The
|
|
// narrow tablet layout keeps its existing floating bar over the body.
|
|
// The NavigationBar owns its SafeArea and therefore also owns the
|
|
// system gesture inset at the bottom.
|
|
extendBody: !phone,
|
|
bottomNavigationBar: rail ? null : bar,
|
|
);
|
|
return backable(
|
|
ShellSystemInsets(
|
|
padding: system,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
// Badges (running runs, unread chats) rebuild the rail alone.
|
|
ListenableBuilder(
|
|
listenable: _bar.badges,
|
|
builder: (context, _) => rail
|
|
? ShellNavigationRail(
|
|
selected: _selected,
|
|
icon: (destination) => _icon(
|
|
destination,
|
|
destinationDetails(destination).icon,
|
|
),
|
|
// Every tab control shares the tap entry, so a rail
|
|
// re-tap reaches the re-select hook like the bar's.
|
|
onSelected: _tapDestination,
|
|
padding: EdgeInsets.only(
|
|
top: system.top,
|
|
bottom: system.bottom,
|
|
),
|
|
)
|
|
: const SizedBox.shrink(),
|
|
),
|
|
// Three children at every width, so the body keeps its slot.
|
|
rail
|
|
? const VerticalDivider(width: 1, thickness: 1)
|
|
: const SizedBox.shrink(),
|
|
Expanded(
|
|
// Beside the rail the panes lay out in the width the rail leaves,
|
|
// which the window's width fixes here (not in a layout pass), so
|
|
// the panes and their pages rebuild with the window.
|
|
child: ShellRailScope(
|
|
shown: rail,
|
|
bodyWidth: rail
|
|
? media.size.width - kNavigationRailSpace
|
|
: null,
|
|
child: scaffold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Leaves a page destination (Settings) for the destination selected before
|
|
/// it. With none recorded (a launch straight onto Settings) it opens Pipelines.
|
|
void _closePage() {
|
|
_select(_history.takePrevious() ?? AppDestination.pipelines);
|
|
}
|
|
|
|
/// The system Back the shell handles: it closes a page, or else returns to
|
|
/// 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[_selected] ?? false) return;
|
|
final previous = _history.takePrevious();
|
|
if (previous != null) _select(previous);
|
|
}
|
|
|
|
/// App-wide search and conversation-list selection are handled before text
|
|
/// fields. Split-pane navigation belongs to the chat workspace. Ctrl+A
|
|
/// bounces between Runs and Pipelines, but leaves text fields and the
|
|
/// terminal their own Ctrl+A (select all, line start).
|
|
bool _handleDestinationKeyEvent(KeyEvent event) {
|
|
final keyboard = HardwareKeyboard.instance;
|
|
// Ctrl+? opens the shortcuts cheatsheet from anywhere, including a focused
|
|
// composer and floating windows; the terminal keeps the chord while it has
|
|
// the keyboard. Escape closes the cheatsheet while it is open.
|
|
if (shellCheatsheetShortcut(event, keyboard) &&
|
|
!primaryFocusIsTypingSurface()) {
|
|
if (event is KeyDownEvent) _cheatsheet.toggle(context);
|
|
return true;
|
|
}
|
|
if (_cheatsheet.isOpen &&
|
|
event is KeyDownEvent &&
|
|
event.logicalKey == LogicalKeyboardKey.escape &&
|
|
!keyboard.isControlPressed &&
|
|
!keyboard.isMetaPressed &&
|
|
!keyboard.isShiftPressed &&
|
|
!keyboard.isAltPressed) {
|
|
_cheatsheet.close(context);
|
|
return true;
|
|
}
|
|
// Ctrl+K is the terminal's kill-line while the terminal has the keyboard;
|
|
// Alt+K still opens Chat there.
|
|
if (shellChatShortcut(event, keyboard) &&
|
|
(keyboard.isAltPressed || !primaryFocusIsTypingSurface())) {
|
|
if (event is KeyDownEvent) _openChat();
|
|
return true;
|
|
}
|
|
if (shellRunsPipelinesShortcut(event, keyboard)) {
|
|
if (primaryFocusTakesTyping()) return false;
|
|
if (event is KeyDownEvent) {
|
|
_select(shellRunsPipelinesTarget(_selected));
|
|
}
|
|
return true;
|
|
}
|
|
// A terminal keeps its keys (Escape, Ctrl+/, Ctrl+digits).
|
|
if (primaryFocusIsTypingSurface()) return false;
|
|
if (_selected == AppDestination.search &&
|
|
event is KeyDownEvent &&
|
|
event.logicalKey == LogicalKeyboardKey.escape &&
|
|
!keyboard.isControlPressed &&
|
|
!keyboard.isMetaPressed &&
|
|
!keyboard.isShiftPressed &&
|
|
!keyboard.isAltPressed &&
|
|
_searchEscape()) {
|
|
return true;
|
|
}
|
|
if (shellSearchShortcut(event, keyboard)) {
|
|
_select(AppDestination.search);
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
if (mounted && _selected == AppDestination.search) {
|
|
_bar.searchFocus.request();
|
|
}
|
|
});
|
|
WidgetsBinding.instance.ensureVisualUpdate();
|
|
return true;
|
|
}
|
|
final listIndex = shellListShortcutIndex(event, keyboard);
|
|
if (listIndex == null || _selected != AppDestination.chat) return false;
|
|
return _bar.lists.open(AppDestination.chat, listIndex);
|
|
}
|
|
|
|
/// Shows Chat (the tab's own selection, so its open chat returns) and then
|
|
/// lets the app focus that chat's composer.
|
|
void _openChat() {
|
|
if (_selected != AppDestination.chat) _select(AppDestination.chat);
|
|
widget.onOpenChat?.call();
|
|
}
|
|
|
|
/// A popup or nested viewer owns Escape before the underlying Search tab.
|
|
bool _searchEscape() {
|
|
final route = ModalRoute.of(context);
|
|
if (route != null && !route.isCurrent) return false;
|
|
final focusedContext = FocusManager.instance.primaryFocus?.context;
|
|
final focusedRoute = focusedContext == null
|
|
? null
|
|
: ModalRoute.of(focusedContext);
|
|
if (focusedRoute != null && route != null && focusedRoute != route) {
|
|
return false;
|
|
}
|
|
if (!_bar.searchFocus.available) return false;
|
|
if (!_bar.searchFocus.focused) {
|
|
_bar.searchFocus.request();
|
|
return true;
|
|
}
|
|
if (_history.isEmpty) return false;
|
|
_back(page: false);
|
|
return true;
|
|
}
|
|
|
|
List<FloatingDestinationItem> _destinationItems() =>
|
|
shellTabDestinations.map((destination) {
|
|
final item = destinationDetails(destination);
|
|
return FloatingDestinationItem(
|
|
key: ValueKey('shell.destination.${destination.name}'),
|
|
icon: _icon(destination, item.icon),
|
|
label: item.label,
|
|
);
|
|
}).toList();
|
|
|
|
/// The open screen's own bar: its Back, title and actions, or the tab's
|
|
/// name with Search.
|
|
SegmentedBar _segmentedBar(
|
|
ShellBarSpec? spec,
|
|
String label, {
|
|
required bool page,
|
|
}) {
|
|
// 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
|
|
? null
|
|
: SegmentedBackButton(
|
|
key: const ValueKey('shell.back'),
|
|
onPressed: onBack,
|
|
),
|
|
title: spec?.title ?? label,
|
|
titleWidget: spec?.titleWidget,
|
|
titleWidgetMaxWidth: spec?.titleWidgetMaxWidth ?? double.infinity,
|
|
backgroundColor: spec?.backgroundColor,
|
|
subtitle: spec?.subtitle,
|
|
subtitleIcon: spec?.subtitleIcon,
|
|
onTitlePressed: spec?.onTitlePressed,
|
|
expandableTitle: spec?.expandableTitle ?? false,
|
|
titleAction: spec?.titleAction,
|
|
titleSemanticLabel: spec?.titleSemanticLabel,
|
|
titleKey: spec?.titleKey,
|
|
// A screen taking the bar over brings its own actions, which pop in
|
|
// one after another; while it stays, they stay.
|
|
actionsKey: published.isEmpty ? null : _bar.ownerFor(_selected),
|
|
actions: [
|
|
if (published.isNotEmpty)
|
|
...published
|
|
// A screen whose main pill is its own field (Search) needs no
|
|
// separate Search action.
|
|
else if (onSearch != null && spec?.titleWidget == null && !page)
|
|
IconButton(
|
|
key: const ValueKey('shell.search'),
|
|
onPressed: onSearch,
|
|
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,
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _destinationStack(List<Widget> contents) => ListPaneWidthsScope(
|
|
widths: _paneWidths,
|
|
child: FadeThroughStack(
|
|
key: _destinationStackKey,
|
|
index: AppDestination.values.indexOf(_selected),
|
|
children: contents,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// The shell's top bar, over the list pane only while the tab shows a list
|
|
/// beside an open item ([ShellPaneSplit]); the item's own bar takes the rest
|
|
/// of the same row. The bar keeps its place in the scaffold either way, so a
|
|
/// split never remounts it.
|
|
///
|
|
/// It rebuilds itself when [listenable] (the focused destination's published
|
|
/// bar) changes; [initial] supplies the size, which does not depend on the
|
|
/// published contents.
|
|
class _ListPaneBar extends StatelessWidget implements PreferredSizeWidget {
|
|
const _ListPaneBar({
|
|
required this.listenable,
|
|
required this.initial,
|
|
required this.split,
|
|
required this.preferredWidth,
|
|
required this.bar,
|
|
required this.visible,
|
|
});
|
|
|
|
final Listenable listenable;
|
|
final SegmentedBar initial;
|
|
final bool Function() split;
|
|
final double? Function() preferredWidth;
|
|
final SegmentedBar Function() bar;
|
|
final bool Function() visible;
|
|
|
|
@override
|
|
Size get preferredSize => initial.preferredSize;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListenableBuilder(
|
|
listenable: listenable,
|
|
builder: (context, _) => !visible()
|
|
? const SizedBox.shrink()
|
|
: ListPaneWidth(
|
|
split: split(),
|
|
preferredWidth: preferredWidth(),
|
|
alignment: AlignmentDirectional.topStart,
|
|
child: bar(),
|
|
),
|
|
);
|
|
}
|