Increase floating tab icon sizes

This commit is contained in:
2026-11-01 11:33:01 +00:00
parent 5346759665
commit fea3d770b4
2 changed files with 54 additions and 18 deletions
@@ -48,33 +48,39 @@ class FloatingDestinationBar extends StatelessWidget {
final ValueChanged<int> onTap;
final List<FloatingDestinationItem> items;
/// Height of the Material bar inside the pill (the stock bar is 80; with
/// labels hidden the icon and its highlight need less).
static const double materialHeight = 56;
/// The icon sizes used by the two host navigation controls.
static const double materialIconSize = 28;
static const double cupertinoIconSize = 30;
/// Height of the Cupertino bar inside the pill (the stock bar's 50).
static const double cupertinoHeight = 50;
/// Padding between the icon (Material 24, Cupertino 26) and the edge of
/// its selection circle.
/// Padding between each icon and the edge of its selection circle.
static const double _materialRing = 8;
static const double _cupertinoRing = 6;
/// The gap between a circle and the pill's nearest edge or neighbour.
/// Keeping these as the source constants makes the bar grow with the icons.
static const double _materialEdgeGap = 8;
static const double _cupertinoEdgeGap = 6;
/// Diameter of the selection circle.
static const double materialHighlightSize = 24 + 2 * _materialRing;
static const double cupertinoHighlightSize = 26 + 2 * _cupertinoRing;
static const double materialHighlightSize =
materialIconSize + 2 * _materialRing;
static const double cupertinoHighlightSize =
cupertinoIconSize + 2 * _cupertinoRing;
/// Height of the host bar, derived from its circle and the equal edge gaps.
static const double materialHeight =
materialHighlightSize + 2 * _materialEdgeGap;
static const double cupertinoHeight =
cupertinoHighlightSize + 2 * _cupertinoEdgeGap;
/// The gap between a tab's circle and the pill's top and bottom; the outer
/// circles keep the same gap from the pill's sides, and neighbours from
/// each other.
static const double materialEdgeGap =
(materialHeight - materialHighlightSize) / 2;
static const double cupertinoEdgeGap =
(cupertinoHeight - cupertinoHighlightSize) / 2;
static const double materialEdgeGap = _materialEdgeGap;
static const double cupertinoEdgeGap = _cupertinoEdgeGap;
/// Width of one tab: its circle and one edge gap (48 Material, 44
/// Cupertino: the platforms' minimum touch targets). The pill is one more
/// edge gap wider than its tabs.
/// Width of one tab: its circle and one edge gap. The pill is one more edge
/// gap wider than its tabs.
static const double materialTabWidth =
materialHighlightSize + materialEdgeGap;
static const double cupertinoTabWidth =
@@ -182,6 +188,9 @@ class FloatingDestinationBar extends StatelessWidget {
indicatorColor: Colors.transparent,
indicatorShape: CircleBorder(),
height: materialHeight,
iconTheme: WidgetStatePropertyAll(
IconThemeData(size: materialIconSize),
),
// Icons only; the label remains each tab's accessible name and its
// tooltip.
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
@@ -240,7 +249,7 @@ class FloatingDestinationBar extends StatelessWidget {
// Secondary-label translucency over glass falls below text contrast
// requirements. The host label role remains readable in both themes.
inactiveColor: CupertinoColors.label.resolveFrom(context),
iconSize: 26,
iconSize: cupertinoIconSize,
height: cupertinoHeight,
currentIndex: currentIndex,
onTap: onTap,
@@ -94,6 +94,33 @@ void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: icon and selection circle sizes grow together', (
tester,
) async {
await pump(
tester,
cupertino: cupertino,
size: const Size(390, 844),
child: Align(
alignment: Alignment.bottomCenter,
child: bar(cupertino: cupertino, count: 2, selected: 0),
),
);
final icon = tester.getRect(find.byIcon(icons.first));
final mark = circle(tester, 0);
final iconSize = cupertino
? FloatingDestinationBar.cupertinoIconSize
: FloatingDestinationBar.materialIconSize;
final highlightSize = cupertino
? FloatingDestinationBar.cupertinoHighlightSize
: FloatingDestinationBar.materialHighlightSize;
expect(icon.width, iconSize);
expect(icon.height, iconSize);
expect(mark.width, highlightSize);
expect(mark.height, highlightSize);
});
for (final placement in placements) {
testWidgets('$host ${placement.name}: compact at the bottom right; the '
'outer circles keep the top gap from the sides and neighbours', (