ComposableTheme¶
@Serializable
data class ComposableTheme(
val isNineslice: Boolean = false,
val states: Map<String, ThemeState>,
val variants: Map<String, StatefulTheme> = emptyMap(),
val minSize: Size? = null,
val contentPadding: ThemePadding? = null
)
The full theme definition for a single composable type (e.g. button, slot).
Contains base states and optional named variants (e.g. "dark").
Constructors¶
ComposableTheme¶
constructor(
isNineslice: Boolean = false,
states: Map<String, ThemeState>,
variants: Map<String, StatefulTheme> = emptyMap(),
minSize: Size? = null,
contentPadding: ThemePadding? = null
)
Types¶
Companion¶
object Companion
Properties¶
contentPadding¶
val contentPadding: ThemePadding?
isNineslice¶
val isNineslice: Boolean
minSize¶
states¶
val states: Map<String, ThemeState>
variants¶
val variants: Map<String, StatefulTheme>
Functions¶
contentPaddingModifier¶
The Modifier.padding a composable using this theme should reserve around its own content, per ComposableTheme.contentPadding - a no-op Modifier when the theme doesn't declare one.
getState¶
inline fun getState(stateName: String, variantName: String): ThemeState
Returns the ThemeState for stateName in variantName, falling back to the base state map and ultimately the "default" state.
hasState¶
Returns true if stateName exists in variantName or the base state map.
intrinsicSizeModifier¶
fun ComposableTheme.intrinsicSizeModifier(ignoreMinSize: Boolean = false): Modifier
The Modifier.sizeIn floor a composable using this theme should apply to its own layout node: ComposableTheme.minSize when the theme declares one, otherwise the "default" state's own sprite dimensions for a non-nine-slice texture (which can't stretch without distorting), otherwise no floor at all - a nine-slice texture with no explicit ComposableTheme.minSize is free to shrink or stretch to fit its content.
Parameters
- ignoreMinSize: skips
ComposableTheme.minSize, for a caller that means to size the widget itself and needs its own Modifier.size to be the last word. A declared minimum is what a theme thinks the widget should never be smaller than, and it wins over a caller's own size otherwise - the two become amin > maxconstraint and the node cannot lay out at all. The sprite-size floor below is not skipped: that one is about a texture that would visibly distort if squashed, which is a fact about the image rather than an opinion about the widget.