mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-23 20:44:01 +02:00
Shows url host in the link preview
This commit is contained in:
@@ -34,12 +34,18 @@ fun UrlPreviewCard(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable { runCatching { uri.openUri(url) } }
|
.clickable { runCatching { uri.openUri(url) } }
|
||||||
.clip(shape = RoundedCornerShape(15.dp))
|
.clip(shape = RoundedCornerShape(15.dp))
|
||||||
.border(1.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.12f), RoundedCornerShape(15.dp))
|
.border(
|
||||||
|
1.dp,
|
||||||
|
MaterialTheme.colors.onSurface.copy(alpha = 0.12f),
|
||||||
|
RoundedCornerShape(15.dp)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
|
val url = URL(previewInfo.url)
|
||||||
|
|
||||||
// correctly treating relative images
|
// correctly treating relative images
|
||||||
val imageUrl = if (previewInfo.image.startsWith("/")) {
|
val imageUrl = if (previewInfo.image.startsWith("/")) {
|
||||||
URL(URL(previewInfo.url), previewInfo.image).toString()
|
URL(url, previewInfo.image).toString()
|
||||||
} else {
|
} else {
|
||||||
previewInfo.image
|
previewInfo.image
|
||||||
}
|
}
|
||||||
@@ -51,12 +57,23 @@ fun UrlPreviewCard(
|
|||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = url.host,
|
||||||
|
style = MaterialTheme.typography.caption,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(start = 10.dp, end = 10.dp, top = 10.dp),
|
||||||
|
color = Color.Gray,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis
|
||||||
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = previewInfo.title,
|
text = previewInfo.title,
|
||||||
style = MaterialTheme.typography.body2,
|
style = MaterialTheme.typography.body2,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(start = 10.dp, end = 10.dp, top = 10.dp),
|
.padding(start = 10.dp, end = 10.dp),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user