Moves aspect ratio to the appropriate composable
This commit is contained in:
@@ -271,10 +271,6 @@ private fun UrlImageView(
|
|||||||
mutableStateOf<Boolean?>(null)
|
mutableStateOf<Boolean?>(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
val ratio = remember {
|
|
||||||
aspectRatio(content.dim)
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchedEffect(key1 = content.url, key2 = imageState) {
|
LaunchedEffect(key1 = content.url, key2 = imageState) {
|
||||||
if (imageState is AsyncImagePainter.State.Success) {
|
if (imageState is AsyncImagePainter.State.Success) {
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
@@ -284,10 +280,10 @@ private fun UrlImageView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
||||||
val myModifier = mainImageModifier.also {
|
val myModifier = mainImageModifier.run {
|
||||||
if (ratio != null) {
|
aspectRatio(content.dim)?.let { ratio ->
|
||||||
it.aspectRatio(ratio, maxHeight.isFinite)
|
this.aspectRatio(ratio, maxHeight.isFinite)
|
||||||
}
|
} ?: this
|
||||||
}
|
}
|
||||||
val contentScale = if (maxHeight.isFinite) ContentScale.Fit else ContentScale.FillWidth
|
val contentScale = if (maxHeight.isFinite) ContentScale.Fit else ContentScale.FillWidth
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user