Merge: list pane width cap

This commit is contained in:
2026-11-02 16:14:50 +00:00
3 changed files with 36 additions and 2 deletions
+7 -1
View File
@@ -15,6 +15,10 @@ 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;
@@ -29,7 +33,9 @@ double listDetailBodyWidth(double window, double available) {
? requestedMinimum
: available * _bodyWindowMinimum;
final maximum = math.max(minimum, available * _bodyAvailableMaximum);
return (window * _bodyWindowTarget).clamp(minimum, maximum);
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]),
@@ -1,8 +1,11 @@
import 'dart:math' as math;
import 'dart:ui' show Tristate;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/features/chat/screen.dart';
@@ -131,7 +134,13 @@ void main() {
paneWidths.add(before);
bodyWidths.add(bodyBefore);
expect(bodyBefore, greaterThanOrEqualTo(width * 0.5));
expect(bodyBefore, lessThanOrEqualTo(width * 0.6));
// 60% of the window, or more once the list reaches its cap.
expect(
bodyBefore,
lessThanOrEqualTo(
math.max(width * 0.6, width - 1 - kListPaneMaxWidth) + 0.5,
),
);
expect(bodyBefore, greaterThan(before));
final rowKeys = switch (destination) {
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
+19
View File
@@ -0,0 +1,19 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/list_detail.dart';
void main() {
test('the list pane stops growing at its cap on very wide windows', () {
for (final width in [1920.0, 2560.0, 3840.0]) {
expect(listDetailListWidth(width, width), kListPaneMaxWidth);
expect(listDetailBodyWidth(width, width), width - 1 - kListPaneMaxWidth);
}
});
test('narrower windows keep the 60/40 split', () {
// An open Fold and a laptop window: the list is under its cap.
for (final width in [880.0, 1100.0]) {
expect(listDetailBodyWidth(width, width), closeTo(width * 0.6, 0.01));
expect(listDetailListWidth(width, width), lessThan(kListPaneMaxWidth));
}
});
}