Loading an image from a web URL and displaying a shimmer during load. Are there any better ways to handle this?
val context = LocalContext.current
val imageLoader = ImageLoader(context)
val request = ImageRequest.Builder(context)
.data(thumbnailUrl)
.build()
val painter = rememberImagePainter(
request = request,
imageLoader = imageLoader
)
val state = painter.state
Image(
painter = painter,
contentDescription = "thumbnail image",
modifier = Modifier
.fillMaxSize()
.placeholder(
visible = state is
ImagePainter.State.Loading,
color = PlaceholderDefaults.color(
backgroundColor = MyTheme.colors.shimmer.copy(0.1f),
),
highlight = PlaceholderHighlight.shimmer(),
),
contentScale = ContentScale.Crop
)
How would you add a token to this request? I tried setting the header with a token but no response. Any suggestions?
Modifier.placeholder
is not a system modifier, where does it come from? Why are you looking for a better solution, doesn't it work for you? – VachillModifier.placeholder
is probably coming out from Accompanist Placeholder library. – Viburnum