Skip to content

Commit

Permalink
Fix image height in landscape mode. Fixes #122 (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines authored Mar 13, 2022
1 parent 3227d9b commit 773964f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/src/main/java/com/jerboa/ui/components/common/PictrsImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import coil.annotation.ExperimentalCoilApi
import coil.compose.rememberImagePainter
import coil.size.OriginalSize
Expand Down Expand Up @@ -94,6 +96,9 @@ fun PictrsUrlImage(
url: String,
modifier: Modifier = Modifier
) {
val configuration = LocalConfiguration.current
val screenHeight = (configuration.screenHeightDp - 150).dp

Image(
painter = rememberImagePainter(
data = pictrsImageThumbnail(url, MAX_IMAGE_SIZE),
Expand All @@ -104,9 +109,11 @@ fun PictrsUrlImage(
transformations(RoundedCornersTransformation(12f))
},
),
contentScale = ContentScale.FillWidth,
contentScale = ContentScale.Fit,
contentDescription = null,
modifier = modifier,
modifier = modifier
.fillMaxWidth()
.heightIn(0.dp, screenHeight)
)
}

Expand Down

0 comments on commit 773964f

Please sign in to comment.