Fix text overflow
`maxLines = 1` should always be used with `softWrap = false` or `overflow = Ellipsis`
This commit is contained in:
1 parent
842e59e893
commit
15e63eb86c
3 files changed
+11
-8
No files matched your search
@@ -30,6 +30,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.client.EhUtils
|
||||
@@ -111,7 +112,7 @@ fun GalleryDetailHeaderCard(
|
||||
val categoryText = EhUtils.getCategory(info.category).uppercase()
|
||||
AssistChip(
|
||||
onClick = onCategoryChipClick,
|
||||
label = { Text(text = categoryText, maxLines = 1) },
|
||||
label = { Text(text = categoryText, overflow = TextOverflow.Visible, softWrap = false, maxLines = 1) },
|
||||
modifier = Modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin)),
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
@@ -123,7 +124,7 @@ fun GalleryDetailHeaderCard(
|
||||
val uploaderText = info.uploader.orEmpty()
|
||||
AssistChip(
|
||||
onClick = onUploaderChipClick,
|
||||
label = { Text(text = uploaderText, maxLines = 1) },
|
||||
label = { Text(text = uploaderText, overflow = TextOverflow.Visible, softWrap = false, maxLines = 1) },
|
||||
modifier = Modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin)),
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
|
||||
@@ -52,6 +52,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.layout.LocalPinnableContainer
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.viewModelScope
|
||||
@@ -289,13 +290,13 @@ fun GalleryDetailContent(
|
||||
onClick = ::onDownloadButtonClick,
|
||||
modifier = Modifier.padding(horizontal = 4.dp).weight(1F),
|
||||
) {
|
||||
Text(text = downloadButtonText, maxLines = 1)
|
||||
Text(text = downloadButtonText, overflow = TextOverflow.Ellipsis, maxLines = 1)
|
||||
}
|
||||
Button(
|
||||
onClick = ::onReadButtonClick,
|
||||
modifier = Modifier.padding(horizontal = 4.dp).weight(1F),
|
||||
) {
|
||||
Text(text = readButtonText, maxLines = 1)
|
||||
Text(text = readButtonText, overflow = TextOverflow.Ellipsis, maxLines = 1)
|
||||
}
|
||||
}
|
||||
if (getDetailError.isNotBlank()) {
|
||||
@@ -347,14 +348,14 @@ fun GalleryDetailContent(
|
||||
onClick = ::onReadButtonClick,
|
||||
modifier = Modifier.height(56.dp).padding(horizontal = 16.dp).width(192.dp),
|
||||
) {
|
||||
Text(text = readButtonText, maxLines = 1)
|
||||
Text(text = readButtonText, overflow = TextOverflow.Ellipsis, maxLines = 1)
|
||||
}
|
||||
Spacer(modifier = modifier.height(24.dp))
|
||||
FilledTonalButton(
|
||||
onClick = ::onDownloadButtonClick,
|
||||
modifier = Modifier.height(56.dp).padding(horizontal = 16.dp).width(192.dp),
|
||||
) {
|
||||
Text(text = downloadButtonText, maxLines = 1)
|
||||
Text(text = downloadButtonText, overflow = TextOverflow.Ellipsis, maxLines = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ suspend fun awaitSelectTags(): List<String> = dialog { cont ->
|
||||
InputChip(
|
||||
selected = true,
|
||||
onClick = { },
|
||||
label = { Text(text = text) },
|
||||
label = { Text(text = text, overflow = TextOverflow.Ellipsis, maxLines = 1) },
|
||||
trailingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Close,
|
||||
@@ -273,11 +273,12 @@ suspend fun awaitSelectTags(): List<String> = dialog { cont ->
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Column {
|
||||
Text(text = tag, maxLines = 1)
|
||||
Text(text = tag, overflow = TextOverflow.Ellipsis, maxLines = 2)
|
||||
ProvideTextStyle(MaterialTheme.typography.bodySmall) {
|
||||
if (hint != null) {
|
||||
Text(
|
||||
text = hint,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user