fix load image box size

This commit is contained in:
greenart7c3
2023-07-07 07:29:48 -03:00
parent 66952c9212
commit 0fead83279

View File

@@ -313,7 +313,8 @@ private fun UrlImageView(
fun LoadImageBox(showImage: MutableState<Boolean>) { fun LoadImageBox(showImage: MutableState<Boolean>) {
Box( Box(
modifier = Modifier modifier = Modifier
.size(300.dp) .height(300.dp)
.fillMaxWidth()
.clip(RoundedCornerShape(10.dp)) .clip(RoundedCornerShape(10.dp))
.background(Color.LightGray) .background(Color.LightGray)
.clickable { showImage.value = true }, .clickable { showImage.value = true },
@@ -337,31 +338,31 @@ private fun AddedImageFeatures(
showImage: MutableState<Boolean> showImage: MutableState<Boolean>
) { ) {
if (!showImage.value) { if (!showImage.value) {
return LoadImageBox(showImage) LoadImageBox(showImage)
} } else {
when (painter.value) {
when (painter.value) { null, is AsyncImagePainter.State.Loading -> {
null, is AsyncImagePainter.State.Loading -> { if (content.blurhash != null) {
if (content.blurhash != null) { DisplayBlurHash(content.blurhash, content.description, contentScale, myModifier)
DisplayBlurHash(content.blurhash, content.description, contentScale, myModifier) } else {
} else { FlowRow() {
FlowRow() { DisplayUrlWithLoadingSymbol(content)
DisplayUrlWithLoadingSymbol(content) }
} }
} }
}
is AsyncImagePainter.State.Error -> { is AsyncImagePainter.State.Error -> {
BlankNote() BlankNote()
}
is AsyncImagePainter.State.Success -> {
if (content.isVerified != null) {
HashVerificationSymbol(content.isVerified, verifiedModifier)
} }
}
else -> { is AsyncImagePainter.State.Success -> {
if (content.isVerified != null) {
HashVerificationSymbol(content.isVerified, verifiedModifier)
}
}
else -> {
}
} }
} }
} }
@@ -377,47 +378,47 @@ private fun AddedImageFeatures(
showImage: MutableState<Boolean> showImage: MutableState<Boolean>
) { ) {
if (!showImage.value) { if (!showImage.value) {
return LoadImageBox(showImage) LoadImageBox(showImage)
} } else {
var verifiedHash by remember {
var verifiedHash by remember { mutableStateOf<Boolean?>(null)
mutableStateOf<Boolean?>(null)
}
when (painter.value) {
null, is AsyncImagePainter.State.Loading -> {
if (content.blurhash != null) {
DisplayBlurHash(content.blurhash, content.description, contentScale, myModifier)
} else {
FlowRow() {
DisplayUrlWithLoadingSymbol(content)
}
}
} }
is AsyncImagePainter.State.Error -> { when (painter.value) {
ClickableUrl(urlText = "${content.url} ", url = content.url) null, is AsyncImagePainter.State.Loading -> {
} if (content.blurhash != null) {
DisplayBlurHash(content.blurhash, content.description, contentScale, myModifier)
is AsyncImagePainter.State.Success -> { } else {
if (content.hash != null) { FlowRow() {
val context = LocalContext.current DisplayUrlWithLoadingSymbol(content)
LaunchedEffect(key1 = content.url) {
launch(Dispatchers.IO) {
val newVerifiedHash = verifyHash(content, context)
if (newVerifiedHash != verifiedHash) {
verifiedHash = newVerifiedHash
}
} }
} }
} }
verifiedHash?.let { is AsyncImagePainter.State.Error -> {
HashVerificationSymbol(it, verifiedModifier) ClickableUrl(urlText = "${content.url} ", url = content.url)
} }
}
else -> { is AsyncImagePainter.State.Success -> {
if (content.hash != null) {
val context = LocalContext.current
LaunchedEffect(key1 = content.url) {
launch(Dispatchers.IO) {
val newVerifiedHash = verifyHash(content, context)
if (newVerifiedHash != verifiedHash) {
verifiedHash = newVerifiedHash
}
}
}
}
verifiedHash?.let {
HashVerificationSymbol(it, verifiedModifier)
}
}
else -> {
}
} }
} }
} }