Enter recovery key: add Done ime action.
This commit is contained in:
parent
8152acfcde
commit
ddd9ca40fc
3 changed files with 27 additions and 4 deletions
|
|
@ -75,6 +75,9 @@ fun SecureBackupEnterRecoveryKeyView(
|
||||||
state = state,
|
state = state,
|
||||||
onChange = {
|
onChange = {
|
||||||
state.eventSink.invoke(SecureBackupEnterRecoveryKeyEvents.OnRecoveryKeyChange(it))
|
state.eventSink.invoke(SecureBackupEnterRecoveryKeyEvents.OnRecoveryKeyChange(it))
|
||||||
|
},
|
||||||
|
onSubmit = {
|
||||||
|
state.eventSink.invoke(SecureBackupEnterRecoveryKeyEvents.Submit)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,13 +115,15 @@ private fun BottomMenu(
|
||||||
@Composable
|
@Composable
|
||||||
private fun Content(
|
private fun Content(
|
||||||
state: SecureBackupEnterRecoveryKeyState,
|
state: SecureBackupEnterRecoveryKeyState,
|
||||||
onChange: ((String) -> Unit)?,
|
onChange: (String) -> Unit,
|
||||||
|
onSubmit: () -> Unit,
|
||||||
) {
|
) {
|
||||||
RecoveryKeyView(
|
RecoveryKeyView(
|
||||||
modifier = Modifier.padding(top = 52.dp),
|
modifier = Modifier.padding(top = 52.dp),
|
||||||
state = state.recoveryKeyViewState,
|
state = state.recoveryKeyViewState,
|
||||||
onClick = null,
|
onClick = null,
|
||||||
onChange = onChange,
|
onChange = onChange,
|
||||||
|
onSubmit = onSubmit,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,7 @@ private fun Content(
|
||||||
state = state,
|
state = state,
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
onChange = null,
|
onChange = null,
|
||||||
|
onSubmit = null,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,15 @@ import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.progressSemantics
|
import androidx.compose.foundation.progressSemantics
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.text.KeyboardActions
|
||||||
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
@ -52,6 +55,7 @@ internal fun RecoveryKeyView(
|
||||||
state: RecoveryKeyViewState,
|
state: RecoveryKeyViewState,
|
||||||
onClick: (() -> Unit)?,
|
onClick: (() -> Unit)?,
|
||||||
onChange: ((String) -> Unit)?,
|
onChange: ((String) -> Unit)?,
|
||||||
|
onSubmit: (() -> Unit)?,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
|
|
@ -63,7 +67,7 @@ internal fun RecoveryKeyView(
|
||||||
modifier = Modifier.padding(start = 16.dp),
|
modifier = Modifier.padding(start = 16.dp),
|
||||||
style = ElementTheme.typography.fontBodyMdRegular,
|
style = ElementTheme.typography.fontBodyMdRegular,
|
||||||
)
|
)
|
||||||
RecoveryKeyContent(state, onClick, onChange)
|
RecoveryKeyContent(state, onClick, onChange, onSubmit)
|
||||||
RecoveryKeyFooter(state)
|
RecoveryKeyFooter(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,11 +77,12 @@ private fun RecoveryKeyContent(
|
||||||
state: RecoveryKeyViewState,
|
state: RecoveryKeyViewState,
|
||||||
onClick: (() -> Unit)?,
|
onClick: (() -> Unit)?,
|
||||||
onChange: ((String) -> Unit)?,
|
onChange: ((String) -> Unit)?,
|
||||||
|
onSubmit: (() -> Unit)?,
|
||||||
) {
|
) {
|
||||||
when (state.recoveryKeyUserStory) {
|
when (state.recoveryKeyUserStory) {
|
||||||
RecoveryKeyUserStory.Setup,
|
RecoveryKeyUserStory.Setup,
|
||||||
RecoveryKeyUserStory.Change -> RecoveryKeyStaticContent(state, onClick)
|
RecoveryKeyUserStory.Change -> RecoveryKeyStaticContent(state, onClick)
|
||||||
RecoveryKeyUserStory.Enter -> RecoveryKeyFormContent(state, onChange)
|
RecoveryKeyUserStory.Enter -> RecoveryKeyFormContent(state, onChange, onSubmit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,8 +148,13 @@ private fun RecoveryKeyStaticContent(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RecoveryKeyFormContent(state: RecoveryKeyViewState, onChange: ((String) -> Unit)?) {
|
private fun RecoveryKeyFormContent(
|
||||||
|
state: RecoveryKeyViewState,
|
||||||
|
onChange: ((String) -> Unit)?,
|
||||||
|
onSubmit: (() -> Unit)?,
|
||||||
|
) {
|
||||||
onChange ?: error("onChange should not be null")
|
onChange ?: error("onChange should not be null")
|
||||||
|
onSubmit ?: error("onSubmit should not be null")
|
||||||
val recoveryKeyVisualTransformation = remember {
|
val recoveryKeyVisualTransformation = remember {
|
||||||
RecoveryKeyVisualTransformation()
|
RecoveryKeyVisualTransformation()
|
||||||
}
|
}
|
||||||
|
|
@ -155,6 +165,12 @@ private fun RecoveryKeyFormContent(state: RecoveryKeyViewState, onChange: ((Stri
|
||||||
onValueChange = onChange,
|
onValueChange = onChange,
|
||||||
enabled = state.inProgress.not(),
|
enabled = state.inProgress.not(),
|
||||||
visualTransformation = recoveryKeyVisualTransformation,
|
visualTransformation = recoveryKeyVisualTransformation,
|
||||||
|
keyboardOptions = KeyboardOptions(
|
||||||
|
imeAction = ImeAction.Done,
|
||||||
|
),
|
||||||
|
keyboardActions = KeyboardActions(
|
||||||
|
onDone = { onSubmit() }
|
||||||
|
),
|
||||||
label = { Text(text = stringResource(id = R.string.screen_recovery_key_confirm_key_placeholder)) }
|
label = { Text(text = stringResource(id = R.string.screen_recovery_key_confirm_key_placeholder)) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -217,5 +233,6 @@ internal fun RecoveryKeyViewPreview(
|
||||||
state = state,
|
state = state,
|
||||||
onClick = {},
|
onClick = {},
|
||||||
onChange = {},
|
onChange = {},
|
||||||
|
onSubmit = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue