DynamicColorSchemeKt

Added in 1.3.0-alpha05

public final class DynamicColorSchemeKt


Summary

Public methods

static final @NonNull ColorScheme
dynamicColorScheme(
    @NonNull Context context,
    @NonNull ColorScheme defaultColorScheme
)

Creates a dynamic color scheme.

static final boolean

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

Public methods

public static final @NonNull ColorScheme dynamicColorScheme(
    @NonNull Context context,
    @NonNull ColorScheme defaultColorScheme
)

Creates a dynamic color scheme.

Use this function to create a color scheme based on the current watchface. If the user changes the watchface colors, this color scheme will change accordingly. This function checks whether the dynamic color scheme can be used and returns defaultColorScheme otherwise.

Parameters
@NonNull Context context

The context required to get system resource data.

@NonNull ColorScheme defaultColorScheme

The fallback ColorScheme to return if the dynamic color scheme is switched off or unavailable on this device.

isDynamicColorSchemeEnabled

public static final boolean isDynamicColorSchemeEnabled(@NonNull Context context)

Returns whether the dynamic colors scheme (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.