enhancement: update card and full post mode

This commit is contained in:
Diego Beraldin 2023-10-17 22:49:12 +02:00
parent df7b4632b7
commit 26e37d9ae8
5 changed files with 42 additions and 36 deletions

View File

@ -50,7 +50,8 @@ fun PostCard(
hideAuthor: Boolean = false, hideAuthor: Boolean = false,
postLayout: PostLayout = PostLayout.Card, postLayout: PostLayout = PostLayout.Card,
separateUpAndDownVotes: Boolean = false, separateUpAndDownVotes: Boolean = false,
withOverflowBlurred: Boolean = true, includeFullBody: Boolean = false,
limitBodyHeight: Boolean = false,
blurNsfw: Boolean = true, blurNsfw: Boolean = true,
options: List<String> = emptyList(), options: List<String> = emptyList(),
onOpenCommunity: ((CommunityModel) -> Unit)? = null, onOpenCommunity: ((CommunityModel) -> Unit)? = null,
@ -90,7 +91,8 @@ fun PostCard(
PostLayout.Card -> MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp) PostLayout.Card -> MaterialTheme.colorScheme.surfaceColorAtElevation(5.dp)
else -> MaterialTheme.colorScheme.background else -> MaterialTheme.colorScheme.background
}, },
withOverflowBlurred = withOverflowBlurred, showBody = includeFullBody || postLayout == PostLayout.Full,
limitBodyHeight = limitBodyHeight,
separateUpAndDownVotes = separateUpAndDownVotes, separateUpAndDownVotes = separateUpAndDownVotes,
autoLoadImages = autoLoadImages, autoLoadImages = autoLoadImages,
blurNsfw = blurNsfw, blurNsfw = blurNsfw,
@ -205,10 +207,11 @@ private fun ExtendedPost(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
post: PostModel, post: PostModel,
autoLoadImages: Boolean = true, autoLoadImages: Boolean = true,
hideAuthor: Boolean, hideAuthor: Boolean = false,
blurNsfw: Boolean, blurNsfw: Boolean = true,
separateUpAndDownVotes: Boolean, separateUpAndDownVotes: Boolean = false,
withOverflowBlurred: Boolean, showBody: Boolean = false,
limitBodyHeight: Boolean = false,
backgroundColor: Color = MaterialTheme.colorScheme.background, backgroundColor: Color = MaterialTheme.colorScheme.background,
options: List<String> = emptyList(), options: List<String> = emptyList(),
onOpenCommunity: ((CommunityModel) -> Unit)? = null, onOpenCommunity: ((CommunityModel) -> Unit)? = null,
@ -248,13 +251,14 @@ private fun ExtendedPost(
onImageClick = onImageClick, onImageClick = onImageClick,
autoLoadImages = autoLoadImages, autoLoadImages = autoLoadImages,
) )
if (showBody) {
Box { Box {
val maxHeight = 200.dp val maxHeight = 200.dp
val maxHeightPx = maxHeight.toLocalPixel() val maxHeightPx = maxHeight.toLocalPixel()
var textHeightPx by remember { mutableStateOf(0f) } var textHeightPx by remember { mutableStateOf(0f) }
PostCardBody( PostCardBody(
modifier = Modifier.let { modifier = Modifier.let {
if (withOverflowBlurred) { if (limitBodyHeight) {
it.heightIn(max = maxHeight) it.heightIn(max = maxHeight)
} else { } else {
it it
@ -265,7 +269,7 @@ private fun ExtendedPost(
text = post.text, text = post.text,
autoLoadImages = autoLoadImages, autoLoadImages = autoLoadImages,
) )
if (withOverflowBlurred && textHeightPx >= maxHeightPx) { if (limitBodyHeight && textHeightPx >= maxHeightPx) {
Box( Box(
modifier = Modifier.height(Spacing.xxl).fillMaxWidth() modifier = Modifier.height(Spacing.xxl).fillMaxWidth()
.align(Alignment.BottomCenter).background( .align(Alignment.BottomCenter).background(
@ -279,6 +283,7 @@ private fun ExtendedPost(
) )
} }
} }
}
if (post.url != post.imageUrl) { if (post.url != post.imageUrl) {
PostLinkBanner( PostLinkBanner(
modifier = Modifier.padding(vertical = Spacing.xs), modifier = Modifier.padding(vertical = Spacing.xs),

View File

@ -179,6 +179,7 @@ class CreateCommentScreen(
modifier = referenceModifier, modifier = referenceModifier,
postLayout = uiState.postLayout, postLayout = uiState.postLayout,
post = originalPost, post = originalPost,
limitBodyHeight = true,
blurNsfw = false, blurNsfw = false,
separateUpAndDownVotes = uiState.separateUpAndDownVotes, separateUpAndDownVotes = uiState.separateUpAndDownVotes,
autoLoadImages = uiState.autoLoadImages, autoLoadImages = uiState.autoLoadImages,

View File

@ -330,7 +330,7 @@ class CreatePostScreen(
PostCard( PostCard(
post = post, post = post,
postLayout = uiState.postLayout, postLayout = uiState.postLayout,
withOverflowBlurred = false, includeFullBody = true,
separateUpAndDownVotes = uiState.separateUpAndDownVotes, separateUpAndDownVotes = uiState.separateUpAndDownVotes,
autoLoadImages = uiState.autoLoadImages, autoLoadImages = uiState.autoLoadImages,
) )

View File

@ -269,7 +269,7 @@ class PostDetailScreen(
PostCard( PostCard(
post = statePost, post = statePost,
postLayout = uiState.postLayout, postLayout = uiState.postLayout,
withOverflowBlurred = false, includeFullBody = true,
separateUpAndDownVotes = uiState.separateUpAndDownVotes, separateUpAndDownVotes = uiState.separateUpAndDownVotes,
autoLoadImages = uiState.autoLoadImages, autoLoadImages = uiState.autoLoadImages,
blurNsfw = false, blurNsfw = false,

View File

@ -117,7 +117,7 @@
<string name="settings_custom_seed_color">Colore tema personalizzato</string> <string name="settings_custom_seed_color">Colore tema personalizzato</string>
<string name="settings_post_layout">Layout post</string> <string name="settings_post_layout">Layout post</string>
<string name="settings_post_layout_compact">Compatto</string> <string name="settings_post_layout_compact">Compatto</string>
<string name="settings_post_layout_card">Carta</string> <string name="settings_post_layout_card">Scheda</string>
<string name="settings_post_layout_full">Intero</string> <string name="settings_post_layout_full">Intero</string>
<string name="settings_color_blue">Blu aziendale</string> <string name="settings_color_blue">Blu aziendale</string>
<string name="settings_color_aquamarine">Acquamarina</string> <string name="settings_color_aquamarine">Acquamarina</string>