Artur Schwarz
07/12/2021, 5:50 PMAndrey Kulikov
07/12/2021, 7:18 PMArtur Schwarz
07/12/2021, 7:23 PMprivate fun ImagePreview(
image: File,
onImageClick: (File) -> Unit
) {
val onClick = { onImageClick.invoke(image) }
Card(
modifier = Modifier
.clickable { onClick.invoke() }
.fillMaxWidth()
.padding(16.dp)
) {
Image(
modifier = Modifier.clickable { onClick.invoke() },
painter = rememberCoilPainter(image),
contentDescription = ""
)
}
}
Andrey Kulikov
07/12/2021, 7:29 PMArtur Schwarz
07/12/2021, 7:29 PMAndrey Kulikov
07/12/2021, 7:33 PMrememberCoilPainter()
it is recommended to predefine the size of the component with some meaningful width and height so it doesn’t jump when you load the images. it is even more important for images inside LazyColumn/LazyRow as there the item sizes are used in order to calculate the amount of needed items. or if you just use the local images from resources use painterResource()Artur Schwarz
07/12/2021, 7:39 PMAndrey Kulikov
07/12/2021, 7:41 PMArtur Schwarz
07/12/2021, 7:42 PM