fix(common-ui): show full text in post detail

This commit is contained in:
Diego Beraldin 2023-09-25 13:44:26 +02:00
parent cf79aaf4a0
commit 859437c321
2 changed files with 27 additions and 15 deletions

View File

@ -40,6 +40,7 @@ fun PostCard(
post: PostModel, post: PostModel,
hideAuthor: Boolean = false, hideAuthor: Boolean = false,
postLayout: PostLayout = PostLayout.Card, postLayout: PostLayout = PostLayout.Card,
withOverflowBlurred: Boolean = true,
blurNsfw: Boolean, blurNsfw: Boolean,
options: List<String> = emptyList(), options: List<String> = emptyList(),
onOpenCommunity: ((CommunityModel) -> Unit)? = null, onOpenCommunity: ((CommunityModel) -> Unit)? = null,
@ -82,10 +83,11 @@ fun PostCard(
post = post, post = post,
hideAuthor = hideAuthor, hideAuthor = hideAuthor,
withDivider = postLayout == PostLayout.Full, withDivider = postLayout == PostLayout.Full,
overflowBlurColor = when (postLayout) { backgroundColor = when (postLayout) {
PostLayout.Card -> MaterialTheme.colorScheme.surfaceVariant PostLayout.Card -> MaterialTheme.colorScheme.surfaceVariant
else -> MaterialTheme.colorScheme.surface else -> MaterialTheme.colorScheme.surface
}, },
withOverflowBlurred = withOverflowBlurred,
blurNsfw = blurNsfw, blurNsfw = blurNsfw,
options = options, options = options,
onOpenCommunity = onOpenCommunity, onOpenCommunity = onOpenCommunity,
@ -188,7 +190,8 @@ private fun ExtendedPost(
hideAuthor: Boolean = false, hideAuthor: Boolean = false,
blurNsfw: Boolean, blurNsfw: Boolean,
withDivider: Boolean = false, withDivider: Boolean = false,
overflowBlurColor: Color = MaterialTheme.colorScheme.background, withOverflowBlurred: Boolean = true,
backgroundColor: Color = MaterialTheme.colorScheme.background,
options: List<String> = emptyList(), options: List<String> = emptyList(),
onOpenCommunity: ((CommunityModel) -> Unit)? = null, onOpenCommunity: ((CommunityModel) -> Unit)? = null,
onOpenCreator: ((UserModel) -> Unit)? = null, onOpenCreator: ((UserModel) -> Unit)? = null,
@ -200,7 +203,7 @@ private fun ExtendedPost(
onOptionSelected: ((Int) -> Unit)? = null, onOptionSelected: ((Int) -> Unit)? = null,
) { ) {
Column( Column(
modifier = modifier.background(overflowBlurColor), modifier = modifier.background(backgroundColor),
verticalArrangement = Arrangement.spacedBy(Spacing.xxs), verticalArrangement = Arrangement.spacedBy(Spacing.xxs),
) { ) {
CommunityAndCreatorInfo( CommunityAndCreatorInfo(
@ -222,10 +225,17 @@ private fun ExtendedPost(
Box { Box {
PostCardBody( PostCardBody(
modifier = Modifier modifier = Modifier
.heightIn(max = 200.dp) .let {
if (withOverflowBlurred) {
it.heightIn(max = 200.dp)
} else {
it
}
}
.padding(bottom = Spacing.xs), .padding(bottom = Spacing.xs),
text = post.text, text = post.text,
) )
if (withOverflowBlurred) {
Box( Box(
modifier = Modifier modifier = Modifier
.height(Spacing.s) .height(Spacing.s)
@ -234,12 +244,13 @@ private fun ExtendedPost(
brush = Brush.verticalGradient( brush = Brush.verticalGradient(
colors = listOf( colors = listOf(
Color.Transparent, Color.Transparent,
overflowBlurColor, backgroundColor,
), ),
), ),
), ),
) )
} }
}
PostLinkBanner( PostLinkBanner(
modifier = Modifier.padding(vertical = Spacing.xs), modifier = Modifier.padding(vertical = Spacing.xs),
url = post.url.takeIf { url = post.url.takeIf {

View File

@ -238,6 +238,7 @@ class PostDetailScreen(
PostCard( PostCard(
post = statePost, post = statePost,
postLayout = uiState.postLayout, postLayout = uiState.postLayout,
withOverflowBlurred = false,
blurNsfw = false, blurNsfw = false,
options = buildList { options = buildList {
add(stringResource(MR.strings.post_action_share)) add(stringResource(MR.strings.post_action_share))