From b82fca303f40f5ee24a13c9531b0d3682a86fcce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de> Date: Mon, 31 Jan 2022 14:33:06 +0100 Subject: [PATCH] Use NEUTRAL/DESTRUCTIVE for button types --- .../androidx/compose/material/DialogButton.kt | 8 +++--- .../contact/add/remote/AddContactDialog.kt | 9 +++---- .../conversation/ConversationDialogs.kt | 25 +++++++++++-------- .../ConversationRequestItemView.kt | 10 ++++---- .../briar/desktop/login/LoginScreen.kt | 10 ++++---- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/androidx/compose/material/DialogButton.kt b/src/main/kotlin/androidx/compose/material/DialogButton.kt index e16456ff83..27a767e46e 100644 --- a/src/main/kotlin/androidx/compose/material/DialogButton.kt +++ b/src/main/kotlin/androidx/compose/material/DialogButton.kt @@ -25,8 +25,8 @@ import org.briarproject.briar.desktop.theme.buttonTextPositive import java.util.Locale enum class ButtonType { - POSITIVE, - NEGATIVE, + NEUTRAL, + DESTRUCTIVE, } @Composable @@ -40,8 +40,8 @@ fun DialogButton( text.uppercase(Locale.getDefault()), fontSize = 16.sp, color = when (type) { - ButtonType.POSITIVE -> MaterialTheme.colors.buttonTextPositive - ButtonType.NEGATIVE -> MaterialTheme.colors.buttonTextNegative + ButtonType.NEUTRAL -> MaterialTheme.colors.buttonTextPositive + ButtonType.DESTRUCTIVE -> MaterialTheme.colors.buttonTextNegative }, ) } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/contact/add/remote/AddContactDialog.kt b/src/main/kotlin/org/briarproject/briar/desktop/contact/add/remote/AddContactDialog.kt index 4e22dac458..840c0834b2 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/contact/add/remote/AddContactDialog.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/contact/add/remote/AddContactDialog.kt @@ -26,8 +26,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn import androidx.compose.material.AlertDialog -import androidx.compose.material.ButtonType.NEGATIVE -import androidx.compose.material.ButtonType.POSITIVE +import androidx.compose.material.ButtonType.NEUTRAL import androidx.compose.material.DialogButton import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon @@ -194,8 +193,8 @@ fun AddContactDialog( } } }, - confirmButton = { DialogButton(onClick = onSubmitAddContactDialog, text = i18n("add"), type = POSITIVE) }, - dismissButton = { DialogButton(onClick = onClose, text = i18n("cancel"), type = NEGATIVE) }, + confirmButton = { DialogButton(onClick = onSubmitAddContactDialog, text = i18n("add"), type = NEUTRAL) }, + dismissButton = { DialogButton(onClick = onClose, text = i18n("cancel"), type = NEUTRAL) }, ) if (error != null) { val (type, title, message) = errorMessage(error) @@ -205,7 +204,7 @@ fun AddContactDialog( } AlertDialog( onDismissRequest = onErrorDialogDismissed, - confirmButton = { DialogButton(onClick = onErrorDialogDismissed, text = i18n("ok"), type = POSITIVE) }, + confirmButton = { DialogButton(onClick = onErrorDialogDismissed, text = i18n("ok"), type = NEUTRAL) }, modifier = Modifier.widthIn(min = DIALOG_WIDTH), title = { Row( diff --git a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationDialogs.kt b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationDialogs.kt index 3ad127a00a..20db970bae 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationDialogs.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationDialogs.kt @@ -20,12 +20,14 @@ package org.briarproject.briar.desktop.conversation import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.IntrinsicSize +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material.AlertDialog import androidx.compose.material.Button -import androidx.compose.material.ButtonType.NEGATIVE -import androidx.compose.material.ButtonType.POSITIVE +import androidx.compose.material.ButtonType.DESTRUCTIVE +import androidx.compose.material.ButtonType.NEUTRAL import androidx.compose.material.DialogButton import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Text @@ -113,8 +115,8 @@ fun DeleteAllMessagesConfirmationDialog( text = { Text(i18n("conversation.delete.all.dialog.message")) }, - dismissButton = { DialogButton(onClick = { close(); onCancel() }, text = i18n("cancel"), type = NEGATIVE) }, - confirmButton = { DialogButton(onClick = { close(); onDelete() }, text = i18n("delete"), type = POSITIVE) }, + dismissButton = { DialogButton(onClick = { close(); onCancel() }, text = i18n("cancel"), type = NEUTRAL) }, + confirmButton = { DialogButton(onClick = { close(); onDelete() }, text = i18n("delete"), type = DESTRUCTIVE) }, ) } @@ -160,7 +162,7 @@ fun DeleteAllMessagesFailedDialog( text = { Text(message) }, - confirmButton = { DialogButton(onClick = close, text = i18n("ok"), type = POSITIVE) }, + confirmButton = { DialogButton(onClick = close, text = i18n("ok"), type = NEUTRAL) }, ) } @@ -185,10 +187,13 @@ fun ChangeAliasDialog( ) }, text = { - TextField(alias, setAlias) + Column { + Spacer(modifier = Modifier.height(80.dp)) + TextField(alias, setAlias) + } }, - dismissButton = { DialogButton(onClick = { close(); onCancel() }, text = i18n("cancel"), type = NEGATIVE) }, - confirmButton = { DialogButton(onClick = { close(); onConfirm() }, text = i18n("change"), type = POSITIVE) }, + dismissButton = { DialogButton(onClick = { close(); onCancel() }, text = i18n("cancel"), type = NEUTRAL) }, + confirmButton = { DialogButton(onClick = { close(); onConfirm() }, text = i18n("change"), type = NEUTRAL) }, ) } @@ -213,7 +218,7 @@ fun DeleteContactConfirmationDialog( text = { Text(i18n("conversation.delete.contact.dialog.message")) }, - dismissButton = { DialogButton(onClick = { close(); onCancel() }, text = i18n("cancel"), type = NEGATIVE) }, - confirmButton = { DialogButton(onClick = { close(); onDelete() }, text = i18n("delete"), type = POSITIVE) }, + dismissButton = { DialogButton(onClick = { close(); onCancel() }, text = i18n("cancel"), type = NEUTRAL) }, + confirmButton = { DialogButton(onClick = { close(); onDelete() }, text = i18n("delete"), type = DESTRUCTIVE) }, ) } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt index 6ffd124281..00e448f28c 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt @@ -27,8 +27,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.material.ButtonType.NEGATIVE -import androidx.compose.material.ButtonType.POSITIVE +import androidx.compose.material.ButtonType.DESTRUCTIVE +import androidx.compose.material.ButtonType.NEUTRAL import androidx.compose.material.DialogButton import androidx.compose.material.MaterialTheme import androidx.compose.material.Text @@ -122,10 +122,10 @@ fun ConversationRequestItemView( Row(modifier = Modifier.align(statusAlignment)) { if (!m.answered) { - DialogButton(onClick = { onResponse(false) }, text = i18n("decline"), type = NEGATIVE) - DialogButton(onClick = { onResponse(false) }, text = i18n("accept"), type = POSITIVE) + DialogButton(onClick = { onResponse(false) }, text = i18n("decline"), type = DESTRUCTIVE) + DialogButton(onClick = { onResponse(false) }, text = i18n("accept"), type = NEUTRAL) } else if (m.canBeOpened) { - DialogButton(onClick = onOpenRequestedShareable, text = i18n("open"), type = POSITIVE) + DialogButton(onClick = onOpenRequestedShareable, text = i18n("open"), type = NEUTRAL) } else { Spacer(Modifier.height(8.dp)) } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/login/LoginScreen.kt b/src/main/kotlin/org/briarproject/briar/desktop/login/LoginScreen.kt index 4d9b4cea0d..f1413a50ad 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/login/LoginScreen.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/login/LoginScreen.kt @@ -22,8 +22,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.AlertDialog -import androidx.compose.material.ButtonType.NEGATIVE -import androidx.compose.material.ButtonType.POSITIVE +import androidx.compose.material.ButtonType.DESTRUCTIVE +import androidx.compose.material.ButtonType.NEUTRAL import androidx.compose.material.DialogButton import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.OutlinedTextField @@ -91,7 +91,7 @@ fun LoginScreen( DialogButton( onClick = viewHolder::closeDecryptionFailedDialog, text = i18n("ok"), - type = POSITIVE + type = NEUTRAL ) }, ) @@ -133,10 +133,10 @@ fun LoginForm( title = { Text(i18n("startup.password_forgotten.title")) }, text = { Text(i18n("startup.password_forgotten.text")) }, dismissButton = { - DialogButton(onClick = closeDialog, text = i18n("cancel"), type = NEGATIVE) + DialogButton(onClick = closeDialog, text = i18n("cancel"), type = NEUTRAL) }, confirmButton = { - DialogButton(onClick = { deleteAccount(); closeDialog() }, text = i18n("delete"), type = POSITIVE) + DialogButton(onClick = { deleteAccount(); closeDialog() }, text = i18n("delete"), type = DESTRUCTIVE) }, modifier = Modifier.width(500.dp) ) -- GitLab