fix(common): force titles in lists to be a single line
This commit is contained in:
parent
687cb32f7c
commit
ca03561df0
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Remove dividers between posts
|
- Remove dividers between posts
|
||||||
|
- Post titles in lists are now truncated to be a single line
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ internal fun CommentsHeader(
|
||||||
modifier = Modifier.padding(16.dp).fillMaxWidth(),
|
modifier = Modifier.padding(16.dp).fillMaxWidth(),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
) {
|
) {
|
||||||
PostTitle(title = post.title, isRead = false)
|
PostTitle(title = post.title, isRead = false, singleLineTitle = false)
|
||||||
TagRow(tags = post.tags.toImmutableList())
|
TagRow(tags = post.tags.toImmutableList())
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.semantics.Role
|
import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||||
import dev.msfjarvis.claw.common.ui.NetworkImage
|
import dev.msfjarvis.claw.common.ui.NetworkImage
|
||||||
|
@ -82,7 +83,12 @@ fun LobstersCard(
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
PostDetails(post = post, isRead = localReadState, modifier = Modifier.weight(1f))
|
PostDetails(
|
||||||
|
post = post,
|
||||||
|
isRead = localReadState,
|
||||||
|
singleLineTitle = true,
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
)
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.wrapContentHeight(),
|
modifier = Modifier.wrapContentHeight(),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
@ -116,9 +122,14 @@ fun LobstersCard(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PostDetails(post: UIPost, isRead: Boolean, modifier: Modifier = Modifier) {
|
fun PostDetails(
|
||||||
|
post: UIPost,
|
||||||
|
isRead: Boolean,
|
||||||
|
singleLineTitle: Boolean,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
PostTitle(title = post.title, isRead = isRead)
|
PostTitle(title = post.title, isRead = isRead, singleLineTitle = singleLineTitle)
|
||||||
TagRow(tags = post.tags.toImmutableList())
|
TagRow(tags = post.tags.toImmutableList())
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
Submitter(
|
Submitter(
|
||||||
|
@ -130,13 +141,20 @@ fun PostDetails(post: UIPost, isRead: Boolean, modifier: Modifier = Modifier) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun PostTitle(title: String, isRead: Boolean, modifier: Modifier = Modifier) {
|
internal fun PostTitle(
|
||||||
|
title: String,
|
||||||
|
isRead: Boolean,
|
||||||
|
singleLineTitle: Boolean,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = title,
|
text = title,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
fontWeight = if (isRead) FontWeight.Normal else FontWeight.Bold,
|
fontWeight = if (isRead) FontWeight.Normal else FontWeight.Bold,
|
||||||
color = MaterialTheme.colorScheme.onBackground,
|
color = MaterialTheme.colorScheme.onBackground,
|
||||||
|
maxLines = if (singleLineTitle) 1 else Int.MAX_VALUE,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue