diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt index 2a9275750..d631d236f 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/PostCard.kt @@ -50,7 +50,8 @@ fun PostCard( hideAuthor: Boolean = false, postLayout: PostLayout = PostLayout.Card, separateUpAndDownVotes: Boolean = false, - withOverflowBlurred: Boolean = true, + includeFullBody: Boolean = false, + limitBodyHeight: Boolean = false, blurNsfw: Boolean = true, options: List = emptyList(), onOpenCommunity: ((CommunityModel) -> Unit)? = null, @@ -90,7 +91,8 @@ fun PostCard( PostLayout.Card -> MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp) else -> MaterialTheme.colorScheme.background }, - withOverflowBlurred = withOverflowBlurred, + showBody = includeFullBody || postLayout == PostLayout.Full, + limitBodyHeight = limitBodyHeight, separateUpAndDownVotes = separateUpAndDownVotes, autoLoadImages = autoLoadImages, blurNsfw = blurNsfw, @@ -205,10 +207,11 @@ private fun ExtendedPost( modifier: Modifier = Modifier, post: PostModel, autoLoadImages: Boolean = true, - hideAuthor: Boolean, - blurNsfw: Boolean, - separateUpAndDownVotes: Boolean, - withOverflowBlurred: Boolean, + hideAuthor: Boolean = false, + blurNsfw: Boolean = true, + separateUpAndDownVotes: Boolean = false, + showBody: Boolean = false, + limitBodyHeight: Boolean = false, backgroundColor: Color = MaterialTheme.colorScheme.background, options: List = emptyList(), onOpenCommunity: ((CommunityModel) -> Unit)? = null, @@ -248,35 +251,37 @@ private fun ExtendedPost( onImageClick = onImageClick, autoLoadImages = autoLoadImages, ) - Box { - val maxHeight = 200.dp - val maxHeightPx = maxHeight.toLocalPixel() - var textHeightPx by remember { mutableStateOf(0f) } - PostCardBody( - modifier = Modifier.let { - if (withOverflowBlurred) { - it.heightIn(max = maxHeight) - } else { - it - } - }.padding(horizontal = Spacing.xs).onGloballyPositioned { - textHeightPx = it.size.toSize().height - }, - text = post.text, - autoLoadImages = autoLoadImages, - ) - if (withOverflowBlurred && textHeightPx >= maxHeightPx) { - Box( - modifier = Modifier.height(Spacing.xxl).fillMaxWidth() - .align(Alignment.BottomCenter).background( - brush = Brush.verticalGradient( - colors = listOf( - Color.Transparent, - backgroundColor, + if (showBody) { + Box { + val maxHeight = 200.dp + val maxHeightPx = maxHeight.toLocalPixel() + var textHeightPx by remember { mutableStateOf(0f) } + PostCardBody( + modifier = Modifier.let { + if (limitBodyHeight) { + it.heightIn(max = maxHeight) + } else { + it + } + }.padding(horizontal = Spacing.xs).onGloballyPositioned { + textHeightPx = it.size.toSize().height + }, + text = post.text, + autoLoadImages = autoLoadImages, + ) + if (limitBodyHeight && textHeightPx >= maxHeightPx) { + Box( + modifier = Modifier.height(Spacing.xxl).fillMaxWidth() + .align(Alignment.BottomCenter).background( + brush = Brush.verticalGradient( + colors = listOf( + Color.Transparent, + backgroundColor, + ), ), ), - ), - ) + ) + } } } if (post.url != post.imageUrl) { diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createcomment/CreateCommentScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createcomment/CreateCommentScreen.kt index db4fc3cc2..d42210d74 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createcomment/CreateCommentScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createcomment/CreateCommentScreen.kt @@ -179,6 +179,7 @@ class CreateCommentScreen( modifier = referenceModifier, postLayout = uiState.postLayout, post = originalPost, + limitBodyHeight = true, blurNsfw = false, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createpost/CreatePostScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createpost/CreatePostScreen.kt index 4d4a84175..faa878e19 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createpost/CreatePostScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/createpost/CreatePostScreen.kt @@ -330,7 +330,7 @@ class CreatePostScreen( PostCard( post = post, postLayout = uiState.postLayout, - withOverflowBlurred = false, + includeFullBody = true, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, ) diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt index 02c99f6e0..7a3075541 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/postdetail/PostDetailScreen.kt @@ -269,7 +269,7 @@ class PostDetailScreen( PostCard( post = statePost, postLayout = uiState.postLayout, - withOverflowBlurred = false, + includeFullBody = true, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages, blurNsfw = false, diff --git a/resources/src/commonMain/resources/MR/it/strings.xml b/resources/src/commonMain/resources/MR/it/strings.xml index 208d72caa..9b79501cf 100644 --- a/resources/src/commonMain/resources/MR/it/strings.xml +++ b/resources/src/commonMain/resources/MR/it/strings.xml @@ -117,7 +117,7 @@ Colore tema personalizzato Layout post Compatto - Carta + Scheda Intero Blu aziendale Acquamarina