AsyncPicPalette
A data class returned via onPaletteLoaded containing extracted color swatches from the loaded image.
data class AsyncPicPalette(
val vibrant: Color?,
val dominant: Color?,
val muted: Color?,
val lightVibrant: Color?,
val darkVibrant: Color?
)
All fields are nullable — complex images may not produce every swatch.
Fields​
| Field | Description | Best used for |
|---|---|---|
vibrant | Most vivid, saturated color | Buttons, highlights, accents |
dominant | Most frequently occurring color | Backgrounds, containers |
muted | Desaturated version of vibrant | Subtle backgrounds |
lightVibrant | Light, saturated swatch | Text on dark backgrounds |
darkVibrant | Dark, saturated swatch | Text color, dark containers |
Usage​
AsyncPic(
source = ImageSource.Url("https://example.com/photo.jpg"),
modifier = Modifier.size(200.dp),
onPaletteLoaded = { palette ->
// Safely unwrap — any swatch may be null
val accent = palette.vibrant ?: palette.dominant ?: Color.Gray
val bg = palette.darkVibrant ?: Color(0xFF1E293B)
}
)
Internal Use​
AsyncPic uses AsyncPicPalette internally to drive the Adaptive Shimmer Morph feature. Before calling onPaletteLoaded, it updates the shimmer's activeShimmerColor with this priority:
vibrantSwatchlightVibrantSwatchdominantSwatch
This means even if you don't pass onPaletteLoaded, you still get the color morphing effect automatically.