Chat: hide the chat list entirely (Ctrl+B / Cmd+B), per device
ListDetailPanes takes listHidden and slides the list to zero width (at once with reduced motion), keeping its expanded or compact mode for when it comes back. A wide chat offers Hide chat list in the list's bar and the pane menu, Ctrl+B (Cmd+B on Apple; a focused terminal keeps Ctrl+B) and, while hidden, a Show chat list button at the start of the top-left pane's bar. The choice is device-local (pipelines.chat.listHidden.v1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../ui/motion/motion.dart';
|
||||
import 'detail_pane_navigator.dart';
|
||||
import 'list_detail_policy.dart';
|
||||
import 'list_pane_divider.dart';
|
||||
@@ -99,6 +100,7 @@ class ListDetailPanes extends StatefulWidget {
|
||||
this.listWidthOverride,
|
||||
this.compactListWidth,
|
||||
this.onListCompactChanged,
|
||||
this.listHidden = false,
|
||||
});
|
||||
|
||||
final Widget list;
|
||||
@@ -110,6 +112,10 @@ class ListDetailPanes extends StatefulWidget {
|
||||
/// The grab handle remains available at the rail edge to expand it again.
|
||||
final double? compactListWidth;
|
||||
final ValueChanged<bool>? onListCompactChanged;
|
||||
|
||||
/// Whether the list is hidden entirely: it slides to zero width (at once
|
||||
/// with reduced motion) and comes back at the width it had.
|
||||
final bool listHidden;
|
||||
final Widget detail;
|
||||
|
||||
/// Which item [detail] shows; selecting another item closes any page the
|
||||
@@ -120,13 +126,32 @@ class ListDetailPanes extends StatefulWidget {
|
||||
State<ListDetailPanes> createState() => _ListDetailPanesState();
|
||||
}
|
||||
|
||||
class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
class _ListDetailPanesState extends State<ListDetailPanes>
|
||||
with SingleTickerProviderStateMixin {
|
||||
// Outside a shell (no [ListPaneWidthsScope]) the divider still drags; the
|
||||
// width lasts as long as the panes.
|
||||
ListPaneWidths? _ownWidths;
|
||||
|
||||
/// How far the list has slid away: 0 shown, 1 hidden.
|
||||
late final AnimationController _hidden = AnimationController(
|
||||
vsync: this,
|
||||
value: widget.listHidden ? 1 : 0,
|
||||
);
|
||||
|
||||
@override
|
||||
void didUpdateWidget(ListDetailPanes oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.listHidden == oldWidget.listHidden) return;
|
||||
_hidden.animateTo(
|
||||
widget.listHidden ? 1 : 0,
|
||||
duration: Motion.of(context, Motion.standard),
|
||||
curve: Motion.curve,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_hidden.dispose();
|
||||
_ownWidths?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -141,7 +166,7 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
final split = ShellBar.available(context);
|
||||
return ShellPaneSplit(
|
||||
child: ListenableBuilder(
|
||||
listenable: widths,
|
||||
listenable: Listenable.merge([widths, _hidden]),
|
||||
builder: (context, _) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final window = ShellRailScope.windowWidth(context);
|
||||
@@ -171,14 +196,19 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
preferred != null
|
||||
? preferred.clamp(compactThreshold, normalBounds.max).toDouble()
|
||||
: listDetailListWidth(window, available, preferred);
|
||||
final listWidth = (widget.listWidthOverride ?? normalWidth)
|
||||
final shownWidth = (widget.listWidthOverride ?? normalWidth)
|
||||
.clamp(0.0, math.max(0.0, available - kDetailPaneMinWidth))
|
||||
.toDouble();
|
||||
final hidden = _hidden.value;
|
||||
final listWidth = shownWidth * (1 - hidden);
|
||||
final lineWidth = listWidth > 0 ? 1.0 : 0.0;
|
||||
final bodyWidth = math.max(0.0, available - lineWidth - listWidth);
|
||||
// The list keeps its width while it slides, so it moves out
|
||||
// rather than reflowing.
|
||||
final retainedWidth = widget.listWidthOverride == null
|
||||
? listWidth
|
||||
? shownWidth
|
||||
: math.max(normalWidth, kListPaneMinWidth);
|
||||
final listGone = listWidth == 0 || widget.listHidden;
|
||||
void resize(double value) {
|
||||
widths.preview(key, value);
|
||||
widget.onListCompactChanged?.call(value < compactThreshold);
|
||||
@@ -225,9 +255,9 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
minWidth: retainedWidth,
|
||||
maxWidth: retainedWidth,
|
||||
child: ExcludeFocus(
|
||||
excluding: listWidth == 0,
|
||||
excluding: listGone,
|
||||
child: ExcludeSemantics(
|
||||
excluding: listWidth == 0,
|
||||
excluding: listGone,
|
||||
child: SizedBox.expand(
|
||||
key: const ValueKey('list-detail-list'),
|
||||
child: Semantics(
|
||||
@@ -257,7 +287,7 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
),
|
||||
],
|
||||
),
|
||||
if (bounds != null)
|
||||
if (bounds != null && hidden == 0)
|
||||
PositionedDirectional(
|
||||
start: listWidth + 0.5 - kListPaneDividerGrabWidth / 2,
|
||||
top: 0,
|
||||
|
||||
Reference in New Issue
Block a user