rememberPlaceholderState
@ExperimentalWearMaterialApi
@Composable
public fun rememberPlaceholderState(isContentReady: () -> Boolean): PlaceholderState
Creates a PlaceholderState
that is remembered across compositions. To start placeholder
animations run PlaceholderState.startPlaceholderAnimation
.
A PlaceholderState
should be created for each component that has placeholder data. The state is
used to coordinate all of the different placeholder effects and animations.
Placeholder has a number of different effects designed to work together. Modifier.placeholder
draws a placeholder shape on top of content that is waiting to load. There can be multiple
placeholders in a component. Modifier.placeholderShimmer
does a shimmer animation over the
whole component that includes the placeholders. There should only be one placeholderShimmer for
each component.
Background placeholder effects are used to mask the background of components like chips and cards
until all of the data has loaded. Use PlaceholderDefaults.placeholderChipColors
PlaceholderDefaults.placeholderBackgroundBrush
and
PlaceholderDefaults.painterWithPlaceholderOverlayBackgroundBrush
to draw the component
background.
Once all of the components content is loaded, isContentReady
is true
the shimmer will stop
and a wipe off animation will remove the placeholders to reveal the content.
Parameters
isContentReady | a lambda to determine whether all of the data/content has been loaded for a given component and is ready to be displayed. |