Fix some text overflow style

This commit is contained in:
Ash 2022-03-30 00:56:41 +08:00
parent 84370395f2
commit 77cd5ca872
4 changed files with 31 additions and 16 deletions

View File

@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel import androidx.hilt.navigation.compose.hiltViewModel
import me.ash.reader.data.feed.Feed import me.ash.reader.data.feed.Feed
@ -52,27 +53,31 @@ fun FeedItem(
.padding(vertical = 14.dp), .padding(vertical = 14.dp),
) { ) {
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier
.fillMaxWidth()
.padding(start = 14.dp, end = 6.dp),
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Row(modifier = Modifier.padding(start = 14.dp)) { Row(modifier = Modifier.weight(1f)) {
Row( Row(
modifier = Modifier modifier = Modifier
.size(20.dp) .size(20.dp)
.clip(CircleShape) .clip(CircleShape)
.background(MaterialTheme.colorScheme.outline), .background(MaterialTheme.colorScheme.outline),
) {} ) {}
Spacer(modifier = Modifier.width(12.dp))
Text( Text(
modifier = Modifier.padding(start = 12.dp, end = 6.dp),
text = feed.name, text = feed.name,
style = MaterialTheme.typography.labelLarge, style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
) )
} }
if (feed.important ?: 0 != 0) { if (feed.important ?: 0 != 0) {
Row() {
Badge( Badge(
modifier = Modifier.padding(end = 6.dp),
containerColor = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.24f), containerColor = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.24f),
contentColor = MaterialTheme.colorScheme.outline, contentColor = MaterialTheme.colorScheme.outline,
content = { content = {
@ -85,4 +90,5 @@ fun FeedItem(
} }
} }
} }
}
} }

View File

@ -19,6 +19,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate import androidx.compose.ui.draw.rotate
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
@ -127,6 +128,8 @@ fun FeedsPage(
text = viewState.account?.name ?: stringResource(R.string.unknown), text = viewState.account?.name ?: stringResource(R.string.unknown),
style = MaterialTheme.typography.displaySmall, style = MaterialTheme.typography.displaySmall,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
) )
} }
item { item {

View File

@ -19,6 +19,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import me.ash.reader.R import me.ash.reader.R
import me.ash.reader.data.feed.Feed import me.ash.reader.data.feed.Feed
@ -60,6 +61,8 @@ fun GroupItem(
text = text, text = text,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSecondaryContainer, color = MaterialTheme.colorScheme.onSecondaryContainer,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
) )
Row( Row(
modifier = Modifier modifier = Modifier

View File

@ -40,12 +40,15 @@ fun ArticleItem(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Text( Text(
modifier = Modifier.padding(start = 30.dp), modifier = Modifier.weight(1f).padding(start = 30.dp),
text = articleWithFeed.feed.name, text = articleWithFeed.feed.name,
color = MaterialTheme.colorScheme.tertiary, color = MaterialTheme.colorScheme.tertiary,
style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
) )
Text( Text(
modifier = Modifier.padding(start = 6.dp),
text = articleWithFeed.article.date.formatToString(context, onlyHourMinute = true), text = articleWithFeed.article.date.formatToString(context, onlyHourMinute = true),
color = MaterialTheme.colorScheme.outline.copy(alpha = 0.7f), color = MaterialTheme.colorScheme.outline.copy(alpha = 0.7f),
style = MaterialTheme.typography.labelMedium, style = MaterialTheme.typography.labelMedium,