Refactor DialogButton

This commit is contained in:
Andrew 2024-06-17 18:02:16 +09:30
parent 5841ab0218
commit c13eb75128

View File

@ -19,7 +19,6 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import network.loki.messenger.R import network.loki.messenger.R
import org.thoughtcrime.securesms.ui.color.LocalColors import org.thoughtcrime.securesms.ui.color.LocalColors
import org.thoughtcrime.securesms.ui.components.BorderlessButton
class DialogButtonModel( class DialogButtonModel(
val text: GetString, val text: GetString,
@ -65,25 +64,14 @@ fun AlertDialog(
buttons?.takeIf { it.isNotEmpty() }?.let { buttons?.takeIf { it.isNotEmpty() }?.let {
Row { Row {
it.forEach { it.forEach {
TextButton( DialogButton(
text = it.text(),
modifier = Modifier modifier = Modifier
.contentDescription(it.contentDescription()) .contentDescription(it.contentDescription())
.weight(1f), .weight(1f)
shape = RectangleShape,
onClick = {
it.onClick
onDismissRequest()
}
) { ) {
Text( it.onClick()
it.text(), onDismissRequest()
color = LocalColors.current.text,
style = largeBold,
modifier = Modifier.padding(
top = 16.dp,
bottom = 24.dp
)
)
} }
} }
} }
@ -95,6 +83,20 @@ fun AlertDialog(
} }
@Composable @Composable
fun DialogButton(text: String, contentDescription: String, onClick: () -> Unit) { fun DialogButton(text: String, modifier: Modifier, onClick: () -> Unit) {
BorderlessButton(text, modifier = Modifier.contentDescription(contentDescription), onClick = onClick) TextButton(
modifier = modifier,
shape = RectangleShape,
onClick = onClick
) {
Text(
text,
color = LocalColors.current.text,
style = largeBold,
modifier = Modifier.padding(
top = 16.dp,
bottom = 24.dp
)
)
}
} }