From 8231062ca5f84ccc159d3fa04fbb51bde8aa4db9 Mon Sep 17 00:00:00 2001 From: Danil Nikolaev Date: Wed, 3 Dec 2025 06:22:53 +0300 Subject: [PATCH] Refactor: Move RippledClickContainer to core UI module Moves the `RippledClickContainer` composable from the `messageshistory` feature module to the `core/ui` module to allow for reuse across different features. Additionally, this change introduces text truncation with an ellipsis for the title and text within the `ReplyContainer` to prevent long content from breaking the layout. --- .../ui/components/RippledClickContainer.kt | 33 +++++++++++++++++++ .../presentation/ReplyContainer.kt | 32 ++++-------------- 2 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 core/ui/src/main/kotlin/dev/meloda/fast/ui/components/RippledClickContainer.kt diff --git a/core/ui/src/main/kotlin/dev/meloda/fast/ui/components/RippledClickContainer.kt b/core/ui/src/main/kotlin/dev/meloda/fast/ui/components/RippledClickContainer.kt new file mode 100644 index 00000000..7cd6bb46 --- /dev/null +++ b/core/ui/src/main/kotlin/dev/meloda/fast/ui/components/RippledClickContainer.kt @@ -0,0 +1,33 @@ +package dev.meloda.fast.ui.components + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.ripple +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.dp + +@Composable +fun RippledClickContainer( + modifier: Modifier = Modifier, + shape: Shape = RoundedCornerShape(4.dp), + onClick: () -> Unit, + content: @Composable () -> Unit +) { + Box( + modifier = modifier + .clip(shape) + .clickable( + interactionSource = null, + indication = ripple(), + onClick = onClick + ), + contentAlignment = Alignment.Center + ) { + content() + } +} diff --git a/feature/messageshistory/src/main/kotlin/dev/meloda/fast/messageshistory/presentation/ReplyContainer.kt b/feature/messageshistory/src/main/kotlin/dev/meloda/fast/messageshistory/presentation/ReplyContainer.kt index 159a9a14..11455186 100644 --- a/feature/messageshistory/src/main/kotlin/dev/meloda/fast/messageshistory/presentation/ReplyContainer.kt +++ b/feature/messageshistory/src/main/kotlin/dev/meloda/fast/messageshistory/presentation/ReplyContainer.kt @@ -2,7 +2,6 @@ package dev.meloda.fast.messageshistory.presentation import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.background -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -17,18 +16,18 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text -import androidx.compose.material3.ripple import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Shape import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import dev.meloda.fast.ui.R +import dev.meloda.fast.ui.components.RippledClickContainer @Composable fun ReplyContainer( @@ -69,13 +68,17 @@ fun ReplyContainer( Text( text = title, style = MaterialTheme.typography.labelLarge, - color = MaterialTheme.colorScheme.primary + color = MaterialTheme.colorScheme.primary, + maxLines = 1, + overflow = TextOverflow.Ellipsis ) AnimatedVisibility(text != null) { Text( text = text.orEmpty(), style = MaterialTheme.typography.bodySmall, + maxLines = 1, + overflow = TextOverflow.Ellipsis ) } } @@ -93,27 +96,6 @@ fun ReplyContainer( } } -@Composable -fun RippledClickContainer( - modifier: Modifier = Modifier, - shape: Shape = RoundedCornerShape(4.dp), - onClick: () -> Unit, - content: @Composable () -> Unit -) { - Box( - modifier = modifier - .clip(shape) - .clickable( - interactionSource = null, - indication = ripple(), - onClick = onClick - ), - contentAlignment = Alignment.Center - ) { - content() - } -} - @Preview @Composable private fun ReplyContainerPreview() {