Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update access factor sources strings #890

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,18 @@ import rdx.works.profile.data.model.factorsources.FactorSource
import rdx.works.profile.data.model.factorsources.LedgerHardwareWalletFactorSource
import rdx.works.profile.data.model.pernetwork.SigningPurpose

@Deprecated("It will be removed once refactoring of access factor sources is complete.")
sealed class InteractionState(val factorSource: FactorSource) {

abstract val label: String

sealed class Device(private val deviceFactorSource: DeviceFactorSource) : InteractionState(deviceFactorSource) {

data class DerivingAccounts(private val deviceFactorSource: DeviceFactorSource) : Device(deviceFactorSource)

data class Pending(
private val deviceFactorSource: DeviceFactorSource,
val signingPurpose: SigningPurpose = SigningPurpose.SignTransaction
) : Device(deviceFactorSource)

data class Success(
private val deviceFactorSource: DeviceFactorSource,
val signingPurpose: SigningPurpose = SigningPurpose.SignTransaction
) : Device(deviceFactorSource)

override val label: String
get() = deviceFactorSource.hint.name
}
Expand All @@ -33,18 +27,12 @@ sealed class InteractionState(val factorSource: FactorSource) {
) : InteractionState(ledgerFactorSource) {

data class DerivingPublicKey(val ledgerFactorSource: LedgerHardwareWalletFactorSource) : Ledger(ledgerFactorSource)
data class DerivingAccounts(val ledgerFactorSource: LedgerHardwareWalletFactorSource) : Ledger(ledgerFactorSource)

data class Pending(
val ledgerFactorSource: LedgerHardwareWalletFactorSource,
val signingPurpose: SigningPurpose = SigningPurpose.SignTransaction
) : Ledger(ledgerFactorSource)

data class Success(
val ledgerFactorSource: LedgerHardwareWalletFactorSource,
val signingPurpose: SigningPurpose = SigningPurpose.SignTransaction
) : Ledger(ledgerFactorSource)

data class Error(
private val ledgerFactorSource: LedgerHardwareWalletFactorSource,
val signingPurpose: SigningPurpose?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ private fun DeriveAccountsBottomSheetContent(
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))
Text(
style = RadixTheme.typography.title,
text = stringResource(id = R.string.accountRecoveryScan_derivingAccounts)
text = stringResource(id = R.string.factorSourceActions_deriveAccounts_title)
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingLarge))
when (showContentForFactorSource) {
ShowContentForFactorSource.Device -> {
Text(
style = RadixTheme.typography.body1Regular,
text = stringResource(id = R.string.derivePublicKeys_subtitleDevice)
text = stringResource(id = R.string.factorSourceActions_device_messageSignature)
)
if (shouldShowRetryButton) {
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingXLarge))
Expand All @@ -130,7 +130,7 @@ private fun DeriveAccountsBottomSheetContent(
is ShowContentForFactorSource.Ledger -> {
Text(
style = RadixTheme.typography.body1Regular,
text = stringResource(id = R.string.derivePublicKeys_subtitleLedger)
text = stringResource(id = R.string.factorSourceActions_ledger_messageDeriveAccounts)
.formattedSpans(SpanStyle(fontWeight = FontWeight.Bold))
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingXXLarge))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ private fun DerivePublicKeyBottomSheetContent(
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))
Text(
style = RadixTheme.typography.title,
text = stringResource(id = R.string.derivePublicKeys_titleCreateAccount)
text = stringResource(id = R.string.factorSourceActions_createAccount_title)
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingLarge))
when (showContentForFactorSource) {
DerivePublicKeyUiState.ShowContentForFactorSource.Device -> {
Text(
style = RadixTheme.typography.body1Regular,
text = stringResource(id = R.string.derivePublicKeys_subtitleDevice)
text = stringResource(id = R.string.factorSourceActions_device_messageSignature)
)
if (shouldShowRetryButton) {
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingXLarge))
Expand All @@ -126,7 +126,7 @@ private fun DerivePublicKeyBottomSheetContent(
is DerivePublicKeyUiState.ShowContentForFactorSource.Ledger -> {
Text(
style = RadixTheme.typography.body1Regular,
text = stringResource(id = R.string.derivePublicKeys_subtitleLedger)
text = stringResource(id = R.string.factorSourceActions_ledger_messageDeriveAccounts)
.formattedSpans(SpanStyle(fontWeight = FontWeight.Bold))
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingXXLarge))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
Expand All @@ -28,7 +24,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.babylon.wallet.android.data.transaction.InteractionState
import com.babylon.wallet.android.designsystem.R
import com.babylon.wallet.android.designsystem.theme.GradientBrand2
import com.babylon.wallet.android.designsystem.theme.RadixTheme
import com.babylon.wallet.android.designsystem.theme.RadixWalletTheme
import com.babylon.wallet.android.presentation.ui.composables.BottomSheetDialogWrapper
Expand Down Expand Up @@ -64,17 +59,11 @@ fun FactorSourceInteractionBottomDialogContent(
interactionState: InteractionState?
) {
when (interactionState) {
is InteractionState.Ledger.Success,
is InteractionState.Device.Success -> {
SignatureSuccessfulContent(modifier = modifier)
}

is InteractionState.Ledger.DerivingPublicKey,
is InteractionState.Ledger.Pending,
is InteractionState.Device.DerivingAccounts,
is InteractionState.Device.Pending -> {
SignatureRequestContent(interactionState, modifier)
}

else -> {}
}
}
Expand Down Expand Up @@ -103,18 +92,11 @@ private fun SignatureRequestContent(
)
val title = stringResource(
id = when (interactionState) {
is InteractionState.Ledger.DerivingPublicKey -> {
com.babylon.wallet.android.R.string.signing_signatureRequest_title
}

is InteractionState.Ledger -> {
com.babylon.wallet.android.R.string.signing_signatureRequest_title
}
is InteractionState.Device.DerivingAccounts -> {
com.babylon.wallet.android.R.string.accountRecoveryScan_derivingAccounts
com.babylon.wallet.android.R.string.factorSourceActions_signature_title
}

is InteractionState.Device -> com.babylon.wallet.android.R.string.signing_signatureRequest_title
is InteractionState.Device -> com.babylon.wallet.android.R.string.factorSourceActions_signature_title
else -> com.babylon.wallet.android.R.string.empty
}
)
Expand All @@ -125,23 +107,12 @@ private fun SignatureRequestContent(
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))
val subtitle = when (interactionState) {
is InteractionState.Device.Success -> {
stringResource(id = signingPurposeDescription(interactionState.signingPurpose))
}

is InteractionState.Device.Pending -> {
stringResource(id = signingPurposeDescription(interactionState.signingPurpose))
}

is InteractionState.Ledger.Success,
is InteractionState.Ledger.Pending -> {
stringResource(id = com.babylon.wallet.android.R.string.signing_signatureRequest_body)
}
is InteractionState.Ledger.DerivingAccounts -> {
stringResource(id = com.babylon.wallet.android.R.string.signing_signatureRequest_body)
}
is InteractionState.Device.DerivingAccounts -> {
"Authenticate to your phone to complete using your phone’s signing key."
stringResource(id = com.babylon.wallet.android.R.string.factorSourceActions_ledger_messageSignature)
}

else -> null
Expand Down Expand Up @@ -185,52 +156,9 @@ private fun SignatureRequestContent(
private fun signingPurposeDescription(signingPurpose: SigningPurpose) =
when (signingPurpose) {
SigningPurpose.SignAuth -> com.babylon.wallet.android.R.string.empty
SigningPurpose.SignTransaction -> com.babylon.wallet.android.R.string.signing_withDeviceFactorSource_signTransaction
SigningPurpose.SignTransaction -> com.babylon.wallet.android.R.string.factorSourceActions_device_messageSignature
}

@Composable
private fun SignatureSuccessfulContent(
modifier: Modifier = Modifier
) {
Column(
modifier
.fillMaxWidth()
.background(color = RadixTheme.colors.defaultBackground)
.padding(RadixTheme.dimensions.paddingLarge),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(RadixTheme.dimensions.paddingDefault)
) {
Icon(
modifier = Modifier
.size(80.dp)
.graphicsLayer { compositingStrategy = CompositingStrategy.Offscreen }
.drawWithCache {
onDrawWithContent {
drawContent()
drawRect(GradientBrand2, blendMode = BlendMode.SrcAtop)
}
},
painter = painterResource(
id = R.drawable.ic_security_key
),
contentDescription = null
)
Text(
text = stringResource(com.babylon.wallet.android.R.string.signing_signatureSuccessful_title),
style = RadixTheme.typography.title,
color = RadixTheme.colors.gray1
)
Spacer(modifier = Modifier.height(RadixTheme.dimensions.paddingDefault))
Text(
text = stringResource(id = com.babylon.wallet.android.R.string.signing_signatureSuccessful_body),
style = RadixTheme.typography.body1Regular,
color = RadixTheme.colors.gray1,
textAlign = TextAlign.Center
)
Spacer(Modifier.height(36.dp))
}
}

@Preview(showBackground = true)
@Composable
fun SignatureRequestContentPreview() {
Expand All @@ -246,11 +174,3 @@ fun SignatureRequestContentPreview() {
)
}
}

@Preview(showBackground = true)
@Composable
fun SignatureSuccessfulContentPreview() {
RadixWalletTheme {
SignatureSuccessfulContent()
}
}
Loading