AiutaAdaptiveImage

fun AiutaAdaptiveImage(model: Any?, contentDescription: String?, shapeDp: Dp? = null, modifier: Modifier = Modifier, alignment: Alignment = Alignment.Center, aspectThreshold: Float = ADAPTIVE_ASPECT_THRESHOLD, onContentRectChanged: (Rect) -> Unit? = null)

Displays an image adaptively depending on its aspect ratio:

  • aspectRatio >= aspectThresholdContentScale.Crop, the image fills the container without side gaps (cover).

  • aspectRatio <aspectThresholdContentScale.Fit (the whole subject stays visible), with the empty side areas filled by a blurred, slightly scaled, color-graded copy of the same image (contain + blurred background).

The foreground is loaded at the view size via rememberConstraintsSizeResolver (instead of Size.ORIGINAL), so large source images aren't decoded at full resolution. The cover / contain decision is driven by a separate probe painter decoded at a fixed size, so the same image yields the same aspect ratio (and thus the same mode) on every device, independent of container size.

The blur is produced by decoding a tiny copy of the same image via Coil and upscaling it, then (where supported) a real Modifier.blur on top — blur is a no-op below Android API 31, so the downsample alone provides the softening there.

Parameters

model

The Coil model to load — a URL String or raw image ByteArray.

shapeDp

The corner radius used to clip the container (and the shimmer placeholder).

contentDescription

The content description for accessibility.

modifier

The modifier applied to the root container. Callers should put sizing and any container-level modifiers (e.g. hazeSource, onGloballyPositioned, click) here.

alignment

The alignment of the image within its bounds.

aspectThreshold

The width/height boundary between cover and contain+blur.

onContentRectChanged

Optional callback reporting the rect (in root coordinates) actually occupied by the painted image. In cover mode this equals the container; in contain mode it is the Fit-letterboxed sub-rect, so callers (e.g. shared-element zoom) animate from the real image bounds instead of the whole view.