GlassTabBar class Panels and controls

A bottom bar of tabs whose selection becomes a glass drop under a finger.

The bar is a GlassBar — the theme's finish, the theme's label colour — and the drop is a clear glass that magnifies it. Under an adaptive host (GlassHost.adaptive) the bar reads its backdrop as a bar does, and the bottomAccessory's glass wears the bar's branch rather than its own. See the file comment for what each part costs.

At rest the selected item sits on a grey capsule in activeColor, and nothing about it but the bar is glass. Pressed, the capsule lifts into a drop kGlassTabDropGrow larger on every side that magnifies the bar by dropZoom; dragged, it follows the finger and the item under it takes the accent; let go, it settles on an item and onSelected is told which. A flick carries the drop on to the item it was heading for.

The items stack icon over label, as an iPhone's do, while the bar gives each less than 80 px, and sit side by side, as an iPad's do, above that. The bar is 60 tall stacked and 44 side by side, and takes the whole width it is given.

GlassTabBar(
  items: const <GlassTabItem>[
    GlassTabItem(icon: Icons.home, label: 'Home'),
    GlassTabItem(icon: Icons.search, label: 'Search'),
    GlassTabItem(icon: Icons.person, label: 'Profile'),
  ],
  selectedIndex: tab,
  onSelected: (int i) => setState(() => tab = i),
)

Note: the drop is glass on glass, so the frames that record while it is held take a second snapshot. While it moves, only the frames where the highlighted item changes record at all.

Minimized on scroll. With minimizeBehavior GlassTabBarMinimizeBehavior.onScrollDown, under a GlassTabBarMinimizer (a GlassScaffold is one), the bar collapses to a circle of its own height at its start edge when the content scrolls down — the selected item's icon in it — and expands when the content scrolls back up; a tap on the circle expands it too, and selects nothing. The collapse is a shape changing inside a declared travel region, so it takes no capture; under reduced motion it is not animated at all.

An accessory (bottomAccessory, UIKit's tabViewBottomAccessory) is a glass capsule kGlassTabAccessoryHeight tall above the bar, which moves down beside the collapsed circle. The bar's box is the same height either way, so a body told the bar's height is not laid out again for it.

Text size. The items' labels do not grow past the default text size, as UIKit's tab bar's do not: an item is a fifth of a phone's width, and at twice the size its label is cut mid-word and its icon meets the next one. A screen reader is given each label whole. At an accessibility text size (1.5 times and up) a touch on an item shows it in iOS's large content viewer: its icon and title large, in a panel in the middle of the screen, following the finger until it lifts. The panel goes in the nearest Overlay; with none there is no panel.

See also:

Inheritance

Constructors

GlassTabBar({required List<GlassTabItem> items, required int selectedIndex, required ValueChanged<int>? onSelected, Color? activeColor, double dropZoom = kGlassTabDropZoom, GlassDropMotion? dropMotion, GlassTabBarMinimizeBehavior minimizeBehavior = GlassTabBarMinimizeBehavior.never, Widget? bottomAccessory, Key? key})
A bar of items — at least two — with selectedIndex highlighted.
const

Properties

activeColor → Color?
The selected item's icon and label, and the one under a held drop. Null for iOS's systemBlue in the appearance of the bar's glass.
final
bottomAccessory → Widget?
A widget on a glass capsule above the bar — a now-playing row, a status — that moves down beside the bar's collapsed circle when it is minimized. Drawn in the bar's label colour. Null for none.
final
dropMotion → GlassDropMotion?
How the held drop deforms as it launches and brakes. Null takes GlassThemeData.dropMotion; GlassDropMotion.none keeps its shape. Off under reduced motion either way.
final
dropZoom → double
See kGlassTabDropZoom; 1 is a drop that does not magnify.
final
hashCode → int
The hash code for this object.
no setterinherited
items → List<GlassTabItem>
The tabs, left to right.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
minimizeBehavior → GlassTabBarMinimizeBehavior
Whether the bar collapses to the selected tab when the content scrolls down. GlassTabBarMinimizeBehavior.never by default; see the class comment.
final
onSelected → ValueChanged<int>?
Called with the item a tap or a drag settles on, when it is not selectedIndex. Null disables the bar.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedIndex → int
The selected item's index into items. The capsule slides to it when it changes, unless a finger is down on the bar.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<GlassTabBar>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited