From bb24ac38d4f4e85cf847984448d0dfa4c487d2ab Mon Sep 17 00:00:00 2001 From: Diego Beraldin Date: Wed, 18 Oct 2023 18:22:27 +0200 Subject: [PATCH] fix: highlighted comment background --- .../core/commonui/components/CommentCard.kt | 4 +-- .../commonui/postdetail/PostDetailScreen.kt | 36 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommentCard.kt b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommentCard.kt index 67179d97b..31aab2f2b 100644 --- a/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommentCard.kt +++ b/core-commonui/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/commonui/components/CommentCard.kt @@ -16,7 +16,6 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.Density @@ -34,7 +33,6 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.CommentR @Composable fun CommentCard( comment: CommentModel, - background: Color = MaterialTheme.colorScheme.background, modifier: Modifier = Modifier, separateUpAndDownVotes: Boolean = false, hideAuthor: Boolean = false, @@ -59,7 +57,7 @@ fun CommentCard( ), ) { Column( - modifier = modifier.background(background) + modifier = modifier ) { var commentHeight by remember { mutableStateOf(0f) } val barWidth = 2.dp 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 af21c8536..f25924ad1 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 @@ -480,22 +480,28 @@ class PostDetailScreen( }, content = { CommentCard( - modifier = Modifier.onClick { - model.reduce( - PostDetailMviModel.Intent.ToggleExpandComment( - commentId, + modifier = Modifier + .background(MaterialTheme.colorScheme.background) + .let { + if (comment.id == highlightCommentId) { + it.background( + MaterialTheme.colorScheme.surfaceColorAtElevation( + 5.dp + ).copy( + alpha = 0.75f + ) + ) + } else { + it + } + } + .onClick { + model.reduce( + PostDetailMviModel.Intent.ToggleExpandComment( + commentId, + ) ) - ) - }, - background = if (comment.id == highlightCommentId) { - MaterialTheme.colorScheme.surfaceColorAtElevation( - 5.dp - ).copy( - alpha = 0.75f - ) - } else { - MaterialTheme.colorScheme.background - }, + }, comment = comment, separateUpAndDownVotes = uiState.separateUpAndDownVotes, autoLoadImages = uiState.autoLoadImages,