mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-05 19:52:34 +02:00
Fix download and loading icon not showing when text overflow
This commit is contained in:
@@ -25,12 +25,14 @@ import androidx.compose.animation.AnimatedVisibility
|
|||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.text.InlineTextContent
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.text.appendInlineContent
|
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@@ -54,12 +56,11 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
import androidx.compose.ui.text.Placeholder
|
|
||||||
import androidx.compose.ui.text.PlaceholderVerticalAlign
|
|
||||||
import androidx.compose.ui.text.SpanStyle
|
import androidx.compose.ui.text.SpanStyle
|
||||||
import androidx.compose.ui.text.buildAnnotatedString
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.text.withStyle
|
import androidx.compose.ui.text.withStyle
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
import coil3.compose.AsyncImagePainter
|
import coil3.compose.AsyncImagePainter
|
||||||
@@ -87,7 +88,6 @@ import com.vitorpamplona.amethyst.ui.note.HashCheckFailedIcon
|
|||||||
import com.vitorpamplona.amethyst.ui.note.HashCheckIcon
|
import com.vitorpamplona.amethyst.ui.note.HashCheckIcon
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Font17SP
|
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size20dp
|
import com.vitorpamplona.amethyst.ui.theme.Size20dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size24dp
|
import com.vitorpamplona.amethyst.ui.theme.Size24dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size30dp
|
import com.vitorpamplona.amethyst.ui.theme.Size30dp
|
||||||
@@ -440,7 +440,6 @@ fun ImageUrlWithDownloadButton(
|
|||||||
|
|
||||||
withStyle(clickableTextStyle) {
|
withStyle(clickableTextStyle) {
|
||||||
pushStringAnnotation("routeToImage", "")
|
pushStringAnnotation("routeToImage", "")
|
||||||
appendInlineContent("inlineContent", "[icon]")
|
|
||||||
pop()
|
pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,8 +447,6 @@ fun ImageUrlWithDownloadButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val inlineContent = mapOf("inlineContent" to InlineDownloadIcon(showImage))
|
|
||||||
|
|
||||||
val pressIndicator =
|
val pressIndicator =
|
||||||
remember {
|
remember {
|
||||||
Modifier
|
Modifier
|
||||||
@@ -457,30 +454,31 @@ fun ImageUrlWithDownloadButton(
|
|||||||
.clickable { runCatching { uri.openUri(url) } }
|
.clickable { runCatching { uri.openUri(url) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
Row(
|
||||||
text = annotatedTermsString,
|
modifier =
|
||||||
modifier = pressIndicator,
|
Modifier
|
||||||
inlineContent = inlineContent,
|
.width(IntrinsicSize.Max),
|
||||||
maxLines = 1,
|
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||||
overflow = TextOverflow.Ellipsis,
|
) {
|
||||||
)
|
Text(
|
||||||
|
text = annotatedTermsString,
|
||||||
|
modifier =
|
||||||
|
pressIndicator
|
||||||
|
.weight(1f, fill = false),
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
|
InlineDownloadIcon(showImage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun InlineDownloadIcon(showImage: MutableState<Boolean>) =
|
private fun InlineDownloadIcon(showImage: MutableState<Boolean>) =
|
||||||
InlineTextContent(
|
IconButton(
|
||||||
Placeholder(
|
modifier = Modifier.size(Size20dp),
|
||||||
width = Font17SP,
|
onClick = { showImage.value = true },
|
||||||
height = Font17SP,
|
|
||||||
placeholderVerticalAlign = PlaceholderVerticalAlign.Center,
|
|
||||||
),
|
|
||||||
) {
|
) {
|
||||||
IconButton(
|
DownloadForOfflineIcon(Size24dp)
|
||||||
modifier = Modifier.size(Size20dp),
|
|
||||||
onClick = { showImage.value = true },
|
|
||||||
) {
|
|
||||||
DownloadForOfflineIcon(Size24dp)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -533,7 +531,6 @@ fun DisplayUrlWithLoadingSymbol(content: BaseMediaContent) {
|
|||||||
|
|
||||||
withStyle(clickableTextStyle) {
|
withStyle(clickableTextStyle) {
|
||||||
pushStringAnnotation("routeToImage", "")
|
pushStringAnnotation("routeToImage", "")
|
||||||
appendInlineContent("inlineContent", "[icon]")
|
|
||||||
pop()
|
pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,8 +538,6 @@ fun DisplayUrlWithLoadingSymbol(content: BaseMediaContent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val inlineContent = mapOf("inlineContent" to InlineLoadingIcon())
|
|
||||||
|
|
||||||
val pressIndicator =
|
val pressIndicator =
|
||||||
remember {
|
remember {
|
||||||
if (content is MediaUrlContent) {
|
if (content is MediaUrlContent) {
|
||||||
@@ -552,26 +547,26 @@ fun DisplayUrlWithLoadingSymbol(content: BaseMediaContent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
Row(
|
||||||
text = annotatedTermsString,
|
modifier =
|
||||||
modifier = pressIndicator,
|
Modifier
|
||||||
inlineContent = inlineContent,
|
.width(IntrinsicSize.Max),
|
||||||
overflow = TextOverflow.Ellipsis,
|
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||||
maxLines = 1,
|
) {
|
||||||
)
|
Text(
|
||||||
|
text = annotatedTermsString,
|
||||||
|
modifier =
|
||||||
|
pressIndicator
|
||||||
|
.weight(1f, fill = false),
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
|
InlineLoadingIcon()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun InlineLoadingIcon() =
|
private fun InlineLoadingIcon() = LoadingAnimation()
|
||||||
InlineTextContent(
|
|
||||||
Placeholder(
|
|
||||||
width = Font17SP,
|
|
||||||
height = Font17SP,
|
|
||||||
placeholderVerticalAlign = PlaceholderVerticalAlign.Center,
|
|
||||||
),
|
|
||||||
) {
|
|
||||||
LoadingAnimation()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DisplayBlurHash(
|
fun DisplayBlurHash(
|
||||||
|
Reference in New Issue
Block a user