Fixes tall images bleeding into other posts.
This commit is contained in:
@@ -13,6 +13,7 @@ import androidx.compose.foundation.clickable
|
|||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.combinedClickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
@@ -57,6 +58,7 @@ import androidx.compose.ui.text.PlaceholderVerticalAlign
|
|||||||
import androidx.compose.ui.text.buildAnnotatedString
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
import androidx.compose.ui.text.withStyle
|
import androidx.compose.ui.text.withStyle
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.isFinite
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
@@ -173,11 +175,6 @@ fun ZoomableContentView(content: ZoomableContent, images: List<ZoomableContent>
|
|||||||
RoundedCornerShape(15.dp)
|
RoundedCornerShape(15.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
val ratio = aspectRatio(content.dim)
|
|
||||||
if (ratio != null) {
|
|
||||||
mainImageModifier = mainImageModifier.aspectRatio(ratio)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content is ZoomableUrlContent) {
|
if (content is ZoomableUrlContent) {
|
||||||
mainImageModifier = mainImageModifier.combinedClickable(
|
mainImageModifier = mainImageModifier.combinedClickable(
|
||||||
onClick = { dialogOpen = true },
|
onClick = { dialogOpen = true },
|
||||||
@@ -216,13 +213,22 @@ private fun LocalImageView(
|
|||||||
mutableStateOf<AsyncImagePainter.State?>(null)
|
mutableStateOf<AsyncImagePainter.State?>(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(contentAlignment = Alignment.Center) {
|
val ratio = aspectRatio(content.dim)
|
||||||
|
|
||||||
|
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
||||||
|
val myModifier = mainImageModifier.also {
|
||||||
|
if (ratio != null) {
|
||||||
|
it.aspectRatio(ratio, maxHeight.isFinite)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val contentScale = if (maxHeight.isFinite) ContentScale.Fit else ContentScale.FillWidth
|
||||||
|
|
||||||
if (content.localFile.exists()) {
|
if (content.localFile.exists()) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = content.localFile,
|
model = content.localFile,
|
||||||
contentDescription = content.description,
|
contentDescription = content.description,
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = contentScale,
|
||||||
modifier = mainImageModifier,
|
modifier = myModifier,
|
||||||
onLoading = {
|
onLoading = {
|
||||||
imageState = it
|
imageState = it
|
||||||
},
|
},
|
||||||
@@ -241,7 +247,7 @@ private fun LocalImageView(
|
|||||||
exit = fadeOut(animationSpec = tween(200))
|
exit = fadeOut(animationSpec = tween(200))
|
||||||
) {
|
) {
|
||||||
if (content.blurhash != null) {
|
if (content.blurhash != null) {
|
||||||
DisplayBlurHash(content.blurhash, content.description, mainImageModifier)
|
DisplayBlurHash(content.blurhash, content.description, contentScale, myModifier)
|
||||||
} else {
|
} else {
|
||||||
FlowRow() {
|
FlowRow() {
|
||||||
DisplayUrlWithLoadingSymbol(content)
|
DisplayUrlWithLoadingSymbol(content)
|
||||||
@@ -272,6 +278,8 @@ private fun UrlImageView(
|
|||||||
mutableStateOf<Boolean?>(null)
|
mutableStateOf<Boolean?>(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val ratio = 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) {
|
||||||
@@ -280,12 +288,19 @@ private fun UrlImageView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(contentAlignment = Alignment.Center) {
|
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
||||||
|
val myModifier = mainImageModifier.also {
|
||||||
|
if (ratio != null) {
|
||||||
|
it.aspectRatio(ratio, maxHeight.isFinite)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val contentScale = if (maxHeight.isFinite) ContentScale.Fit else ContentScale.FillWidth
|
||||||
|
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = content.url,
|
model = content.url,
|
||||||
contentDescription = content.description,
|
contentDescription = content.description,
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = contentScale,
|
||||||
modifier = mainImageModifier,
|
modifier = myModifier,
|
||||||
onLoading = {
|
onLoading = {
|
||||||
imageState = it
|
imageState = it
|
||||||
},
|
},
|
||||||
@@ -303,7 +318,7 @@ private fun UrlImageView(
|
|||||||
exit = fadeOut(animationSpec = tween(200))
|
exit = fadeOut(animationSpec = tween(200))
|
||||||
) {
|
) {
|
||||||
if (content.blurhash != null) {
|
if (content.blurhash != null) {
|
||||||
DisplayBlurHash(content.blurhash, content.description, mainImageModifier)
|
DisplayBlurHash(content.blurhash, content.description, contentScale, myModifier)
|
||||||
} else {
|
} else {
|
||||||
FlowRow() {
|
FlowRow() {
|
||||||
DisplayUrlWithLoadingSymbol(content)
|
DisplayUrlWithLoadingSymbol(content)
|
||||||
@@ -389,6 +404,7 @@ private fun DisplayUrlWithLoadingSymbolWait(content: ZoomableContent) {
|
|||||||
private fun DisplayBlurHash(
|
private fun DisplayBlurHash(
|
||||||
blurhash: String?,
|
blurhash: String?,
|
||||||
description: String?,
|
description: String?,
|
||||||
|
contentScale: ContentScale,
|
||||||
modifier: Modifier
|
modifier: Modifier
|
||||||
) {
|
) {
|
||||||
if (blurhash == null) return
|
if (blurhash == null) return
|
||||||
@@ -400,7 +416,7 @@ private fun DisplayBlurHash(
|
|||||||
blurhash
|
blurhash
|
||||||
),
|
),
|
||||||
contentDescription = description,
|
contentDescription = description,
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = contentScale,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ private fun RenderVideoOrPictureNote(
|
|||||||
var moreActionsExpanded by remember { mutableStateOf(false) }
|
var moreActionsExpanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Column(Modifier.fillMaxSize(1f)) {
|
Column(Modifier.fillMaxSize(1f)) {
|
||||||
Row(Modifier.weight(1f, true), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {
|
||||||
if (noteEvent is FileHeaderEvent) {
|
if (noteEvent is FileHeaderEvent) {
|
||||||
FileHeaderDisplay(note)
|
FileHeaderDisplay(note)
|
||||||
} else if (noteEvent is FileStorageHeaderEvent) {
|
} else if (noteEvent is FileStorageHeaderEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user