Function

stylePropertyOf

Creates a new style property.

stylePropertyOf

Source set: Common
public fun <T> stylePropertyOf(
    name: String,
    interpolate: (a: T, b: T, t: Float) -> T = ::defaultInterpolate,
    defaultValue: () -> T,
): ProvidableStyleProperty<T>

Creates a new style property.

Defining a style property using stylePropertyOf produces a style property that will use a jump-cut halfway through the animation (except if the type implements Interpolatable as described below, and a select number of well-known types such as Dp, Float, Int, Long, Color and TextUnit). For types that do not support Interpolatable, it is recommended that a type specific interpolate lambda be supplied, even for types like Dp that are handled by default, to specify how to interpolate the values of T during animation.

If the type supports Interpolatable, such as Brush, stylePropertyOf will use the Interpolatable implementation instead of a jump-cut.

Parameters

name debug/tooling name for the property
interpolate interpolate the values a and b on t which is a fraction between 0f and 1f
defaultValue fallback value provider when the property is not provided

Content updated: