Resize chat list into compact rail and animate visible chat markers
This commit is contained in:
@@ -96,12 +96,19 @@ class ListDetailPanes extends StatefulWidget {
|
||||
required this.detail,
|
||||
this.detailIdentity,
|
||||
this.listWidthOverride,
|
||||
this.compactListWidth,
|
||||
this.onListCompactChanged,
|
||||
});
|
||||
|
||||
final Widget list;
|
||||
|
||||
/// Focus layouts may retain the list offstage at zero/compact width.
|
||||
final double? listWidthOverride;
|
||||
|
||||
/// Optional compact rail reached by dragging below the normal list minimum.
|
||||
/// The grab handle remains available at the rail edge to expand it again.
|
||||
final double? compactListWidth;
|
||||
final ValueChanged<bool>? onListCompactChanged;
|
||||
final Widget detail;
|
||||
|
||||
/// Which item [detail] shows; selecting another item closes any page the
|
||||
@@ -139,11 +146,30 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
final window = media.size.width;
|
||||
final available = constraints.maxWidth;
|
||||
final preferred = widths.widthFor(key);
|
||||
final normalWidth = listDetailListWidth(
|
||||
window,
|
||||
available,
|
||||
preferred,
|
||||
final resizable =
|
||||
widget.listWidthOverride == null ||
|
||||
widget.listWidthOverride == widget.compactListWidth;
|
||||
final bounds = resizable
|
||||
? listPaneWidthBounds(
|
||||
window,
|
||||
available,
|
||||
minimum: widget.compactListWidth ?? kListPaneMinWidth,
|
||||
)
|
||||
: null;
|
||||
final compactThreshold = math.min(
|
||||
kListPaneMinWidth,
|
||||
listDetailListWidth(window, available) * .8,
|
||||
);
|
||||
// In a tight split the shell's bar and list share the default
|
||||
// width policy. The rail can still collapse/expand there without
|
||||
// making the shell's controls wider than their list.
|
||||
final normalBounds = listPaneWidthBounds(window, available);
|
||||
final normalWidth =
|
||||
widget.compactListWidth != null &&
|
||||
normalBounds != null &&
|
||||
preferred != null
|
||||
? preferred.clamp(compactThreshold, normalBounds.max).toDouble()
|
||||
: listDetailListWidth(window, available, preferred);
|
||||
final listWidth = (widget.listWidthOverride ?? normalWidth)
|
||||
.clamp(0.0, math.max(0.0, available - kDetailPaneMinWidth))
|
||||
.toDouble();
|
||||
@@ -152,9 +178,11 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
final retainedWidth = widget.listWidthOverride == null
|
||||
? listWidth
|
||||
: math.max(normalWidth, kListPaneMinWidth);
|
||||
final bounds = widget.listWidthOverride == null
|
||||
? listPaneWidthBounds(window, available)
|
||||
: null;
|
||||
void resize(double value) {
|
||||
widths.preview(key, value);
|
||||
widget.onListCompactChanged?.call(value < compactThreshold);
|
||||
}
|
||||
|
||||
Widget body = widget.detail;
|
||||
if (split) {
|
||||
// Beside the list the item is not under the shell's top bar (it
|
||||
@@ -236,11 +264,14 @@ class _ListDetailPanesState extends State<ListDetailPanes> {
|
||||
width: kListPaneDividerGrabWidth,
|
||||
child: ListPaneDivider(
|
||||
width: listWidth,
|
||||
min: bounds.min,
|
||||
min: widget.compactListWidth ?? bounds.min,
|
||||
max: bounds.max,
|
||||
onChanged: (value) => widths.preview(key, value),
|
||||
onChanged: resize,
|
||||
onChangeEnd: () => widths.commit(key),
|
||||
onReset: () => widths.reset(key),
|
||||
onReset: () {
|
||||
widths.reset(key);
|
||||
widget.onListCompactChanged?.call(false);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -30,8 +30,9 @@ const double _listWindowMaximum = 0.6;
|
||||
/// is too small for any width but the default policy's.
|
||||
({double min, double max})? listPaneWidthBounds(
|
||||
double window,
|
||||
double available,
|
||||
) {
|
||||
double available, {
|
||||
double minimum = kListPaneMinWidth,
|
||||
}) {
|
||||
final bodyMinimum = math.max(
|
||||
window * _bodyWindowMinimum,
|
||||
kDetailPaneMinWidth,
|
||||
@@ -40,8 +41,8 @@ const double _listWindowMaximum = 0.6;
|
||||
available - 1 - bodyMinimum,
|
||||
window * _listWindowMaximum,
|
||||
);
|
||||
if (maximum < kListPaneMinWidth) return null;
|
||||
return (min: kListPaneMinWidth, max: maximum);
|
||||
if (maximum < minimum) return null;
|
||||
return (min: minimum, max: maximum);
|
||||
}
|
||||
|
||||
/// The open item's width beside a list, for a [window] this wide and
|
||||
|
||||
Reference in New Issue
Block a user