Coil v2.0.0-alpha04 Release Notes
Release Date: 2021-11-22 // over 2 years ago-
- 🆕 New: Add
AsyncImage
tocoil-compose
.AsyncImage
is a composable that executes anImageRequest
asynchronously and renders the result.AsyncImage
is intended to replacerememberImagePainter
for most use cases.- Its API is not final and may change before the final 2.0 release.
- It has a similar API to
Image
and supports the same arguments:Alignment
,ContentScale
,alpha
,ColorFilter
, andFilterQuality
. - It supports overwriting what's drawn for each
AsyncImagePainter
state using thecontent
,loading
,success
, anderror
arguments. - It fixes a number of design issues that
rememberImagePainter
has with resolving image size and scale. - Example usages:
// Only draw the image. AsyncImage( model = "https://example.com/image.jpg", contentDescription = null // Avoid `null` and set this to a localized string if possible. ) // Draw the image with a circle crop, crossfade, and overwrite the `loading` state. AsyncImage( model = ImageRequest.Builder(LocalContext.current) .data("https://example.com/image.jpg") .crossfade(true) .build(), contentDescription = null, modifier = Modifier .clip(CircleShape), loading = { CircularProgressIndicator() }, contentScale = ContentScale.Crop ) // Draw the image with a circle crop, crossfade, and overwrite all states. AsyncImage( model = ImageRequest.Builder(LocalContext.current) .data("https://example.com/image.jpg") .crossfade(true) .build(), contentDescription = null, modifier = Modifier .clip(CircleShape), contentScale = ContentScale.Crop ) { state -> if (state is AsyncImagePainter.State.Loading) { CircularProgressIndicator() } else { AsyncImageContent() // Draws the image. } }
- Important: Rename
ImagePainter
toAsyncImagePainter
andrememberImagePainter
torememberAsyncImagePainter
.ExecuteCallback
is no longer supported. To have theAsyncImagePainter
skip waiting foronDraw
to be called, setImageRequest.size(OriginalSize)
(or any size) instead.- Add an optional
FilterQuality
argument torememberAsyncImagePainter
.
- 🏗 Use coroutines for cleanup operations in
DiskCache
and addDiskCache.Builder.cleanupDispatcher
. - 🛠 Fix Compose preview for placeholder set using
ImageLoader.Builder.placeholder
. - Mark
LocalImageLoader.current
with@ReadOnlyComposable
to generate more efficient code. - ⚡️ Update Compose to 1.1.0-beta03 and depend on
compose.foundation
instead ofcompose.ui
. - ⚡️ Update
androidx.appcompat-resources
to 1.4.0.
- 🆕 New: Add