Avoids null model errors that might be delaying some of the rendering.

This commit is contained in:
Vitor Pamplona
2023-08-02 13:29:44 -04:00
parent 6cbee81e72
commit 579465ac6c
@@ -1,5 +1,6 @@
package com.vitorpamplona.amethyst.ui.components package com.vitorpamplona.amethyst.ui.components
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@@ -64,19 +65,30 @@ fun RobohashFallbackAsyncImage(
model = Robohash.imageRequest(context, robot) model = Robohash.imageRequest(context, robot)
) )
AsyncImage( if (model != null) {
model = model, AsyncImage(
contentDescription = contentDescription, model = model,
modifier = modifier, contentDescription = contentDescription,
placeholder = painter, modifier = modifier,
fallback = painter, placeholder = painter,
error = painter, fallback = painter,
alignment = alignment, error = painter,
contentScale = contentScale, alignment = alignment,
alpha = alpha, contentScale = contentScale,
colorFilter = colorFilter, alpha = alpha,
filterQuality = filterQuality colorFilter = colorFilter,
) filterQuality = filterQuality
)
} else {
Image(
painter = painter,
contentDescription = contentDescription,
modifier = modifier,
alignment = alignment,
contentScale = contentScale,
colorFilter = colorFilter
)
}
} }
@Composable @Composable