resolveToolkitIcon

fun resolveToolkitIcon(icon: ToolkitIcon, selectedIcon: ToolkitIcon, selected: Boolean, interacted: Boolean = false): ToolkitIcon(source)

Picks which of the two icons of a component has to be rendered.

The rules cover the three combinations the toolkit supports:

  • Static only (vector, drawable resource, and/or bitmap): selectedIcon while selected, icon otherwise.

  • Static normal icon + animated selected icon: the static icon is shown until the component is either selected or clicked at least once (interacted); from then on the AVD is rendered so it can play. This is the "Icons.Rounded.Share at rest, animation on click" case. The first frame of the AVD should be drawn like the static icon, otherwise the swap is visible.

  • Animated only: the AVD is always rendered, resting on its first or last frame depending on the selection state.

Parameters

icon

Icon declared for the unselected state.

selectedIcon

Icon declared for the selected state.

selected

Whether the component is currently selected.

interacted

Whether the component has been clicked at least once while composed.