Browse Source

Supress warning `ModifierComposed` for autofill, there is a low risk of performance issue here.

pull/2635/head
Benoit Marty 6 months ago committed by Benoit Marty
parent
commit
07ca064ac4
  1. 28
      features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordView.kt
  2. 1
      libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt

28
features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordView.kt

@ -141,7 +141,7 @@ fun LoginPasswordView(
// Submit // Submit
Box( Box(
modifier = Modifier modifier = Modifier
.padding(horizontal = 16.dp) .padding(horizontal = 16.dp)
) { ) {
ButtonColumnMolecule { ButtonColumnMolecule {
Button( Button(
@ -201,11 +201,14 @@ private fun LoginForm(
.fillMaxWidth() .fillMaxWidth()
.onTabOrEnterKeyFocusNext(focusManager) .onTabOrEnterKeyFocusNext(focusManager)
.testTag(TestTags.loginEmailUsername) .testTag(TestTags.loginEmailUsername)
.autofill(autofillTypes = listOf(AutofillType.Username), onFill = { .autofill(
val sanitized = it.sanitize() autofillTypes = listOf(AutofillType.Username),
loginFieldState = sanitized onFill = {
eventSink(LoginPasswordEvents.SetLogin(sanitized)) val sanitized = it.sanitize()
}), loginFieldState = sanitized
eventSink(LoginPasswordEvents.SetLogin(sanitized))
}
),
placeholder = { placeholder = {
Text(text = stringResource(CommonStrings.common_username)) Text(text = stringResource(CommonStrings.common_username))
}, },
@ -247,11 +250,14 @@ private fun LoginForm(
.fillMaxWidth() .fillMaxWidth()
.onTabOrEnterKeyFocusNext(focusManager) .onTabOrEnterKeyFocusNext(focusManager)
.testTag(TestTags.loginPassword) .testTag(TestTags.loginPassword)
.autofill(autofillTypes = listOf(AutofillType.Password), onFill = { .autofill(
val sanitized = it.sanitize() autofillTypes = listOf(AutofillType.Password),
passwordFieldState = sanitized onFill = {
eventSink(LoginPasswordEvents.SetPassword(sanitized)) val sanitized = it.sanitize()
}), passwordFieldState = sanitized
eventSink(LoginPasswordEvents.SetPassword(sanitized))
}
),
onValueChange = { onValueChange = {
val sanitized = it.sanitize() val sanitized = it.sanitize()
passwordFieldState = sanitized passwordFieldState = sanitized

1
libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt

@ -213,6 +213,7 @@ private fun TextFieldValueContentToPreview() {
} }
} }
@Suppress("ModifierComposed")
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
fun Modifier.autofill(autofillTypes: List<AutofillType>, onFill: (String) -> Unit) = composed { fun Modifier.autofill(autofillTypes: List<AutofillType>, onFill: (String) -> Unit) = composed {
val autofillNode = AutofillNode(autofillTypes, onFill = onFill) val autofillNode = AutofillNode(autofillTypes, onFill = onFill)

Loading…
Cancel
Save