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
f31e648e35
commit
a74a62c090
5 changed files with 5 additions and 21 deletions
|
|
@ -31,7 +31,7 @@ fun SetupBiometricView(
|
|||
state: SetupBiometricState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
BackHandler(true) {
|
||||
BackHandler {
|
||||
state.eventSink(SetupBiometricEvents.UsePin)
|
||||
}
|
||||
HeaderFooterPage(
|
||||
|
|
|
|||
|
|
@ -45,9 +45,8 @@ fun QrCodeConfirmationView(
|
|||
onCancel: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
BackHandler {
|
||||
onCancel()
|
||||
}
|
||||
BackHandler(onBack = onCancel)
|
||||
|
||||
val icon = when (step) {
|
||||
is QrCodeConfirmationStep.DisplayCheckCode -> CompoundIcons.Computer()
|
||||
is QrCodeConfirmationStep.DisplayVerificationCode -> CompoundIcons.LockSolid()
|
||||
|
|
|
|||
|
|
@ -45,16 +45,14 @@ fun QrCodeErrorView(
|
|||
onRetry: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
BackHandler {
|
||||
onRetry()
|
||||
}
|
||||
BackHandler(onBack = onRetry)
|
||||
FlowStepPage(
|
||||
modifier = modifier,
|
||||
iconStyle = BigIcon.Style.AlertSolid,
|
||||
title = titleText(errorScreenType, appName),
|
||||
subTitle = subtitleText(errorScreenType, appName),
|
||||
content = { Content(errorScreenType) },
|
||||
buttons = { Buttons(onRetry) }
|
||||
buttons = { Buttons(onRetry) },
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
package io.element.android.features.userprofile.shared
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||
|
|
@ -51,7 +50,6 @@ fun UserProfileView(
|
|||
openAvatarPreview: (username: String, url: String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
BackHandler { goBack() }
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
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.ensureCalledOnceWithTwoParams
|
||||
import io.element.android.tests.testutils.pressBack
|
||||
import io.element.android.tests.testutils.pressBackKey
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
|
@ -46,16 +45,6 @@ import org.robolectric.annotation.Config
|
|||
class UserProfileViewTest {
|
||||
@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
|
||||
fun `on back button click - the expected callback is called`() = runTest {
|
||||
ensureCalledOnce { callback ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue