SetupPinEvents -> SetupPinEvent
This commit is contained in:
committed by
Benoit Marty
parent
90918cbb9d
commit
668b03f8bc
+3
-3
@@ -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
|
||||
}
|
||||
+3
-3
@@ -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()
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+2
-2
@@ -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)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
+3
-3
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user