MaterialScopeKt

Added in 1.3.0-alpha03

public final class MaterialScopeKt


Summary

Public methods

static final @NonNull ColorBuilders.ColorProp
getColorProp(@NonNull MaterialScope receiver, int colorToken)

Retrieves the ColorProp from the customized or default Material theme or dynamic system theme with the given color token name.

static final @NonNull ModifiersBuilders.Corner
getCorner(@NonNull MaterialScope receiver, int shapeToken)

Retrieves the Corner shape from the default Material theme with shape token name.

static final boolean

Returns whether the dynamic colors theme (colors following the system theme) is enabled.

static final @NonNull LayoutElementBuilders.LayoutElement
materialScope(
    @NonNull Context context,
    @NonNull DeviceParametersBuilders.DeviceParameters deviceConfiguration,
    boolean allowDynamicTheme,
    @ExtensionFunctionType @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> layout
)

Creates a top-level receiver scope MaterialScope that calls the given layout to support for opinionated defaults and building Material3 components and layout.

Public methods

public static final @NonNull ColorBuilders.ColorProp getColorProp(@NonNull MaterialScope receiver, int colorToken)

Retrieves the ColorProp from the customized or default Material theme or dynamic system theme with the given color token name.

Throws
kotlin.IllegalArgumentException

if the token name is not recognized as one of the constants in ColorTokens

public static final @NonNull ModifiersBuilders.Corner getCorner(@NonNull MaterialScope receiver, int shapeToken)

Retrieves the Corner shape from the default Material theme with shape token name.

Throws
kotlin.IllegalArgumentException

if the token name is not recognized as one of the constants in Shape

public static final boolean isDynamicThemeEnabled(@NonNull Context context)

Returns whether the dynamic colors theme (colors following the system theme) is enabled.

If enabled, and elements or MaterialScope are opted in to using dynamic theme, colors will change whenever system theme changes.

public static final @NonNull LayoutElementBuilders.LayoutElement materialScope(
    @NonNull Context context,
    @NonNull DeviceParametersBuilders.DeviceParameters deviceConfiguration,
    boolean allowDynamicTheme,
    @ExtensionFunctionType @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> layout
)

Creates a top-level receiver scope MaterialScope that calls the given layout to support for opinionated defaults and building Material3 components and layout.

Parameters
@NonNull Context context

The Android Context for the Tile service

@NonNull DeviceParametersBuilders.DeviceParameters deviceConfiguration

The device parameters for where the components will be rendered

boolean allowDynamicTheme

If dynamic colors theme should be used on components, meaning that colors will follow the system theme if enabled on the device. If not set, defaults to using the system theme

@ExtensionFunctionType @NonNull Function1<@NonNull MaterialScope, @NonNull LayoutElementBuilders.LayoutElement> layout

Scoped slot for the content of layout to be displayed