Class

StyleResolver

A resolver that will resolve the properties of a given style lambda.

Source set: Common
public class StyleResolver constructor(
    style: CommonStyle,
    styleState: StyleState = MutableStyleState(null),
) : RememberObserver

A resolver that will resolve the properties of a given style lambda. An instance of this should be created and passed to the styleResolver modifier which will resolve the style lambda in context.

Parameters

style a CommonStyle that will be invoked to resolve the style properties. CustomStyle types should provide a toCommonStyle() extension method that converts the custom style to CommonStyle to be passed as the value of the style parameter.
styleState a StyleState instance that is provided to the StyleStateScope as the StyleStateScope.state parameter. This allows the style to read the styleState during resolution to detect, for example, when the component being styled is focused, pressed, hovered, etc. in addition to custom states such as isPlaying.

Properties

style

Source set: Common
public var style: CommonStyle by mutableStateOf(style)

The style being resolved by the style resolver. Assigning a new value to this property will cause the style resolver to invalidate and the new style will be called on or before the next call to resolve.

styleState

Source set: Common
public var styleState: StyleState by mutableStateOf(styleState)

The style state being used to resolve the style. Assigning a new value to this property will cause the style resolver to invalidate and the new style will be called on or before the next call to resolve.

Functions

resolve

Source set: Common
public inline fun <R> resolve(block: StyleResolverScope.() -> R): R

Asks the StyleResolver to resolve the properties of a given style lambda. The resolved properties can be read in block.

Parameters

block called in a scope that allows style properties to be read.

onRemembered

Source set: Common
override fun onRemembered()

Implements RememberObserver API to allow composition to manage the lifetime of the StyleResolver

onForgotten

Source set: Common
override fun onForgotten()

Implements RememberObserver API to allow composition to manage the lifetime of the StyleResolver

onAbandoned

Source set: Common
override fun onAbandoned()

Implements RememberObserver API to allow composition to manage the lifetime of the StyleResolver

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: