From c13eb75128fae159eccdd79793cc235ebcdfdbc1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 17 Jun 2024 18:02:16 +0930 Subject: [PATCH] Refactor DialogButton --- .../thoughtcrime/securesms/ui/AlertDialog.kt | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt index 1c67ac0fb3..9f4ade47b6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt @@ -19,7 +19,6 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import network.loki.messenger.R import org.thoughtcrime.securesms.ui.color.LocalColors -import org.thoughtcrime.securesms.ui.components.BorderlessButton class DialogButtonModel( val text: GetString, @@ -65,25 +64,14 @@ fun AlertDialog( buttons?.takeIf { it.isNotEmpty() }?.let { Row { it.forEach { - TextButton( + DialogButton( + text = it.text(), modifier = Modifier .contentDescription(it.contentDescription()) - .weight(1f), - shape = RectangleShape, - onClick = { - it.onClick - onDismissRequest() - } + .weight(1f) ) { - Text( - it.text(), - color = LocalColors.current.text, - style = largeBold, - modifier = Modifier.padding( - top = 16.dp, - bottom = 24.dp - ) - ) + it.onClick() + onDismissRequest() } } } @@ -95,6 +83,20 @@ fun AlertDialog( } @Composable -fun DialogButton(text: String, contentDescription: String, onClick: () -> Unit) { - BorderlessButton(text, modifier = Modifier.contentDescription(contentDescription), onClick = onClick) +fun DialogButton(text: String, modifier: Modifier, onClick: () -> Unit) { + TextButton( + modifier = modifier, + shape = RectangleShape, + onClick = onClick + ) { + Text( + text, + color = LocalColors.current.text, + style = largeBold, + modifier = Modifier.padding( + top = 16.dp, + bottom = 24.dp + ) + ) + } }