fix: images always being full-width
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
88faa795ba
commit
89cc41b414
|
|
@ -4,6 +4,7 @@ import android.text.format.Formatter
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
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.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
|
@ -75,26 +76,32 @@ fun FileAttachment(attachment: AutumnResource) {
|
||||||
fun ImageAttachment(attachment: AutumnResource) {
|
fun ImageAttachment(attachment: AutumnResource) {
|
||||||
val url = "$REVOLT_FILES/attachments/${attachment.id}/${attachment.filename}"
|
val url = "$REVOLT_FILES/attachments/${attachment.id}/${attachment.filename}"
|
||||||
|
|
||||||
|
BoxWithConstraints {
|
||||||
RemoteImage(
|
RemoteImage(
|
||||||
url = url,
|
url = url,
|
||||||
contentScale = ContentScale.Fit,
|
contentScale = ContentScale.Fit,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.width(attachment.metadata?.width?.toInt()?.dp ?: maxWidth)
|
||||||
.aspectRatio(
|
.aspectRatio(
|
||||||
attachment.metadata!!.width!!.toFloat() / attachment.metadata.height!!.toFloat()
|
attachment.metadata!!.width!!.toFloat() / attachment.metadata.height!!.toFloat()
|
||||||
),
|
),
|
||||||
description = attachment.filename ?: "Image"
|
description = attachment.filename ?: "Image"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun VideoAttachment(attachment: AutumnResource) {
|
fun VideoAttachment(attachment: AutumnResource) {
|
||||||
val url = "$REVOLT_FILES/attachments/${attachment.id}/${attachment.filename}"
|
val url = "$REVOLT_FILES/attachments/${attachment.id}/${attachment.filename}"
|
||||||
|
|
||||||
|
BoxWithConstraints {
|
||||||
Box(
|
Box(
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.width(attachment.metadata?.width?.toInt()?.dp ?: maxWidth)
|
||||||
|
.aspectRatio(
|
||||||
|
attachment.metadata!!.width!!.toFloat() / attachment.metadata.height!!.toFloat()
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
// Turns out that when you give Glide a video URL, you get a perfectly cromulent thumbnail.
|
// Turns out that when you give Glide a video URL, you get a perfectly cromulent thumbnail.
|
||||||
RemoteImage(
|
RemoteImage(
|
||||||
|
|
@ -103,7 +110,7 @@ fun VideoAttachment(attachment: AutumnResource) {
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.aspectRatio(
|
.aspectRatio(
|
||||||
attachment.metadata!!.width!!.toFloat() / attachment.metadata.height!!.toFloat()
|
attachment.metadata.width!!.toFloat() / attachment.metadata.height.toFloat()
|
||||||
),
|
),
|
||||||
description = attachment.filename ?: "Video"
|
description = attachment.filename ?: "Video"
|
||||||
)
|
)
|
||||||
|
|
@ -125,6 +132,7 @@ fun VideoAttachment(attachment: AutumnResource) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AudioAttachment(attachment: AutumnResource) {
|
fun AudioAttachment(attachment: AutumnResource) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue