Compact floating tab bars with circular selection and equal edge gaps
The floating tab bar is now sized to its icon tabs at the bottom right on every width, the selected icon sits in a tinted circle on both hosts, and the gap from each outer circle to the pill's sides equals the gap to its top, bottom and neighbours.
This commit is contained in:
@@ -48,16 +48,25 @@ void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: phone bar spans the width minus its margins', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('$host: phone bar hugs its tabs at the bottom right too, and '
|
||||
'taps beside it reach the content', (tester) async {
|
||||
taps = 0;
|
||||
await setSize(tester, const Size(390, 844));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
final rect = tester.getRect(pill());
|
||||
expect(rect.left, 16);
|
||||
expect(
|
||||
rect.width,
|
||||
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
|
||||
);
|
||||
expect(rect.right, 390 - 16);
|
||||
expect(rect.bottom, 844 - 16);
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
await tester.tapAt(Offset(rect.left - 40, rect.center.dy));
|
||||
await tester.pump();
|
||||
expect(taps, 1);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host: wide bar hugs its tabs at the right edge, content '
|
||||
@@ -69,13 +78,17 @@ void main() {
|
||||
expect(rect.right, 1200 - 16);
|
||||
expect(rect.bottom, 800 - 16);
|
||||
expect(rect.width, lessThan(1200 * 0.6));
|
||||
// Four icon-only tabs (Settings opens from the Pipelines bar).
|
||||
// Four icon-only tabs (Settings opens from the Pipelines bar) and one
|
||||
// more edge gap, so the outer circles keep it from the sides.
|
||||
expect(
|
||||
rect.width,
|
||||
4 *
|
||||
(cupertino
|
||||
? FloatingDestinationBar.cupertinoTabWidth
|
||||
: FloatingDestinationBar.materialTabWidth) +
|
||||
(cupertino
|
||||
? FloatingDestinationBar.cupertinoTabWidth
|
||||
: FloatingDestinationBar.materialTabWidth),
|
||||
? FloatingDestinationBar.cupertinoEdgeGap
|
||||
: FloatingDestinationBar.materialEdgeGap),
|
||||
);
|
||||
// No rail or sidebar: the content starts at the left edge.
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
@@ -127,7 +140,11 @@ void main() {
|
||||
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
await tester.pump();
|
||||
expect(tester.getRect(pill()).width, 390 - 32);
|
||||
expect(
|
||||
tester.getRect(pill()).width,
|
||||
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
|
||||
);
|
||||
expect(tester.getRect(pill()).right, 390 - 16);
|
||||
expect(tester.state(find.byType(StatefulBuilder)), same(state));
|
||||
});
|
||||
|
||||
@@ -186,7 +203,12 @@ void main() {
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(tester.getRect(pill()).width, 320 - 32);
|
||||
// Sized to its four tabs at the right, as on any width.
|
||||
expect(
|
||||
tester.getRect(pill()).width,
|
||||
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
|
||||
);
|
||||
expect(tester.getRect(pill()).right, 320 - 16);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,7 +90,12 @@ void main() {
|
||||
of: find.byType(FloatingDestinationBar),
|
||||
matching: find.byType(GlassPill),
|
||||
);
|
||||
expect(tester.getSize(destinationPill).width, 358);
|
||||
// Sized to its four tabs at the bottom right.
|
||||
expect(
|
||||
tester.getSize(destinationPill).width,
|
||||
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
|
||||
);
|
||||
expect(tester.getRect(destinationPill).right, 390 - 16);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
||||
await tester.pump();
|
||||
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||
|
||||
@@ -192,12 +192,16 @@ void main() {
|
||||
expect(pill.width, lessThan(1200 * 0.6));
|
||||
});
|
||||
|
||||
testWidgets('$host 390: the bar spans the phone', (tester) async {
|
||||
testWidgets('$host 390: the bar hugs its tabs at the phone\'s bottom '
|
||||
'right', (tester) async {
|
||||
await setSize(tester, const Size(390, 844));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
|
||||
await tester.pump();
|
||||
final pill = destinationPill(tester);
|
||||
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
|
||||
expect(
|
||||
pill.width,
|
||||
FloatingDestinationBar.pillWidth(cupertino: cupertino, tabs: 4),
|
||||
);
|
||||
expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user