Remove or replace unnecessary BackHandler calls (#4148)
* Remove/replace `BackHandler` calls: - For `UserProfileView`, remove the redundant `BackHandler` -> `navigateUp()` call. - For `SetupBiometricView`, remove the `enabled = true` parameter, as this is the default value.
This commit is contained in:
parent
9946bf29fd
commit
6bfd28b1d8
5 changed files with 5 additions and 21 deletions
|
|
@ -31,7 +31,7 @@ fun SetupBiometricView(
|
||||||
state: SetupBiometricState,
|
state: SetupBiometricState,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
BackHandler(true) {
|
BackHandler {
|
||||||
state.eventSink(SetupBiometricEvents.UsePin)
|
state.eventSink(SetupBiometricEvents.UsePin)
|
||||||
}
|
}
|
||||||
HeaderFooterPage(
|
HeaderFooterPage(
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,8 @@ fun QrCodeConfirmationView(
|
||||||
onCancel: () -> Unit,
|
onCancel: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
BackHandler {
|
BackHandler(onBack = onCancel)
|
||||||
onCancel()
|
|
||||||
}
|
|
||||||
val icon = when (step) {
|
val icon = when (step) {
|
||||||
is QrCodeConfirmationStep.DisplayCheckCode -> CompoundIcons.Computer()
|
is QrCodeConfirmationStep.DisplayCheckCode -> CompoundIcons.Computer()
|
||||||
is QrCodeConfirmationStep.DisplayVerificationCode -> CompoundIcons.LockSolid()
|
is QrCodeConfirmationStep.DisplayVerificationCode -> CompoundIcons.LockSolid()
|
||||||
|
|
|
||||||
|
|
@ -45,16 +45,14 @@ fun QrCodeErrorView(
|
||||||
onRetry: () -> Unit,
|
onRetry: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
BackHandler {
|
BackHandler(onBack = onRetry)
|
||||||
onRetry()
|
|
||||||
}
|
|
||||||
FlowStepPage(
|
FlowStepPage(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
iconStyle = BigIcon.Style.AlertSolid,
|
iconStyle = BigIcon.Style.AlertSolid,
|
||||||
title = titleText(errorScreenType, appName),
|
title = titleText(errorScreenType, appName),
|
||||||
subTitle = subtitleText(errorScreenType, appName),
|
subTitle = subtitleText(errorScreenType, appName),
|
||||||
content = { Content(errorScreenType) },
|
content = { Content(errorScreenType) },
|
||||||
buttons = { Buttons(onRetry) }
|
buttons = { Buttons(onRetry) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
package io.element.android.features.userprofile.shared
|
package io.element.android.features.userprofile.shared
|
||||||
|
|
||||||
import androidx.activity.compose.BackHandler
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
|
|
@ -51,7 +50,6 @@ fun UserProfileView(
|
||||||
openAvatarPreview: (username: String, url: String) -> Unit,
|
openAvatarPreview: (username: String, url: String) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
BackHandler { goBack() }
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
topBar = {
|
topBar = {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ import io.element.android.tests.testutils.ensureCalledOnce
|
||||||
import io.element.android.tests.testutils.ensureCalledOnceWithParam
|
import io.element.android.tests.testutils.ensureCalledOnceWithParam
|
||||||
import io.element.android.tests.testutils.ensureCalledOnceWithTwoParams
|
import io.element.android.tests.testutils.ensureCalledOnceWithTwoParams
|
||||||
import io.element.android.tests.testutils.pressBack
|
import io.element.android.tests.testutils.pressBack
|
||||||
import io.element.android.tests.testutils.pressBackKey
|
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -46,16 +45,6 @@ import org.robolectric.annotation.Config
|
||||||
class UserProfileViewTest {
|
class UserProfileViewTest {
|
||||||
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `on back key press - the expected callback is called`() = runTest {
|
|
||||||
ensureCalledOnce { callback ->
|
|
||||||
rule.setUserProfileView(
|
|
||||||
goBack = callback,
|
|
||||||
)
|
|
||||||
rule.pressBackKey()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `on back button click - the expected callback is called`() = runTest {
|
fun `on back button click - the expected callback is called`() = runTest {
|
||||||
ensureCalledOnce { callback ->
|
ensureCalledOnce { callback ->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue