GlassTabBarPhysics class
Everything that moves in a glass tab bar, advanced one frame at a time: the platter (the bar's own glass), the lens that selects a tab, and the states that drive the glass optics.
Geometry is in the bar's layout coordinates, in logical pixels. The lens and the tab content live inside the platter and share its transform (platterTransform): the platter swells while pressed and stretches and drifts toward the finger.
The model and its numbers come from UIKit's own tab bar on the iOS 26.5 simulator: its lens and the bar's flex measured every frame under scripted touches (398×62pt bar, four tabs), with their springs. Where UIKit's lens trails the finger through a spring, this lens follows it exactly.
Constructors
- GlassTabBarPhysics({required int count, required int selectedIndex})
Properties
- clear → double
-
Same as liftProgress.
no setter
- count → int
-
no setter
- flex → double
-
The soft-body state that drives the flex.
no setter
- flexDrift → double
-
no setter
- flexScale → Size
-
The lens's flex scale (x, y) and drift, as drawn.
no setter
- glowAlpha → double
-
no setter
- glowCenter → Offset?
-
The fingertip glow's center in bar coordinates: the finger, and where
it left once lifted (null before any touch).
no setter
- glowSigma → double
-
no setter
- glowSize → double
-
The glow's diameter and blur (gaussian sigma) on screen, and its
opacity.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isActive → bool
-
Whether anything is still moving (or pressed).
no setter
- lensInPlatter → Rect
-
The lens in platter coordinates: its bounds (the pill grown by the
lift) with its flex scale, drifted by the flex.
no setter
- lensRect → Rect
-
The lens outline, in bar coordinates.
no setter
- lensX → double
-
The lens's center along the bar, in platter coordinates (without its
flex drift).
no setter
- lift → double
-
How far the lens's bounds have grown from the pill's (0 to 1).
no setter
- liftProgress → double
-
0 for the frosted resting pill, 1 for clear glass (UIKit's lens lift
progress).
no setter
- padding → EdgeInsets
-
Gaps between the platter's edges and its tabs (UIKit's: inset all
round).
no setter
- pillHeight → double
-
no setter
- pillWidth → double
-
Width of the resting pill, as UIKit sizes its tab buttons: wider than
the spacing between tabs, so that neighbours overlap. For up to three
tabs they overlap by 8pt and the bar hugs them (see naturalWidth); for
more the bar fills its width and they overlap by 40pt in all for four
tabs, 33pt for five (107.5pt for four tabs in 398pt, 84.6pt for five).
no setter
- platterDrift → Offset
-
The platter's translation toward the finger.
no setter
- platterRect → Rect
-
The platter's outline, in bar coordinates.
no setter
- platterScale → double
-
The platter's swell alone (1 at rest, pressedScale pressed).
no setter
- platterScaleX → double
-
The platter's scale along x, with its stretch toward the finger.
no setter
- platterScaleY → double
-
The platter's scale along y, with its stretch toward the finger.
no setter
- platterTransform → Matrix4
-
The same mapping as toBar, for painting the platter's content.
no setter
- press → double
-
How pressed the bar is, 0 to 1: its wash and fingertip glow follow.
no setter
- pressed → bool
-
no setter
- reduceMotion ↔ bool
-
Reduce Motion, as UIKit's bar honors it: the resting selection slides
under the finger without lifting into a lens, and nothing swells,
stretches or flexes.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedIndex → int
-
The tab that the lens rests on when released.
no setter
- size → Size
-
no setter
- stretch → double
-
Log of the flex's x scale, for compatibility with earlier callers.
no setter
- tabMiddle → double
-
The tabs' vertical center.
no setter
- touch → Offset?
-
The finger, in bar coordinates, while pressed.
no setter
Methods
-
layout(
Size size, int count, {EdgeInsets padding = const EdgeInsets.all(inset), bool search = false}) → void -
Lays the bar out at
sizewithcounttabs,paddinginside its edges. -
nearestTab(
double x) → int -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pointerCancel(
{double? time}) → void -
pointerDown(
Offset position, {double? time}) → void -
A finger came down at
position, in bar coordinates.timeis when, in seconds on the clock given to tick; without it the touch counts as half a frame before the next tick. -
pointerMove(
Offset position, {double? time}) → void -
pointerUp(
{double? time}) → int - Ends the touch and returns the tab it chose: the one nearest the lens, which is under the finger.
-
select(
int index) → void - The selection changed from outside (or a choice was not taken up).
-
tabCenter(
int index) → double -
Center of tab
index: the end tabs' pills sit at the padding, and the others are evenly spaced between them. -
tick(
double now) → bool -
Advances everything to
now(in seconds; the same clock as touch times). Returns whether anything is still moving. -
toBar(
Offset p) → Offset - Maps platter coordinates (the bar's layout) to where they are drawn.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- debugOnTick ↔ void Function(GlassTabBarPhysics physics, double now)?
-
Called at the end of every tick, for debugging and measurement.
getter/setter pair
Static Methods
-
naturalWidth(
int count, double label, {double horizontal = 2 * inset, bool search = false}) → double? -
The width of UIKit's bar of
counttabs whose widest label islabelpoints wide, or null for four tabs or more, which fill the width they are given. Each tab is 94pt wide, or 39pt wider than the widest label; three tabs with short labels make a 274pt bar.horizontalis the padding at its two ends.
Constants
- glowBlur → const double
- glowDiameter → const double
- glowOpacity → const double
- inset → const double
- UIKit's gap between the platter's edge and its tabs' resting pills.
- lensHangTime → const double
- liftOutset → const double
- How much the lens outgrows the pill when lifted, on each side.
- pressedScale → const double
- tabHeight → const double
- UIKit's tab (and resting pill) height: its 62pt bar less inset above and below.