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.

Summary

Public constructors

StyleResolver(style: CommonStyle, styleState: StyleState)
Cmn

Public functions

open Unit

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

Cmn
open Unit

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

Cmn
open Unit

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

Cmn
inline R
<R : Any?> resolve(block: StyleResolverScope.() -> R)

Asks the StyleResolver to resolve the properties of a given style lambda.

Cmn

Public constructors

StyleResolver

StyleResolver(
    style: CommonStyle,
    styleState: StyleState = MutableStyleState(null)
)
Parameters
style: CommonStyle

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: StyleState = MutableStyleState(null)

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.

Public functions

onAbandoned

open fun onAbandoned(): Unit

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

onForgotten

open fun onForgotten(): Unit

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

onRemembered

open fun onRemembered(): Unit

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

resolve

inline fun <R : Any?> 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: StyleResolverScope.() -> R

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