Split view: drag the divider to resize the list pane, remembered per destination

A 12 px grab area over the divider line resizes the list live (mouse,
touch, arrow keys; double tap resets to the default policy). The shell bar
over the list follows. Widths persist per destination in SharedPreferences
and clamp to the window without overwriting the saved value. Capture kit
gains hover= and drag= steps.
This commit is contained in:
2026-11-03 10:49:09 +00:00
parent 6413fc5a90
commit c0d68f7c47
10 changed files with 837 additions and 115 deletions
+21 -5
View File
@@ -9,6 +9,7 @@ import '../ui/adaptive/floating_destination_bar.dart';
import 'attention_badge.dart';
import 'destination.dart';
import 'list_detail.dart';
import 'list_pane_widths.dart';
import 'shell_bar.dart';
class AdaptiveShell extends StatefulWidget {
@@ -20,8 +21,12 @@ class AdaptiveShell extends StatefulWidget {
this.onDestinationSelected,
this.onSearch,
this.attentionCount = 0,
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
});
/// Where each destination's dragged list-pane width is kept on this device.
final ListPaneWidthStore listPaneWidthStore;
final Map<AppDestination, WidgetBuilder> destinationBodies;
final bool cupertino;
@@ -46,6 +51,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
late AppDestination _selected;
final Set<AppDestination> _visited = {};
final ShellBarRegistry _bar = ShellBarRegistry();
late final ListPaneWidths _paneWidths = ListPaneWidths(
store: widget.listPaneWidthStore,
);
// Keeps every destination's state if the stack's parent ever changes.
final GlobalKey _destinationStackKey = GlobalKey();
@@ -53,6 +61,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
void dispose() {
HardwareKeyboard.instance.removeHandler(_handleDestinationKeyEvent);
_bar.dispose();
_paneWidths.dispose();
super.dispose();
}
@@ -168,9 +177,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
SegmentedBar currentBar() =>
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
final topBar = _ListPaneBar(
listenable: _bar.bar,
listenable: Listenable.merge([_bar.bar, _paneWidths]),
initial: currentBar(),
split: () => _bar.split(_selected),
preferredWidth: () => _paneWidths.widthFor(_selected.name),
bar: currentBar,
);
// The scaffolds below swap the system insets for their bars'
@@ -313,10 +323,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
);
}
Widget _destinationStack(List<Widget> contents) => FadeThroughStack(
key: _destinationStackKey,
index: AppDestination.values.indexOf(_selected),
children: contents,
Widget _destinationStack(List<Widget> contents) => ListPaneWidthsScope(
widths: _paneWidths,
child: FadeThroughStack(
key: _destinationStackKey,
index: AppDestination.values.indexOf(_selected),
children: contents,
),
);
}
@@ -334,12 +347,14 @@ class _ListPaneBar extends StatelessWidget
required this.listenable,
required this.initial,
required this.split,
required this.preferredWidth,
required this.bar,
});
final Listenable listenable;
final SegmentedBar initial;
final bool Function() split;
final double? Function() preferredWidth;
final SegmentedBar Function() bar;
@override
@@ -354,6 +369,7 @@ class _ListPaneBar extends StatelessWidget
listenable: listenable,
builder: (context, _) => ListPaneWidth(
split: split(),
preferredWidth: preferredWidth(),
alignment: AlignmentDirectional.topStart,
child: bar(),
),