coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.79k stars 660 forks source link

AsyncImage fills the screen if one dimension is not specified and the image is not resolved #2349

Closed ParsleyJ closed 1 week ago

ParsleyJ commented 4 months ago

Describe the bug The AsyncImage composable takes up all the possible space when the image (provided via URL) is not resolved.

To Reproduce In the following snippet, the rendered screen should contain just a red box. Instead nothing is displayed, as the empty AsyncImage takes up the full height of the screen, pushing the box to the bottom, outside the screen.

@Composable
fun TestScreen() {
    Column(Modifier.fillMaxSize()) {

        AsyncImage(
            modifier = Modifier.fillMaxWidth(.5f),
            model = "https://inexistent.url/missingImage.png",
            contentDescription = "Test image",
            contentScale = ContentScale.FillWidth
        )

        Box(Modifier.background(color = Color.Red).size(50.dp))

    }
}

Version kt-coil, coil-compose 2.6.0

RobertTadevosyan commented 2 months ago

@ParsleyJ the expected result is that the async image would have a 0 height ?

ParsleyJ commented 2 months ago

@RobertTadevosyan

Yes