val image = remember { --- } ////// 1
Image(
painter = image,
contentDescription = null
)
Button(onClick = {
lifecycleScope.launch {
val user = api.auth(AuthRequest(username, password))
val request = ImageRequest.Builder(context)
.data(user.image)
.build()
context.imageLoader.execute(request).drawable ///// 2
})
val bitmap = ImageBitmap.imageResource(id = R.drawable.pikcha)
var image by remember { mutableStateOf(bitmap) }
Image(
bitmap = image,
contentDescription = null
)
Button(
onClick = {
lifecycleScope.launch(Dispatchers.IO) {
val user = api.auth(AuthRequest(username, password))
val request = ImageRequest.Builder(context)
.data(user.image)
.build()
val drawable = context.imageLoader.execute(request).drawable
image = (drawable as BitmapDrawable).bitmap.asImageBitmap()
}
}
)