From 77cd5ca872bc87ef0a65fc30ff5611757c49de93 Mon Sep 17 00:00:00 2001 From: Ash Date: Wed, 30 Mar 2022 00:56:41 +0800 Subject: [PATCH] Fix some text overflow style --- .../ash/reader/ui/page/home/feeds/FeedItem.kt | 36 +++++++++++-------- .../reader/ui/page/home/feeds/FeedsPage.kt | 3 ++ .../reader/ui/page/home/feeds/GroupItem.kt | 3 ++ .../reader/ui/page/home/flow/ArticleItem.kt | 5 ++- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt index d7d5dd9..c489c70 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedItem.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.LocalView +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import me.ash.reader.data.feed.Feed @@ -52,36 +53,41 @@ fun FeedItem( .padding(vertical = 14.dp), ) { Row( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .padding(start = 14.dp, end = 6.dp), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, ) { - Row(modifier = Modifier.padding(start = 14.dp)) { + Row(modifier = Modifier.weight(1f)) { Row( modifier = Modifier .size(20.dp) .clip(CircleShape) .background(MaterialTheme.colorScheme.outline), ) {} - Spacer(modifier = Modifier.width(12.dp)) Text( + modifier = Modifier.padding(start = 12.dp, end = 6.dp), text = feed.name, style = MaterialTheme.typography.labelLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant + color = MaterialTheme.colorScheme.onSurfaceVariant, + maxLines = 1, + overflow = TextOverflow.Ellipsis, ) } if (feed.important ?: 0 != 0) { - Badge( - modifier = Modifier.padding(end = 6.dp), - containerColor = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.24f), - contentColor = MaterialTheme.colorScheme.outline, - content = { - Text( - text = feed.important.toString(), - style = MaterialTheme.typography.labelSmall - ) - }, - ) + Row() { + Badge( + containerColor = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.24f), + contentColor = MaterialTheme.colorScheme.outline, + content = { + Text( + text = feed.important.toString(), + style = MaterialTheme.typography.labelSmall + ) + }, + ) + } } } } diff --git a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt index 10e987f..61b350b 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/FeedsPage.kt @@ -19,6 +19,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavHostController @@ -127,6 +128,8 @@ fun FeedsPage( text = viewState.account?.name ?: stringResource(R.string.unknown), style = MaterialTheme.typography.displaySmall, color = MaterialTheme.colorScheme.onSurface, + maxLines = 1, + overflow = TextOverflow.Ellipsis, ) } item { diff --git a/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt b/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt index e43a0bf..aaeb5a8 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/feeds/GroupItem.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import me.ash.reader.R import me.ash.reader.data.feed.Feed @@ -60,6 +61,8 @@ fun GroupItem( text = text, style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.onSecondaryContainer, + maxLines = 1, + overflow = TextOverflow.Ellipsis, ) Row( modifier = Modifier diff --git a/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleItem.kt b/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleItem.kt index a778ecc..cf442fc 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleItem.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleItem.kt @@ -40,12 +40,15 @@ fun ArticleItem( verticalAlignment = Alignment.CenterVertically, ) { Text( - modifier = Modifier.padding(start = 30.dp), + modifier = Modifier.weight(1f).padding(start = 30.dp), text = articleWithFeed.feed.name, color = MaterialTheme.colorScheme.tertiary, style = MaterialTheme.typography.labelMedium, + maxLines = 1, + overflow = TextOverflow.Ellipsis, ) Text( + modifier = Modifier.padding(start = 6.dp), text = articleWithFeed.article.date.formatToString(context, onlyHourMinute = true), color = MaterialTheme.colorScheme.outline.copy(alpha = 0.7f), style = MaterialTheme.typography.labelMedium,