fix: highlighted comment background

This commit is contained in:
Diego Beraldin 2023-10-18 18:22:27 +02:00
parent e56f531468
commit bb24ac38d4
2 changed files with 22 additions and 18 deletions

View File

@ -16,7 +16,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.Density
@ -34,7 +33,6 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.CommentR
@Composable @Composable
fun CommentCard( fun CommentCard(
comment: CommentModel, comment: CommentModel,
background: Color = MaterialTheme.colorScheme.background,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
separateUpAndDownVotes: Boolean = false, separateUpAndDownVotes: Boolean = false,
hideAuthor: Boolean = false, hideAuthor: Boolean = false,
@ -59,7 +57,7 @@ fun CommentCard(
), ),
) { ) {
Column( Column(
modifier = modifier.background(background) modifier = modifier
) { ) {
var commentHeight by remember { mutableStateOf(0f) } var commentHeight by remember { mutableStateOf(0f) }
val barWidth = 2.dp val barWidth = 2.dp

View File

@ -480,21 +480,27 @@ class PostDetailScreen(
}, },
content = { content = {
CommentCard( CommentCard(
modifier = Modifier.onClick { modifier = Modifier
model.reduce( .background(MaterialTheme.colorScheme.background)
PostDetailMviModel.Intent.ToggleExpandComment( .let {
commentId, if (comment.id == highlightCommentId) {
) it.background(
)
},
background = if (comment.id == highlightCommentId) {
MaterialTheme.colorScheme.surfaceColorAtElevation( MaterialTheme.colorScheme.surfaceColorAtElevation(
5.dp 5.dp
).copy( ).copy(
alpha = 0.75f alpha = 0.75f
) )
)
} else { } else {
MaterialTheme.colorScheme.background it
}
}
.onClick {
model.reduce(
PostDetailMviModel.Intent.ToggleExpandComment(
commentId,
)
)
}, },
comment = comment, comment = comment,
separateUpAndDownVotes = uiState.separateUpAndDownVotes, separateUpAndDownVotes = uiState.separateUpAndDownVotes,