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