Align wide desktop tabs to leading edge
This commit is contained in:
@@ -173,7 +173,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
// remounts a destination.
|
||||
//
|
||||
// While the tab shows its list beside an open item the bar moves under
|
||||
// the list pane, centred in the list's (dragged) width, so the open item
|
||||
// the leading edge of the list pane, so the open item
|
||||
// keeps its whole height: the list clears the bar and the item clears
|
||||
// only the system inset (see ListDetailPanes). The bar keeps its place
|
||||
// in the tree, so a split never replays its entrance.
|
||||
@@ -198,7 +198,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(shellTabDestinations[value]),
|
||||
items: _destinationItems(),
|
||||
alignment: split ? Alignment.bottomCenter : null,
|
||||
alignment: split ? AlignmentDirectional.bottomStart : null,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -13,10 +13,11 @@ import 'floating_destination_labels.dart';
|
||||
/// frosted [GlassPill] buttons, one per tab, instead of a full-width system
|
||||
/// bar. Used for the app's destinations and for every page's own tabs.
|
||||
///
|
||||
/// The row is only as wide as its buttons and sits at the trailing (right,
|
||||
/// in left-to-right text) edge, near the thumb, keeping [kFloatingBarMargin]
|
||||
/// from the sides and above the bottom safe area. Only the buttons take
|
||||
/// taps: the gaps between and beside them reach the content behind. A row
|
||||
/// The row is only as wide as its buttons and, by default, sits at the trailing
|
||||
/// (right, in left-to-right text) edge, near the thumb, keeping
|
||||
/// [kFloatingBarMargin] from the sides and above the bottom safe area. Hosts
|
||||
/// can request another alignment for a pane-specific layout. Only the buttons
|
||||
/// take taps: the gaps between and beside them reach the content behind. A row
|
||||
/// squeezed below its natural width narrows its gaps, then scales down.
|
||||
///
|
||||
/// The selected button is filled with the host's selection tint, which
|
||||
@@ -48,8 +49,8 @@ class FloatingDestinationBar extends StatefulWidget {
|
||||
final bool showLabels;
|
||||
|
||||
/// Where the row sits in the width it is given, at [FloatingBarEdge.bottom]:
|
||||
/// the trailing end by default. The shell centres its tabs under the list
|
||||
/// pane while a list shows beside an open item.
|
||||
/// the trailing end by default. The shell can align its main tabs to the
|
||||
/// leading edge of a list pane while a list shows beside an open item.
|
||||
final AlignmentGeometry? alignment;
|
||||
|
||||
/// The edge the bar floats at. At [FloatingBarEdge.top] (an open item's
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Desktop main tabs leading alignment
|
||||
|
||||
Wide list-detail layouts now place the main destination tab row at the leading
|
||||
edge of the list pane. Narrow layouts retain their trailing placement, and
|
||||
page-specific tab bars remain unchanged. Focused shell tests cover Material and
|
||||
Cupertino geometry, including stored pane widths.
|
||||
@@ -6,9 +6,11 @@ import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_labels.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
|
||||
/// Main navigation keeps visible captions and full-size targets, floating at
|
||||
/// the trailing edge on a phone and centered under the list on a wide window.
|
||||
/// the trailing edge on a phone and the leading edge under the list on a wide
|
||||
/// window.
|
||||
void main() {
|
||||
Finder pill() => find.descendant(
|
||||
of: find.byType(FloatingDestinationBar),
|
||||
@@ -110,7 +112,7 @@ void main() {
|
||||
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host: wide bar hugs its tabs under the list column, content '
|
||||
testWidgets('$host: wide leading bar under the list, content '
|
||||
'keeps the width and taps beside the bar reach it', (tester) async {
|
||||
taps = 0;
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
@@ -118,13 +120,7 @@ void main() {
|
||||
final rect = tester.getRect(pill());
|
||||
// With no item open the bar still sits under the list column, where it
|
||||
// sits beside an open item, so it never jumps sides.
|
||||
expect(
|
||||
rect.center.dx,
|
||||
moreOrLessEquals(
|
||||
listDetailListWidth(1200, 1200, null) / 2,
|
||||
epsilon: 0.5,
|
||||
),
|
||||
);
|
||||
expect(rect.left, moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5));
|
||||
expect(rect.bottom, 800 - 16);
|
||||
expect(rect.width, lessThan(1200 * 0.6));
|
||||
// Captions participate in the bar's content-driven width.
|
||||
@@ -179,11 +175,8 @@ void main() {
|
||||
tester.view.physicalSize = const Size(1200, 800);
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.getRect(pill()).center.dx,
|
||||
moreOrLessEquals(
|
||||
listDetailListWidth(1200, 1200, null) / 2,
|
||||
epsilon: 0.5,
|
||||
),
|
||||
tester.getRect(pill()).left,
|
||||
moreOrLessEquals(kFloatingBarMargin, epsilon: 0.5),
|
||||
);
|
||||
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
|
||||
expect(tester.state(find.byType(StatefulBuilder)), same(state));
|
||||
|
||||
@@ -9,8 +9,8 @@ import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
|
||||
/// While a tab shows its list beside an open item, the shell's destination
|
||||
/// bar moves to the bottom of the list pane, centred in the list's (dragged)
|
||||
/// width. The list clears the bar; the item keeps its whole height, its own
|
||||
/// bar moves to the leading edge at the bottom of the list pane, including
|
||||
/// after the list's width is dragged. The list clears the bar; the item keeps its whole height, its own
|
||||
/// bottom control (its tabs, or a composer) at its bottom edge.
|
||||
void main() {
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
@@ -128,8 +128,8 @@ void main() {
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final pill = destinationPill(tester);
|
||||
// Centred at the bottom of the list pane, never over the detail.
|
||||
expect(pill.center.dx, closeTo(list.center.dx, 0.5));
|
||||
// Leading at the bottom of the list pane, never over the detail.
|
||||
expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5));
|
||||
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right));
|
||||
expect(pill.overlaps(body), isFalse, reason: 'never over the detail');
|
||||
@@ -227,17 +227,24 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
final store = MemoryListPaneWidthStore({'chat': 300});
|
||||
await tester.pumpWidget(shell(cupertino: cupertino, store: store));
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(list.width, closeTo(300, 0.5));
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.center.dx, closeTo(list.center.dx, 0.5));
|
||||
expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin));
|
||||
for (final width in [300.0, 520.0]) {
|
||||
final store = MemoryListPaneWidthStore({'chat': width});
|
||||
await tester.pumpWidget(
|
||||
KeyedSubtree(
|
||||
key: ValueKey(width),
|
||||
child: shell(cupertino: cupertino, store: store),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(list.width, closeTo(width, 0.5));
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.left, closeTo(list.left + kFloatingBarMargin, 0.5));
|
||||
expect(pill.left, greaterThanOrEqualTo(kFloatingBarMargin - 0.5));
|
||||
expect(pill.right, lessThanOrEqualTo(list.right - kFloatingBarMargin));
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('$host 1200 Settings: a page without a list keeps the bar '
|
||||
@@ -260,10 +267,7 @@ void main() {
|
||||
final pill = destinationPill(tester);
|
||||
// Same place as beside an open item (Search has no split), so opening
|
||||
// or closing an item never moves the bar across the window.
|
||||
expect(
|
||||
pill.center.dx,
|
||||
closeTo(listDetailListWidth(1200, 1200, null) / 2, 0.5),
|
||||
);
|
||||
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
|
||||
expect(pill.width, lessThan(1200 * 0.6));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user