SetupBiometricEvents -> SetupBiometricEvent
This commit is contained in:
parent
bc60512e10
commit
90918cbb9d
5 changed files with 13 additions and 13 deletions
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
package io.element.android.features.lockscreen.impl.setup.biometric
|
||||
|
||||
sealed interface SetupBiometricEvents {
|
||||
data object AllowBiometric : SetupBiometricEvents
|
||||
data object UsePin : SetupBiometricEvents
|
||||
sealed interface SetupBiometricEvent {
|
||||
data object AllowBiometric : SetupBiometricEvent
|
||||
data object UsePin : SetupBiometricEvent
|
||||
}
|
||||
|
|
@ -35,16 +35,16 @@ class SetupBiometricPresenter(
|
|||
val coroutineScope = rememberCoroutineScope()
|
||||
val biometricUnlock = biometricAuthenticatorManager.rememberConfirmBiometricAuthenticator()
|
||||
|
||||
fun handleEvent(event: SetupBiometricEvents) {
|
||||
fun handleEvent(event: SetupBiometricEvent) {
|
||||
when (event) {
|
||||
SetupBiometricEvents.AllowBiometric -> coroutineScope.launch {
|
||||
SetupBiometricEvent.AllowBiometric -> coroutineScope.launch {
|
||||
biometricUnlock.setup()
|
||||
if (biometricUnlock.authenticate() == BiometricAuthenticator.AuthenticationResult.Success) {
|
||||
lockScreenStore.setIsBiometricUnlockAllowed(true)
|
||||
isBiometricSetupDone = true
|
||||
}
|
||||
}
|
||||
SetupBiometricEvents.UsePin -> coroutineScope.launch {
|
||||
SetupBiometricEvent.UsePin -> coroutineScope.launch {
|
||||
lockScreenStore.setIsBiometricUnlockAllowed(false)
|
||||
isBiometricSetupDone = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ package io.element.android.features.lockscreen.impl.setup.biometric
|
|||
|
||||
data class SetupBiometricState(
|
||||
val isBiometricSetupDone: Boolean,
|
||||
val eventSink: (SetupBiometricEvents) -> Unit
|
||||
val eventSink: (SetupBiometricEvent) -> Unit
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ fun SetupBiometricView(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
BackHandler {
|
||||
state.eventSink(SetupBiometricEvents.UsePin)
|
||||
state.eventSink(SetupBiometricEvent.UsePin)
|
||||
}
|
||||
HeaderFooterPage(
|
||||
modifier = modifier.padding(top = 80.dp),
|
||||
|
|
@ -42,8 +42,8 @@ fun SetupBiometricView(
|
|||
},
|
||||
footer = {
|
||||
SetupBiometricFooter(
|
||||
onAllowClick = { state.eventSink(SetupBiometricEvents.AllowBiometric) },
|
||||
onSkipClick = { state.eventSink(SetupBiometricEvents.UsePin) }
|
||||
onAllowClick = { state.eventSink(SetupBiometricEvent.AllowBiometric) },
|
||||
onSkipClick = { state.eventSink(SetupBiometricEvent.UsePin) }
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class SetupBiometricPresenterTest {
|
|||
presenter.test {
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.isBiometricSetupDone).isFalse()
|
||||
state.eventSink(SetupBiometricEvents.AllowBiometric)
|
||||
state.eventSink(SetupBiometricEvent.AllowBiometric)
|
||||
}
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.isBiometricSetupDone).isTrue()
|
||||
|
|
@ -50,7 +50,7 @@ class SetupBiometricPresenterTest {
|
|||
presenter.test {
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.isBiometricSetupDone).isFalse()
|
||||
state.eventSink(SetupBiometricEvents.AllowBiometric)
|
||||
state.eventSink(SetupBiometricEvent.AllowBiometric)
|
||||
}
|
||||
}
|
||||
assertThat(lockScreenStore.isBiometricUnlockAllowed().first()).isFalse()
|
||||
|
|
@ -63,7 +63,7 @@ class SetupBiometricPresenterTest {
|
|||
presenter.test {
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.isBiometricSetupDone).isFalse()
|
||||
state.eventSink(SetupBiometricEvents.UsePin)
|
||||
state.eventSink(SetupBiometricEvent.UsePin)
|
||||
}
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.isBiometricSetupDone).isTrue()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue