Replace custom Text usage in shared components with String (#212)

This commit is contained in:
Brian Yencho 2023-11-06 12:48:00 -06:00 committed by Álison Fernandes
parent e066c885a9
commit c67fa04d1c
9 changed files with 41 additions and 48 deletions

View file

@ -136,10 +136,10 @@ fun CreateAccountScreen(
CreateAccountDialog.HaveIBeenPwned -> {
BitwardenTwoButtonDialog(
title = R.string.weak_and_exposed_master_password.asText(),
message = haveIBeenPwnedMessage,
confirmButtonText = R.string.yes.asText(),
dismissButtonText = R.string.no.asText(),
title = stringResource(id = R.string.weak_and_exposed_master_password),
message = haveIBeenPwnedMessage(),
confirmButtonText = stringResource(id = R.string.yes),
dismissButtonText = stringResource(id = R.string.no),
onConfirmClick = remember(viewModel) {
{ viewModel.trySendAction(ContinueWithBreachedPasswordClick) }
},

View file

@ -42,7 +42,6 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.data.platform.repository.model.Environment
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.BitwardenBasicDialog
import com.x8bit.bitwarden.ui.platform.components.BitwardenFilledButton
import com.x8bit.bitwarden.ui.platform.components.BitwardenSelectionDialog
@ -261,7 +260,7 @@ private fun EnvironmentSelector(
if (shouldShowDialog) {
BitwardenSelectionDialog(
title = R.string.logging_in_on.asText(),
title = stringResource(id = R.string.logging_in_on),
onDismissRequest = { shouldShowDialog = false },
) {
options.forEach {

View file

@ -2,20 +2,17 @@ package com.x8bit.bitwarden.ui.platform.components
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.Text
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
/**
* Represents a row of text that can be clicked on and contains an external link.
*
* @param text The label for the row as a [Text].
* @param text The label for the row as a [String].
* @param onClick The callback when the row is clicked.
* @param modifier The modifier to be applied to the layout.
* @param withDivider Indicates if a divider should be drawn on the bottom of the row, defaults
@ -23,7 +20,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
*/
@Composable
fun BitwardenExternalLinkRow(
text: Text,
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
withDivider: Boolean = true,
@ -47,7 +44,7 @@ fun BitwardenExternalLinkRow(
private fun BitwardenExternalLinkRow_preview() {
BitwardenTheme {
BitwardenExternalLinkRow(
text = "Linked Text".asText(),
text = "Linked Text",
onClick = { },
)
}

View file

@ -97,7 +97,7 @@ fun BitwardenMultiSelectButton(
)
if (shouldShowDialog) {
BitwardenSelectionDialog(
title = label.asText(),
title = label,
onDismissRequest = { shouldShowDialog = false },
) {
options.forEach { optionString ->

View file

@ -31,7 +31,7 @@ import com.x8bit.bitwarden.ui.platform.base.util.Text
*/
@Composable
fun BitwardenSelectionDialog(
title: Text,
title: String,
onDismissRequest: () -> Unit,
selectionItems: @Composable ColumnScope.() -> Unit = {},
) {
@ -50,7 +50,7 @@ fun BitwardenSelectionDialog(
modifier = Modifier
.padding(24.dp)
.fillMaxWidth(),
text = title(),
text = title,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.headlineSmall,
)

View file

@ -18,13 +18,12 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.ui.platform.base.util.Text
/**
* Represents a clickable row of text and can contains an optional [content] that appears to the
* right of the [text].
*
* @param text The label for the row as a [Text].
* @param text The label for the row as a [String].
* @param onClick The callback when the row is clicked.
* @param modifier The modifier to be applied to the layout.
* @param withDivider Indicates if a divider should be drawn on the bottom of the row, defaults
@ -33,7 +32,7 @@ import com.x8bit.bitwarden.ui.platform.base.util.Text
*/
@Composable
fun BitwardenTextRow(
text: Text,
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
withDivider: Boolean = false,
@ -61,7 +60,7 @@ fun BitwardenTextRow(
modifier = Modifier
.padding(end = 16.dp)
.weight(1f),
text = text(),
text = text,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
)

View file

@ -4,10 +4,9 @@ import androidx.compose.material3.AlertDialog
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import com.x8bit.bitwarden.ui.platform.base.util.Text
/**
* Represents a Bitwarden-styled dialog that is hidden or shown based on [visibilityState].
* Represents a Bitwarden-styled dialog with two buttons.
*
* @param title title to show.
* @param message message to show.
@ -20,10 +19,10 @@ import com.x8bit.bitwarden.ui.platform.base.util.Text
*/
@Composable
fun BitwardenTwoButtonDialog(
title: Text,
message: Text,
confirmButtonText: Text,
dismissButtonText: Text,
title: String,
message: String,
confirmButtonText: String,
dismissButtonText: String,
onConfirmClick: () -> Unit,
onDismissClick: () -> Unit,
onDismissRequest: () -> Unit,
@ -32,26 +31,26 @@ fun BitwardenTwoButtonDialog(
onDismissRequest = onDismissRequest,
dismissButton = {
BitwardenTextButton(
label = dismissButtonText(),
label = dismissButtonText,
onClick = onDismissClick,
)
},
confirmButton = {
BitwardenTextButton(
label = confirmButtonText(),
label = confirmButtonText,
onClick = onConfirmClick,
)
},
title = {
Text(
text = title(),
text = title,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.headlineSmall,
)
},
text = {
Text(
text = message(),
text = message,
color = MaterialTheme.colorScheme.onSurfaceVariant,
style = MaterialTheme.typography.bodyMedium,
)

View file

@ -167,19 +167,19 @@ private fun ContentColum(
)
Spacer(modifier = Modifier.height(16.dp))
BitwardenExternalLinkRow(
text = R.string.bitwarden_help_center.asText(),
text = stringResource(id = R.string.bitwarden_help_center),
onClick = onHelpCenterClick,
)
BitwardenExternalLinkRow(
text = R.string.web_vault.asText(),
text = stringResource(id = R.string.web_vault),
onClick = onWebVaultClick,
)
BitwardenExternalLinkRow(
text = R.string.learn_org.asText(),
text = stringResource(id = R.string.learn_org),
onClick = onLearnAboutOrgsClick,
)
BitwardenExternalLinkRow(
text = R.string.rate_the_app.asText(),
text = stringResource(id = R.string.rate_the_app),
onClick = onRateTheAppClick,
)
CopyRow(

View file

@ -33,7 +33,6 @@ import com.x8bit.bitwarden.R
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
import com.x8bit.bitwarden.ui.platform.base.util.IntentHandler
import com.x8bit.bitwarden.ui.platform.base.util.Text
import com.x8bit.bitwarden.ui.platform.base.util.asText
import com.x8bit.bitwarden.ui.platform.components.BitwardenExternalLinkRow
import com.x8bit.bitwarden.ui.platform.components.BitwardenListHeaderText
import com.x8bit.bitwarden.ui.platform.components.BitwardenSelectionDialog
@ -149,7 +148,7 @@ fun AccountSecurityScreen(
.padding(horizontal = 16.dp),
)
BitwardenTextRow(
text = R.string.pending_log_in_requests.asText(),
text = stringResource(id = R.string.pending_log_in_requests),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.PendingLoginRequestsClick) }
},
@ -199,7 +198,7 @@ fun AccountSecurityScreen(
.padding(horizontal = 16.dp),
)
BitwardenTextRow(
text = R.string.session_timeout.asText(),
text = stringResource(id = R.string.session_timeout),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.SessionTimeoutClick) }
},
@ -212,7 +211,7 @@ fun AccountSecurityScreen(
)
}
BitwardenTextRow(
text = R.string.session_timeout_action.asText(),
text = stringResource(id = R.string.session_timeout_action),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.SessionTimeoutActionClick) }
},
@ -233,14 +232,14 @@ fun AccountSecurityScreen(
.padding(horizontal = 16.dp),
)
BitwardenTextRow(
text = R.string.account_fingerprint_phrase.asText(),
text = stringResource(id = R.string.account_fingerprint_phrase),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.AccountFingerprintPhraseClick) }
},
modifier = Modifier.fillMaxWidth(),
)
BitwardenExternalLinkRow(
text = R.string.two_step_login.asText(),
text = stringResource(id = R.string.two_step_login),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.TwoStepLoginClick) }
},
@ -248,7 +247,7 @@ fun AccountSecurityScreen(
modifier = Modifier.fillMaxWidth(),
)
BitwardenExternalLinkRow(
text = R.string.change_master_password.asText(),
text = stringResource(id = R.string.change_master_password),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.ChangeMasterPasswordClick) }
},
@ -256,21 +255,21 @@ fun AccountSecurityScreen(
modifier = Modifier.fillMaxWidth(),
)
BitwardenTextRow(
text = R.string.lock_now.asText(),
text = stringResource(id = R.string.lock_now),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.LockNowClick) }
},
modifier = Modifier.fillMaxWidth(),
)
BitwardenTextRow(
text = R.string.log_out.asText(),
text = stringResource(id = R.string.log_out),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.LogoutClick) }
},
modifier = Modifier.fillMaxWidth(),
)
BitwardenTextRow(
text = R.string.delete_account.asText(),
text = stringResource(id = R.string.delete_account),
onClick = remember(viewModel) {
{ viewModel.trySendAction(AccountSecurityAction.DeleteAccountClick) }
},
@ -286,11 +285,11 @@ private fun ConfirmLogoutDialog(
onConfirmClick: () -> Unit,
) {
BitwardenTwoButtonDialog(
title = R.string.log_out.asText(),
message = R.string.logout_confirmation.asText(),
confirmButtonText = R.string.yes.asText(),
title = stringResource(id = R.string.log_out),
message = stringResource(id = R.string.logout_confirmation),
confirmButtonText = stringResource(id = R.string.yes),
onConfirmClick = onConfirmClick,
dismissButtonText = R.string.cancel.asText(),
dismissButtonText = stringResource(id = R.string.cancel),
onDismissClick = onDismiss,
onDismissRequest = onDismiss,
)
@ -352,7 +351,7 @@ private fun SessionTimeoutActionDialog(
onActionSelect: (SessionTimeoutAction) -> Unit,
) {
BitwardenSelectionDialog(
title = R.string.vault_timeout_action.asText(),
title = stringResource(id = R.string.vault_timeout_action),
onDismissRequest = onDismissRequest,
) {
SessionTimeoutAction.values().forEach { option ->