Tabs: the selected tab's icon is a little larger
The selected icon grows to 1.15x with the selection tint (220 ms, same curve) and shrinks back when another tab is selected, on every floating tab bar; reduced motion jumps straight to the size.
This commit is contained in:
@@ -156,6 +156,11 @@ class FloatingTabButton extends StatelessWidget {
|
||||
),
|
||||
child: FloatingTabBounce(motion: motion, index: index, child: icon),
|
||||
);
|
||||
// The selected icon is a little larger, growing with the selection.
|
||||
glyph = Transform.scale(
|
||||
scale: 1 + (Motion.tabSelectedIconScale - 1) * t,
|
||||
child: glyph,
|
||||
);
|
||||
final reveal = GlassReveal.maybeOf(context);
|
||||
if (reveal != null) {
|
||||
// The icon sits above the glass, so it fades with it here.
|
||||
|
||||
@@ -43,6 +43,10 @@ abstract final class Motion {
|
||||
/// The icon's scale at the top of its bounce.
|
||||
static const double tabBounceScale = 1.08;
|
||||
|
||||
/// How much larger the selected tab's icon is than the others; it grows
|
||||
/// and shrinks with the selection tint.
|
||||
static const double tabSelectedIconScale = 1.15;
|
||||
|
||||
/// Duration of each top-bar island's entrance pop (Back, title, actions).
|
||||
static const Duration barEntranceDuration = Duration(milliseconds: 240);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
|
||||
@@ -128,7 +129,12 @@ void main() {
|
||||
isA<CircleBorder>(),
|
||||
);
|
||||
final icon = tester.getRect(find.byIcon(icons[index]));
|
||||
expect(icon.size, Size(iconSize, iconSize));
|
||||
// Tab 0 is selected: its icon is a little larger than the others.
|
||||
final side = index == 0
|
||||
? iconSize * Motion.tabSelectedIconScale
|
||||
: iconSize;
|
||||
expect(icon.width, moreOrLessEquals(side));
|
||||
expect(icon.height, moreOrLessEquals(side));
|
||||
expect(icon.center, circle.center);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/motion/motion.dart';
|
||||
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';
|
||||
@@ -218,7 +219,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(fillAlpha(tester, 2), tint);
|
||||
expect(fillAlpha(tester, 0), 0);
|
||||
expect(iconWidth(tester, 2), moreOrLessEquals(iconSize));
|
||||
// At rest the selected icon is a little larger than the others.
|
||||
expect(
|
||||
iconWidth(tester, 2),
|
||||
moreOrLessEquals(iconSize * Motion.tabSelectedIconScale),
|
||||
);
|
||||
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
|
||||
expect(iconWidth(tester, 1), moreOrLessEquals(iconSize));
|
||||
final context = tester.element(find.byKey(tabKey(2)));
|
||||
final selectedColour = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
@@ -263,7 +270,12 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(fillAlpha(tester, 2), tint);
|
||||
expect(fillAlpha(tester, 0), 0);
|
||||
expect(iconWidth(tester, 2), moreOrLessEquals(iconSize));
|
||||
// No bounce, and the selected icon jumps straight to its larger size.
|
||||
expect(
|
||||
iconWidth(tester, 2),
|
||||
moreOrLessEquals(iconSize * Motion.tabSelectedIconScale),
|
||||
);
|
||||
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
|
||||
});
|
||||
|
||||
testWidgets('$host: switching the shell tabs never replays the main '
|
||||
|
||||
Reference in New Issue
Block a user