mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-02 20:15:49 +01:00
Add RegV5 confirm PIN UI.
This commit is contained in:
committed by
Michelle Tang
parent
e6e6075c9b
commit
e8785218a5
+55
-27
@@ -122,6 +122,7 @@ private fun OnePaneLayout(
|
||||
.padding(params.panePadding(hasHeader = false))
|
||||
) {
|
||||
PinDescription(
|
||||
isConfirmEnabled = state.isConfirmEnabled,
|
||||
onLearnMore = { onEvent(PinCreationScreenEvents.LearnMore) }
|
||||
)
|
||||
|
||||
@@ -182,6 +183,7 @@ private fun TwoPaneLayout(
|
||||
.padding(paddingValues)
|
||||
) {
|
||||
PinDescription(
|
||||
isConfirmEnabled = state.isConfirmEnabled,
|
||||
onLearnMore = { onEvent(PinCreationScreenEvents.LearnMore) }
|
||||
)
|
||||
}
|
||||
@@ -226,12 +228,16 @@ private fun TwoPaneLayout(
|
||||
|
||||
@Composable
|
||||
private fun PinDescription(
|
||||
isConfirmEnabled: Boolean,
|
||||
onLearnMore: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(modifier = modifier) {
|
||||
Text(
|
||||
text = stringResource(R.string.PinCreationScreen__create_your_pin),
|
||||
text = when {
|
||||
isConfirmEnabled -> stringResource(R.string.PinCreationScreen__confirm_your_pin)
|
||||
else -> stringResource(R.string.PinCreationScreen__create_your_pin)
|
||||
},
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
textAlign = TextAlign.Start,
|
||||
modifier = Modifier
|
||||
@@ -241,34 +247,45 @@ private fun PinDescription(
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
val descriptionText = buildAnnotatedString {
|
||||
append(stringResource(R.string.PinCreationScreen__pins_can_help))
|
||||
append(" ")
|
||||
pushStringAnnotation(tag = "LEARN_MORE", annotation = "learn_more")
|
||||
withStyle(
|
||||
style = SpanStyle(
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
textDecoration = TextDecoration.Underline
|
||||
)
|
||||
) {
|
||||
append(stringResource(R.string.PinCreationScreen__learn_more))
|
||||
if (isConfirmEnabled) {
|
||||
Text(
|
||||
text = stringResource(R.string.PinCreationScreen__reenter_pin_description),
|
||||
style = MaterialTheme.typography.bodyLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Start
|
||||
),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
} else {
|
||||
val descriptionText = buildAnnotatedString {
|
||||
append(stringResource(R.string.PinCreationScreen__pins_can_help))
|
||||
append(" ")
|
||||
pushStringAnnotation(tag = "LEARN_MORE", annotation = "learn_more")
|
||||
withStyle(
|
||||
style = SpanStyle(
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
textDecoration = TextDecoration.Underline
|
||||
)
|
||||
) {
|
||||
append(stringResource(R.string.PinCreationScreen__learn_more))
|
||||
}
|
||||
pop()
|
||||
}
|
||||
pop()
|
||||
}
|
||||
|
||||
ClickableText(
|
||||
text = descriptionText,
|
||||
style = MaterialTheme.typography.bodyLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Start
|
||||
),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = { offset ->
|
||||
descriptionText.getStringAnnotations(tag = "LEARN_MORE", start = offset, end = offset)
|
||||
.firstOrNull()
|
||||
?.let { onLearnMore() }
|
||||
}
|
||||
)
|
||||
ClickableText(
|
||||
text = descriptionText,
|
||||
style = MaterialTheme.typography.bodyLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Start
|
||||
),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onClick = { offset ->
|
||||
descriptionText.getStringAnnotations(tag = "LEARN_MORE", start = offset, end = offset)
|
||||
.firstOrNull()
|
||||
?.let { onLearnMore() }
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,3 +407,14 @@ private fun PinCreationScreenAlphanumericPreview() {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@AllDevicePreviews
|
||||
@Composable
|
||||
private fun PinCreationScreenConfirmPreview() {
|
||||
Previews.Preview {
|
||||
PinCreationScreen(
|
||||
state = PinCreationState(isConfirmEnabled = true),
|
||||
onEvent = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,6 +313,10 @@
|
||||
|
||||
<!-- PIN creation screen title. -->
|
||||
<string name="PinCreationScreen__create_your_pin">Create your PIN</string>
|
||||
<!-- PIN creation screen title when confirming the new Signal PIN. -->
|
||||
<string name="PinCreationScreen__confirm_your_pin">Confirm your PIN</string>
|
||||
<!-- Describes how to confirm the new Signal PIN. -->
|
||||
<string name="PinCreationScreen__reenter_pin_description">Re-enter the PIN you just created</string>
|
||||
<!-- Describes the purpose of creating a Signal PIN. -->
|
||||
<string name="PinCreationScreen__pins_can_help">PINs can help you restore your account if you lose your phone. </string>
|
||||
<!-- Labels the button to learn more about Signal PINs. -->
|
||||
|
||||
Reference in New Issue
Block a user