SetupPinEvents -> SetupPinEvent
This commit is contained in:
parent
90918cbb9d
commit
668b03f8bc
5 changed files with 12 additions and 12 deletions
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
package io.element.android.features.lockscreen.impl.setup.pin
|
||||
|
||||
sealed interface SetupPinEvents {
|
||||
data class OnPinEntryChanged(val entryAsText: String, val fromConfirmationStep: Boolean) : SetupPinEvents
|
||||
data object ClearFailure : SetupPinEvents
|
||||
sealed interface SetupPinEvent {
|
||||
data class OnPinEntryChanged(val entryAsText: String, val fromConfirmationStep: Boolean) : SetupPinEvent
|
||||
data object ClearFailure : SetupPinEvent
|
||||
}
|
||||
|
|
@ -74,9 +74,9 @@ class SetupPinPresenter(
|
|||
}
|
||||
}
|
||||
|
||||
fun handleEvent(event: SetupPinEvents) {
|
||||
fun handleEvent(event: SetupPinEvent) {
|
||||
when (event) {
|
||||
is SetupPinEvents.OnPinEntryChanged -> {
|
||||
is SetupPinEvent.OnPinEntryChanged -> {
|
||||
// Use the fromConfirmationStep flag from ui to avoid race condition.
|
||||
if (event.fromConfirmationStep) {
|
||||
confirmPinEntry = confirmPinEntry.fillWith(event.entryAsText)
|
||||
|
|
@ -84,7 +84,7 @@ class SetupPinPresenter(
|
|||
choosePinEntry = choosePinEntry.fillWith(event.entryAsText)
|
||||
}
|
||||
}
|
||||
SetupPinEvents.ClearFailure -> {
|
||||
SetupPinEvent.ClearFailure -> {
|
||||
when (setupPinFailure) {
|
||||
is SetupPinFailure.PinsDoNotMatch -> {
|
||||
choosePinEntry = choosePinEntry.clear()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ data class SetupPinState(
|
|||
val isConfirmationStep: Boolean,
|
||||
val setupPinFailure: SetupPinFailure?,
|
||||
val appName: String,
|
||||
val eventSink: (SetupPinEvents) -> Unit
|
||||
val eventSink: (SetupPinEvent) -> Unit
|
||||
) {
|
||||
val activePinEntry = if (isConfirmationStep) {
|
||||
confirmPinEntry
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ private fun SetupPinContent(
|
|||
pinEntry = state.activePinEntry,
|
||||
isSecured = true,
|
||||
onValueChange = { entry ->
|
||||
state.eventSink(SetupPinEvents.OnPinEntryChanged(entry, state.isConfirmationStep))
|
||||
state.eventSink(SetupPinEvent.OnPinEntryChanged(entry, state.isConfirmationStep))
|
||||
},
|
||||
modifier = Modifier
|
||||
.focusRequester(focusRequester)
|
||||
|
|
@ -119,7 +119,7 @@ private fun SetupPinContent(
|
|||
title = state.setupPinFailure.title(),
|
||||
content = state.setupPinFailure.content(),
|
||||
onSubmit = {
|
||||
state.eventSink(SetupPinEvents.ClearFailure)
|
||||
state.eventSink(SetupPinEvent.ClearFailure)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class SetupPinPresenterTest {
|
|||
awaitLastSequentialItem().also { state ->
|
||||
state.choosePinEntry.assertText(forbiddenPin)
|
||||
assertThat(state.setupPinFailure).isEqualTo(SetupPinFailure.ForbiddenPin)
|
||||
state.eventSink(SetupPinEvents.ClearFailure)
|
||||
state.eventSink(SetupPinEvent.ClearFailure)
|
||||
}
|
||||
awaitLastSequentialItem().also { state ->
|
||||
state.choosePinEntry.assertEmpty()
|
||||
|
|
@ -78,7 +78,7 @@ class SetupPinPresenterTest {
|
|||
state.choosePinEntry.assertText(completePin)
|
||||
state.confirmPinEntry.assertText(mismatchedPin)
|
||||
assertThat(state.setupPinFailure).isEqualTo(SetupPinFailure.PinsDoNotMatch)
|
||||
state.eventSink(SetupPinEvents.ClearFailure)
|
||||
state.eventSink(SetupPinEvent.ClearFailure)
|
||||
}
|
||||
awaitLastSequentialItem().also { state ->
|
||||
state.choosePinEntry.assertEmpty()
|
||||
|
|
@ -104,7 +104,7 @@ class SetupPinPresenterTest {
|
|||
}
|
||||
|
||||
private fun SetupPinState.onPinEntryChanged(pinEntry: String) {
|
||||
eventSink(SetupPinEvents.OnPinEntryChanged(pinEntry, isConfirmationStep))
|
||||
eventSink(SetupPinEvent.OnPinEntryChanged(pinEntry, isConfirmationStep))
|
||||
}
|
||||
|
||||
private fun createSetupPinPresenter(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue