Files
pipelines/app/lib/shell/list_detail_policy.dart
T
alan 40e94cc3da Shell: on wide split layouts the destination tabs sit under the list pane
The four destination buttons move from the bottom right over the detail
pane to the bottom of the list pane, centred in the (dragged) list width.
The list now keeps the bar's height as bottom clearance; the detail pane
clears only the system inset, so its tabs, the chat composer and the
artifact actions sit at its bottom edge. Phone layout is unchanged.
kStackedBarGap is gone with the stacked bars.
2026-11-03 12:30:56 +00:00

84 lines
3.0 KiB
Dart

import 'dart:math' as math;
import 'package:flutter/widgets.dart';
/// At least this wide, a destination keeps its list beside the open item
/// (with the destination rail) instead of pushing the item as its own page.
const double kListDetailMinWidth = 600;
const double _bodyWindowTarget = 0.6;
const double _bodyWindowMinimum = 0.5;
const double _bodyAvailableMaximum = 0.75;
/// The widest the list pane grows beside an open item: on a very wide window
/// (a 4K monitor) the extra width goes to the open item, not the list.
const double kListPaneMaxWidth = 440;
/// Whether the window at [context] shows list and detail side by side.
bool showsListBesideDetail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kListDetailMinWidth;
/// The narrowest list pane a drag leaves.
const double kListPaneMinWidth = 240;
/// The narrowest open item a drag leaves, beside the share of the window it
/// always keeps (so its own tabs, floating at its bottom, still fit).
const double kDetailPaneMinWidth = 320;
const double _listWindowMaximum = 0.6;
/// How far a drag may resize the list pane for a [window] this wide and
/// [available] width for both panes and their divider; null when the window
/// is too small for any width but the default policy's.
({double min, double max})? listPaneWidthBounds(
double window,
double available,
) {
final bodyMinimum = math.max(
window * _bodyWindowMinimum,
kDetailPaneMinWidth,
);
final maximum = math.min(
available - 1 - bodyMinimum,
window * _listWindowMaximum,
);
if (maximum < kListPaneMinWidth) return null;
return (min: kListPaneMinWidth, max: maximum);
}
/// The open item's width beside a list, for a [window] this wide and
/// [available] width for both panes and their divider. A [preferred] list
/// width (the operator's drag) replaces the default policy, clamped to
/// [listPaneWidthBounds].
double listDetailBodyWidth(
double window,
double available, [
double? preferred,
]) {
if (preferred != null) {
final bounds = listPaneWidthBounds(window, available);
if (bounds != null) {
return available - 1 - preferred.clamp(bounds.min, bounds.max);
}
}
// Target 60% of the full window. Keep at least half for the body while
// leaving a flexible share for native list controls on tighter windows.
final requestedMinimum = window * _bodyWindowMinimum;
final minimum = available > requestedMinimum
? requestedMinimum
: available * _bodyWindowMinimum;
final maximum = math.max(minimum, available * _bodyAvailableMaximum);
final body = (window * _bodyWindowTarget).clamp(minimum, maximum);
// Past the list's cap, the open item takes the rest.
return math.max(body, available - 1 - kListPaneMaxWidth);
}
/// The list pane's width beside an open item (see [listDetailBodyWidth]),
/// one divider excluded.
double listDetailListWidth(
double window,
double available, [
double? preferred,
]) => math.max(
0,
available - 1 - listDetailBodyWidth(window, available, preferred),
);