ToolkitFab

class ToolkitFab(val icon: ToolkitIcon, val onClick: () -> Unit, val label: String? = null, val contentDescription: String? = label, val size: FabSize = FabSize.Regular, val color: FabColor = FabColor.Primary, val expanded: Boolean = true, val visible: Boolean = true, val id: Any = label ?: contentDescription ?: icon)(source)

A floating action button, described rather than drawn: the Toolkit's scaffolds turn a list of these into a column of buttons at the bottom end of the screen, with the Toolkit's click sound, haptics, press bounce and animated icons.

listOf(
ToolkitFab(ToolkitIcon.Vector(Icons.Outlined.Search), onClick = ::search, size = FabSize.Small, color = FabColor.Secondary),
ToolkitFab(ToolkitIcon.Vector(Icons.Outlined.Add), onClick = ::add, label = "New item", expanded = !scrolled),
)

Parameters

icon

The button's icon. An animated vector or Lottie icon plays on each click.

onClick

What the button does.

label

Makes the button an extended one, with this text beside the icon.

contentDescription

What a screen reader says; defaults to label. Give one for a button without a label.

size

Material 3's floating action button sizes, for both plain and extended buttons.

color

Which container colour of the theme the button takes.

expanded

For an extended button: false folds it to its icon, as when a list scrolls.

visible

False scales the button out; it keeps its place in the list for when it returns.

id

Tells buttons apart as the list changes, so each animates in and out on its own. Defaults to the label or, without one, the content description.

Constructors

Link copied to clipboard
constructor(icon: ToolkitIcon, onClick: () -> Unit, label: String? = null, contentDescription: String? = label, size: FabSize = FabSize.Regular, color: FabColor = FabColor.Primary, expanded: Boolean = true, visible: Boolean = true, id: Any = label ?: contentDescription ?: icon)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val id: Any
Link copied to clipboard
Link copied to clipboard
val onClick: () -> Unit
Link copied to clipboard
Link copied to clipboard