chanjungskim
03/03/2023, 1:28 AMfun GifImage(
@DrawableRes resId: Int,
contentDescription: String,
modifier: Modifier = Modifier,
) {
val imageLoader = ImageLoader.Builder(LocalContext.current)
.components {
if (SDK_INT >= 28) {
add(ImageDecoderDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
}.build()
Image(
painter = rememberAsyncImagePainter(resId, imageLoader),
contentDescription = contentDescription,
modifier = modifier
)
}
Colin White
03/03/2023, 3:22 AMplaceholder
element in preview since the preview environment is a bit special. IIRC certain decoders won’t work inside previewColin White
03/03/2023, 3:24 AMremember
the ImageLoader
so it’s not recreated on each compositionStylianos Gakis
10/20/2023, 3:38 PMclass PreviewImageLoader(private val drawable: Drawable) : ImageLoader {...
to your previews to do something like render all the preview images with a filled red color or something like that, just to know a but better what the final UI will look like before running the app?