Convert InternalConversationSettings to compose.

This commit is contained in:
Alex Hart
2025-05-27 10:48:34 -03:00
committed by GitHub
parent 6879778f4b
commit daa3e5d95a
5 changed files with 804 additions and 417 deletions

View File

@@ -44,6 +44,7 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import org.signal.core.ui.R
@@ -224,6 +225,34 @@ object Rows {
onClick: (() -> Unit)? = null,
onLongClick: (() -> Unit)? = null,
enabled: Boolean = true
) {
TextRow(
text = remember(text) { AnnotatedString(text) },
label = remember(label) { label?.let { AnnotatedString(label) } },
icon = icon,
modifier = modifier,
iconModifier = iconModifier,
foregroundTint = foregroundTint,
onClick = onClick,
onLongClick = onLongClick,
enabled = enabled
)
}
/**
* Text row that positions [text] and optional [label] in a [TextAndLabel] to the side of an optional [icon].
*/
@Composable
fun TextRow(
text: AnnotatedString,
modifier: Modifier = Modifier,
iconModifier: Modifier = Modifier,
label: AnnotatedString? = null,
icon: Painter? = null,
foregroundTint: Color = MaterialTheme.colorScheme.onSurface,
onClick: (() -> Unit)? = null,
onLongClick: (() -> Unit)? = null,
enabled: Boolean = true
) {
TextRow(
text = {
@@ -353,6 +382,28 @@ object Rows {
enabled: Boolean = true,
textColor: Color = MaterialTheme.colorScheme.onSurface,
textStyle: TextStyle = MaterialTheme.typography.bodyLarge
) {
TextAndLabel(
text = remember(text) { text?.let { AnnotatedString(it) } },
label = remember(label) { label?.let { AnnotatedString(it) } },
modifier = modifier,
enabled = enabled,
textColor = textColor,
textStyle = textStyle
)
}
/**
* Row component to position text above an optional label.
*/
@Composable
fun RowScope.TextAndLabel(
text: AnnotatedString? = null,
modifier: Modifier = Modifier,
label: AnnotatedString? = null,
enabled: Boolean = true,
textColor: Color = MaterialTheme.colorScheme.onSurface,
textStyle: TextStyle = MaterialTheme.typography.bodyLarge
) {
Column(
modifier = modifier