From 93df0387e98fed7c9d55d88060f17250d6714257 Mon Sep 17 00:00:00 2001 From: "mohamad.jaara" Date: Thu, 7 Sep 2023 13:35:27 +0200 Subject: [PATCH 1/2] fix: crash related to request focus when clicking on last name EditText in CreateAccountDetailsScreen --- .../details/CreateAccountDetailsScreen.kt | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt index 1ce02a8fe5e..05791595082 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt @@ -122,9 +122,7 @@ private fun DetailsContent( ) { val keyboardOptions = KeyboardOptions(KeyboardCapitalization.Words, true, KeyboardType.Text, ImeAction.Next) val keyboardController = LocalSoftwareKeyboardController.current - val focusRequesterFirstName = remember { FocusRequester() } - val focusRequesterLastName = remember { FocusRequester() } - val focusRequesterTeamName = remember { FocusRequester() } + val firstNameFocusRequester = remember { FocusRequester() } Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -134,13 +132,6 @@ private fun DetailsContent( .verticalScroll(rememberScrollState()) ) { - val requestFocus = remember<(Offset) -> Unit> { - { _ -> - keyboardController?.show() - focusRequesterTeamName.requestFocus() - } - } - Text( text = stringResource(R.string.create_personal_account_details_text), style = MaterialTheme.wireTypography.body01, @@ -166,7 +157,7 @@ private fun DetailsContent( end = MaterialTheme.wireDimensions.spacing16x, bottom = MaterialTheme.wireDimensions.spacing16x ) - .focusRequester(focusRequesterFirstName) + .focusRequester(firstNameFocusRequester) .testTag("firstName"), ) @@ -184,10 +175,7 @@ private fun DetailsContent( end = MaterialTheme.wireDimensions.spacing16x, bottom = MaterialTheme.wireDimensions.spacing16x ) - .focusRequester(focusRequesterLastName) .testTag("lastName"), - shouldDetectTaps = true, - onTap = requestFocus ) if (state.type == CreateAccountFlowType.CreateTeam) { @@ -205,10 +193,7 @@ private fun DetailsContent( end = MaterialTheme.wireDimensions.spacing16x, bottom = MaterialTheme.wireDimensions.spacing16x ) - .testTag("teamName") - .focusRequester(focusRequesterTeamName), - shouldDetectTaps = true, - onTap = requestFocus + .testTag("teamName"), ) } @@ -227,7 +212,6 @@ private fun DetailsContent( WireTextFieldState.Default }, autofill = false, - onTap = requestFocus ) WirePasswordTextField( @@ -251,12 +235,11 @@ private fun DetailsContent( WireTextFieldState.Error(stringResource(id = R.string.create_account_details_password_error)) } else WireTextFieldState.Default, autofill = false, - onTap = requestFocus ) } LaunchedEffect(Unit) { - focusRequesterFirstName.requestFocus() + firstNameFocusRequester.requestFocus() keyboardController?.show() } From 4f4e3609914d70787eac9f5d0b26cf753496ee6f Mon Sep 17 00:00:00 2001 From: "mohamad.jaara" Date: Thu, 7 Sep 2023 15:09:55 +0200 Subject: [PATCH 2/2] detekt --- .../authentication/create/details/CreateAccountDetailsScreen.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt b/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt index 05791595082..51beccee1cc 100644 --- a/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/authentication/create/details/CreateAccountDetailsScreen.kt @@ -41,7 +41,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester -import androidx.compose.ui.geometry.Offset import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource