Keep chat controls readable and expose labeled app navigation
This commit is contained in:
@@ -29,6 +29,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
final mode = selected == null || !beside
|
||||
? ChatSidebarMode.expanded
|
||||
: _sidebarMode;
|
||||
final navigation = ShellBarScope.maybeOf(context);
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
@@ -41,6 +42,15 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
),
|
||||
if (mode == ChatSidebarMode.compact)
|
||||
ChatCompactSidebar(
|
||||
navigation: navigation?.registry.canNavigate == true
|
||||
? ShellDestinationMenu(
|
||||
cupertino:
|
||||
chatControlsStyleOf(context) ==
|
||||
ChatControlsStyle.cupertino,
|
||||
current: AppDestination.chat,
|
||||
onSelected: navigation!.registry.navigateTo,
|
||||
)
|
||||
: null,
|
||||
controller: _sessionsForSidebar,
|
||||
folds: _foldsForSidebar,
|
||||
activeSessionId: selected,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/segmented_bar_overlay.dart';
|
||||
import '../domain/chat_colors.dart';
|
||||
import '../ui/sessions/chat_color_palette.dart';
|
||||
|
||||
@@ -65,12 +66,13 @@ class ChatColorWash extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
final top = MediaQuery.paddingOf(context).top;
|
||||
final barHeight = top + SegmentedBarOverlay.reservedHeightOf(context);
|
||||
return Positioned(
|
||||
top: top,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: fadeBelowBar,
|
||||
child: wash(top, top, top + fadeBelowBar),
|
||||
child: wash(barHeight, barHeight, barHeight + fadeBelowBar),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ class ChatModeControl extends StatefulWidget {
|
||||
required this.mode,
|
||||
required this.modeName,
|
||||
this.onChanged,
|
||||
this.showLabel = false,
|
||||
});
|
||||
|
||||
final bool showLabel;
|
||||
final ApiGateway gateway;
|
||||
final String sessionId;
|
||||
|
||||
@@ -98,7 +100,8 @@ class _ChatModeControlState extends State<ChatModeControl> {
|
||||
final label = _name;
|
||||
// At phone widths the title and a named mode cannot both remain useful.
|
||||
// Keep the mode's shield, whose semantic label and picker still name it.
|
||||
final iconOnly = MediaQuery.sizeOf(context).width < 600;
|
||||
final iconOnly =
|
||||
!widget.showLabel && MediaQuery.sizeOf(context).width < 600;
|
||||
final content = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
||||
@@ -22,6 +22,7 @@ class ChatModelControl extends StatefulWidget {
|
||||
required this.sessionId,
|
||||
required this.session,
|
||||
this.onChanged,
|
||||
this.showLabel = false,
|
||||
this.answeredBy = '',
|
||||
});
|
||||
|
||||
@@ -29,6 +30,7 @@ class ChatModelControl extends StatefulWidget {
|
||||
/// no model on record.
|
||||
final String answeredBy;
|
||||
|
||||
final bool showLabel;
|
||||
final ApiGateway gateway;
|
||||
final String sessionId;
|
||||
|
||||
@@ -116,7 +118,7 @@ class _ChatModelControlState extends State<ChatModelControl> {
|
||||
: widget.answeredBy.isNotEmpty
|
||||
? widget.answeredBy
|
||||
: '${backend.isEmpty ? 'opencode' : backend} default';
|
||||
final compact = MediaQuery.sizeOf(context).width < 600;
|
||||
final compact = !widget.showLabel && MediaQuery.sizeOf(context).width < 600;
|
||||
final content = compact
|
||||
? const Icon(Icons.memory_outlined)
|
||||
: Row(
|
||||
|
||||
@@ -48,55 +48,86 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
automaticallyImplyLeading: false,
|
||||
// The platform's own Back, so it reads and behaves as every other
|
||||
// page's Back; its key stays for finders.
|
||||
leading: showBack
|
||||
? SegmentedBackButton(
|
||||
key: const Key('chat-back'),
|
||||
cupertino: cupertino,
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
title: title.isEmpty ? 'Chat' : title,
|
||||
subtitle: folder,
|
||||
subtitleIcon: cupertino ? CupertinoIcons.folder : Icons.folder_outlined,
|
||||
onTitlePressed: onInfo,
|
||||
titleSemanticLabel: 'Chat information',
|
||||
titleKey: const Key('chat-info'),
|
||||
separateActionIslands: true,
|
||||
actions: [
|
||||
if (controls.isNotEmpty)
|
||||
_ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
children: controls,
|
||||
),
|
||||
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
||||
Row(
|
||||
key: const Key('chat-actions-island'),
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final narrow = constraints.maxWidth < 800;
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
automaticallyImplyLeading: false,
|
||||
// The platform's own Back, so it reads and behaves as every other
|
||||
// page's Back; its key stays for finders.
|
||||
leading: showBack
|
||||
? SegmentedBackButton(
|
||||
key: const Key('chat-back'),
|
||||
cupertino: cupertino,
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
title: title.isEmpty ? 'Chat' : title,
|
||||
subtitle: folder,
|
||||
subtitleIcon: cupertino
|
||||
? CupertinoIcons.folder
|
||||
: Icons.folder_outlined,
|
||||
onTitlePressed: onInfo,
|
||||
titleSemanticLabel: 'Chat information',
|
||||
titleKey: const Key('chat-info'),
|
||||
separateActionIslands: true,
|
||||
actions: [
|
||||
if (!narrow && controls.isNotEmpty)
|
||||
_ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
children: controls,
|
||||
),
|
||||
if (actions.isNotEmpty || moreActions.isNotEmpty)
|
||||
Row(
|
||||
key: const Key('chat-actions-island'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
...actions,
|
||||
// Unknown action widgets retain their original behavior and stay
|
||||
// visible; only the explicit overflow contract becomes a menu.
|
||||
for (final action in moreActions)
|
||||
if (action is! SegmentedOverflowable) action,
|
||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
||||
SegmentedMoreButton(
|
||||
cupertino: cupertino,
|
||||
entries: [
|
||||
for (final action
|
||||
in moreActions.whereType<SegmentedOverflowable>())
|
||||
action.overflowEntry,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
bottomPadding: narrow ? 8 : 16,
|
||||
backdrop: backdrop,
|
||||
);
|
||||
return ColoredBox(
|
||||
color: cupertino
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
...actions,
|
||||
// Unknown action widgets retain their original behavior and stay
|
||||
// visible; only the explicit overflow contract becomes a menu.
|
||||
for (final action in moreActions)
|
||||
if (action is! SegmentedOverflowable) action,
|
||||
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
|
||||
SegmentedMoreButton(
|
||||
cupertino: cupertino,
|
||||
entries: [
|
||||
for (final action
|
||||
in moreActions.whereType<SegmentedOverflowable>())
|
||||
action.overflowEntry,
|
||||
],
|
||||
bar,
|
||||
if (narrow && controls.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
|
||||
child: SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
child: _ControlIsland(
|
||||
key: const Key('chat-model-permission-island'),
|
||||
fill: true,
|
||||
vertical: constraints.maxWidth < 340,
|
||||
children: controls,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
bottomPadding: 16,
|
||||
backdrop: backdrop,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -104,11 +135,27 @@ class ChatThreadHeader extends StatelessWidget {
|
||||
/// Related selectors share the available width. Each remains a real control;
|
||||
/// they never migrate into the unrelated actions menu.
|
||||
class _ControlIsland extends StatelessWidget {
|
||||
const _ControlIsland({super.key, required this.children});
|
||||
const _ControlIsland({
|
||||
super.key,
|
||||
required this.children,
|
||||
this.fill = false,
|
||||
this.vertical = false,
|
||||
});
|
||||
final List<Widget> children;
|
||||
final bool fill;
|
||||
final bool vertical;
|
||||
@override
|
||||
Widget build(BuildContext context) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [for (final child in children) Flexible(child: child)],
|
||||
);
|
||||
Widget build(BuildContext context) => vertical
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: children,
|
||||
)
|
||||
: Row(
|
||||
mainAxisSize: fill ? MainAxisSize.max : MainAxisSize.min,
|
||||
children: [
|
||||
for (final child in children)
|
||||
if (fill) Expanded(child: child) else Flexible(child: child),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1040,8 +1040,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
// Under the app shell the conversation takes over the app's bar (title,
|
||||
// Back, model, information) instead of drawing a second bar below it.
|
||||
final inShellBar = ShellBar.available(context);
|
||||
// The conversation's bar floats over the transcript's top and history
|
||||
// scrolls behind it; the transcript ends at the composer's top edge, so
|
||||
// The measured header owns its space so scrolled text never falls
|
||||
// behind the controls; the transcript ends at the composer's top edge, so
|
||||
// nothing renders behind the composer and the viewport shrinks as the
|
||||
// composer grows.
|
||||
// Every input of the composer comes from this widget's configuration,
|
||||
@@ -1072,6 +1072,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
final page = FloatingBarOverlay(
|
||||
bar: ChatPaneBarReveal(bar: composerBar),
|
||||
child: SegmentedBarOverlay(
|
||||
reserveSpace: true,
|
||||
bar: ChatPaneBarReveal(bar: _header(context, inShellBar)),
|
||||
child: NotificationListener<ScrollMetricsNotification>(
|
||||
onNotification: _onScrollMetrics,
|
||||
@@ -1341,6 +1342,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
controls: [
|
||||
if (hasModel)
|
||||
ChatModelControl(
|
||||
showLabel: true,
|
||||
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
||||
gateway: widget.gateway,
|
||||
sessionId: widget.sessionId,
|
||||
@@ -1356,6 +1358,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
/// The session's permission mode, keyed per session so another chat
|
||||
/// re-reads its own modes.
|
||||
Widget _modeControl() => ChatModeControl(
|
||||
showLabel: true,
|
||||
key: ValueKey<String>('chat-mode-${widget.sessionId}'),
|
||||
gateway: widget.gateway,
|
||||
sessionId: widget.sessionId,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import '../../shell/destination.dart';
|
||||
import '../../shell/shell_bar.dart';
|
||||
import '../../shell/shell_destination_menu.dart';
|
||||
import '../../shell/detail_page.dart';
|
||||
import '../../shell/empty_detail_pane.dart';
|
||||
import '../../shell/list_detail.dart';
|
||||
|
||||
@@ -74,6 +74,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_bar.onNavigate = _select;
|
||||
_selected = widget.destination ?? AppDestination.pipelines;
|
||||
_visited.add(_selected);
|
||||
HardwareKeyboard.instance.addHandler(_handleDestinationKeyEvent);
|
||||
@@ -192,6 +193,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
preferredWidth: _paneWidths.widthFor(_selected.name),
|
||||
alignment: AlignmentDirectional.bottomStart,
|
||||
child: FloatingDestinationBar(
|
||||
showLabels: true,
|
||||
cupertino: widget.cupertino,
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(shellTabDestinations[value]),
|
||||
|
||||
@@ -64,6 +64,12 @@ class ShellBarSpec {
|
||||
/// on a run event) then rebuilds nothing, and a badge change rebuilds only
|
||||
/// the tab bar.
|
||||
class ShellBarRegistry extends ChangeNotifier {
|
||||
ValueChanged<AppDestination>? onNavigate;
|
||||
bool get canNavigate => onNavigate != null && !_disposed;
|
||||
void navigateTo(AppDestination destination) {
|
||||
if (!_disposed) onNavigate?.call(destination);
|
||||
}
|
||||
|
||||
final Map<AppDestination, (Object, ShellBarSpec)> _specs = {};
|
||||
final Map<(AppDestination, ShellBadgeKind), int> _badges = {};
|
||||
final _Notifier _bar = _Notifier();
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'destination.dart';
|
||||
|
||||
/// Native, labeled destination access when the full tab bar cannot fit a rail.
|
||||
class ShellDestinationMenu extends StatelessWidget {
|
||||
const ShellDestinationMenu({
|
||||
super.key,
|
||||
required this.cupertino,
|
||||
required this.current,
|
||||
required this.onSelected,
|
||||
});
|
||||
final bool cupertino;
|
||||
final AppDestination current;
|
||||
final ValueChanged<AppDestination> onSelected;
|
||||
|
||||
Future<void> _choose(BuildContext context) async {
|
||||
final value = await showCupertinoModalPopup<AppDestination>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: const Text('Main navigation'),
|
||||
actions: [
|
||||
for (final destination in AppDestination.values)
|
||||
CupertinoActionSheetAction(
|
||||
isDefaultAction: destination == current,
|
||||
onPressed: () => Navigator.pop(context, destination),
|
||||
child: Text(destinationDetails(destination).label),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (value != null && context.mounted) onSelected(value);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final child = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(cupertino ? CupertinoIcons.square_grid_2x2 : Icons.apps),
|
||||
const Text('Menu'),
|
||||
],
|
||||
);
|
||||
if (cupertino) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: 'Main navigation',
|
||||
child: CupertinoButton(onPressed: () => _choose(context), child: child),
|
||||
);
|
||||
}
|
||||
return PopupMenuButton<AppDestination>(
|
||||
tooltip: 'Main navigation',
|
||||
onSelected: onSelected,
|
||||
itemBuilder: (context) => [
|
||||
for (final destination in AppDestination.values)
|
||||
CheckedPopupMenuItem(
|
||||
value: destination,
|
||||
checked: destination == current,
|
||||
child: Text(destinationDetails(destination).label),
|
||||
),
|
||||
],
|
||||
child: Padding(padding: const EdgeInsets.all(8), child: child),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import '../motion/motion.dart';
|
||||
import 'floating_bar_layout.dart';
|
||||
import 'floating_tab_button.dart';
|
||||
import 'floating_tab_motion.dart';
|
||||
import 'floating_destination_labels.dart';
|
||||
|
||||
/// A tab bar which floats above the bottom edge as a row of separate round
|
||||
/// frosted [GlassPill] buttons, one per tab, instead of a full-width system
|
||||
@@ -37,10 +38,14 @@ class FloatingDestinationBar extends StatefulWidget {
|
||||
required this.items,
|
||||
this.edge = FloatingBarEdge.bottom,
|
||||
this.alignment,
|
||||
this.showLabels = false,
|
||||
});
|
||||
|
||||
final bool cupertino;
|
||||
|
||||
/// Main app navigation keeps names visible; dense page tabs can stay icons.
|
||||
final bool showLabels;
|
||||
|
||||
/// Where the row sits in the width it is given, at [FloatingBarEdge.bottom]:
|
||||
/// the trailing end by default. The shell centres its tabs under the list
|
||||
/// pane while a list shows beside an open item.
|
||||
@@ -194,6 +199,17 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
|
||||
}
|
||||
|
||||
Widget _row(BuildContext context, double width) {
|
||||
if (widget.showLabels) {
|
||||
return FloatingDestinationLabels(
|
||||
key: FloatingDestinationBar.rowKey,
|
||||
cupertino: cupertino,
|
||||
labels: [for (final item in items) item.label],
|
||||
selected: currentIndex,
|
||||
buttonBuilder: (index) => _button(context, index),
|
||||
onTap: widget.onTap,
|
||||
backdrop: _backdrop,
|
||||
);
|
||||
}
|
||||
final gap = _gap(width);
|
||||
// As tall as the selected (largest) button; the others are centred on
|
||||
// it, and every gap stays the same while a button grows or shrinks.
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import 'dart:ui' show SemanticsRole;
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Content-driven main navigation captions keep names visible without scaling
|
||||
/// down touch targets. Narrow lists and large text wrap into another row.
|
||||
class FloatingDestinationLabels extends StatelessWidget {
|
||||
const FloatingDestinationLabels({
|
||||
super.key,
|
||||
required this.cupertino,
|
||||
required this.labels,
|
||||
required this.selected,
|
||||
required this.buttonBuilder,
|
||||
required this.onTap,
|
||||
required this.backdrop,
|
||||
});
|
||||
final bool cupertino;
|
||||
final List<String> labels;
|
||||
final int selected;
|
||||
final Widget Function(int) buttonBuilder;
|
||||
final ValueChanged<int> onTap;
|
||||
final BackdropKey backdrop;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
final surface = cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainer;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
||||
: Theme.of(context).textTheme.labelSmall!;
|
||||
return Semantics(
|
||||
role: SemanticsRole.tabBar,
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: BackdropGroup(
|
||||
backdropKey: backdrop,
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
for (var index = 0; index < labels.length; index++)
|
||||
GestureDetector(
|
||||
key: ValueKey('destination-label-${labels[index]}'),
|
||||
excludeFromSemantics: true,
|
||||
onTap: () => onTap(index),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
buttonBuilder(index),
|
||||
ExcludeSemantics(
|
||||
child: Text(
|
||||
labels[index],
|
||||
style: style.copyWith(
|
||||
color: color,
|
||||
fontWeight: index == selected
|
||||
? FontWeight.w600
|
||||
: style.fontWeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,24 @@ class SegmentedBarOverlay extends StatelessWidget {
|
||||
super.key,
|
||||
required this.bar,
|
||||
required this.child,
|
||||
this.reserveSpace = false,
|
||||
});
|
||||
|
||||
final Widget bar;
|
||||
final Widget child;
|
||||
|
||||
/// Gives reading content its own viewport below the measured bar.
|
||||
final bool reserveSpace;
|
||||
|
||||
static double reservedHeightOf(BuildContext context) =>
|
||||
context
|
||||
.dependOnInheritedWidgetOfExactType<_ReservedBarHeight>()
|
||||
?.height ??
|
||||
0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => CustomMultiChildLayout(
|
||||
delegate: _OverlayLayout(),
|
||||
delegate: _OverlayLayout(reserveSpace),
|
||||
children: [
|
||||
// Painted first, so the bar draws (and takes taps) above it.
|
||||
LayoutId(
|
||||
@@ -32,9 +42,14 @@ class SegmentedBarOverlay extends StatelessWidget {
|
||||
final media = MediaQuery.of(context);
|
||||
return MediaQuery(
|
||||
data: media.copyWith(
|
||||
padding: media.padding.copyWith(top: barHeight),
|
||||
padding: media.padding.copyWith(
|
||||
top: reserveSpace ? 0 : barHeight,
|
||||
),
|
||||
),
|
||||
child: _ReservedBarHeight(
|
||||
height: reserveSpace ? barHeight : 0,
|
||||
child: child,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -70,6 +85,8 @@ class _ContentConstraints extends BoxConstraints {
|
||||
}
|
||||
|
||||
class _OverlayLayout extends MultiChildLayoutDelegate {
|
||||
_OverlayLayout(this.reserveSpace);
|
||||
final bool reserveSpace;
|
||||
@override
|
||||
void performLayout(Size size) {
|
||||
final bar = layoutChild(
|
||||
@@ -82,11 +99,26 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
|
||||
positionChild(_Slot.bar, Offset.zero);
|
||||
layoutChild(
|
||||
_Slot.content,
|
||||
_ContentConstraints(size, barHeight: bar.height),
|
||||
_ContentConstraints(
|
||||
Size(
|
||||
size.width,
|
||||
(size.height - (reserveSpace ? bar.height : 0)).clamp(0, size.height),
|
||||
),
|
||||
barHeight: bar.height,
|
||||
),
|
||||
);
|
||||
positionChild(_Slot.content, Offset.zero);
|
||||
positionChild(_Slot.content, Offset(0, reserveSpace ? bar.height : 0));
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRelayout(_OverlayLayout oldDelegate) => false;
|
||||
bool shouldRelayout(_OverlayLayout oldDelegate) =>
|
||||
reserveSpace != oldDelegate.reserveSpace;
|
||||
}
|
||||
|
||||
class _ReservedBarHeight extends InheritedWidget {
|
||||
const _ReservedBarHeight({required this.height, required super.child});
|
||||
final double height;
|
||||
@override
|
||||
bool updateShouldNotify(_ReservedBarHeight oldWidget) =>
|
||||
height != oldWidget.height;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user