Merge pull request #2635 from element-hq/renovate/io.nlopez.compose.rules-detekt-0.x

Update dependency io.nlopez.compose.rules:detekt to v0.4.0
This commit is contained in:
ganfra 2024-05-29 10:06:37 +02:00 committed by GitHub
commit 45188aea03
6 changed files with 42 additions and 34 deletions

View file

@ -60,7 +60,7 @@ allprojects {
config.from(files("$rootDir/tools/detekt/detekt.yml")) config.from(files("$rootDir/tools/detekt/detekt.yml"))
} }
dependencies { dependencies {
detektPlugins("io.nlopez.compose.rules:detekt:0.3.12") detektPlugins("io.nlopez.compose.rules:detekt:0.3.13")
} }
// KtLint // KtLint

View file

@ -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

View file

@ -87,10 +87,13 @@ internal fun RoomListSearchView(
) { ) {
Column( Column(
modifier = modifier modifier = modifier
.applyIf(state.isSearchActive, ifTrue = { .applyIf(
// Disable input interaction to underlying views condition = state.isSearchActive,
pointerInput(Unit) {} ifTrue = {
}) // Disable input interaction to underlying views
pointerInput(Unit) {}
}
)
) { ) {
if (state.isSearchActive) { if (state.isSearchActive) {
RoomListSearchContent( RoomListSearchContent(

View file

@ -168,6 +168,7 @@ data class BloomLayer(
* @param bottomSoftEdgeAlpha The alpha value to apply to the bottom soft edge. * @param bottomSoftEdgeAlpha The alpha value to apply to the bottom soft edge.
* @param alpha The alpha value to apply to the bloom effect. * @param alpha The alpha value to apply to the bloom effect.
*/ */
@SuppressWarnings("ModifierComposed")
fun Modifier.bloom( fun Modifier.bloom(
hash: String?, hash: String?,
background: Color, background: Color,
@ -312,6 +313,7 @@ fun Modifier.bloom(
* @param bottomSoftEdgeAlpha The alpha value to apply to the bottom soft edge. * @param bottomSoftEdgeAlpha The alpha value to apply to the bottom soft edge.
* @param alpha The alpha value to apply to the bloom effect. * @param alpha The alpha value to apply to the bloom effect.
*/ */
@SuppressWarnings("ModifierComposed")
fun Modifier.avatarBloom( fun Modifier.avatarBloom(
avatarData: AvatarData, avatarData: AvatarData,
background: Color, background: Color,

View file

@ -16,30 +16,26 @@
package io.element.android.libraries.designsystem.modifiers package io.element.android.libraries.designsystem.modifiers
import android.annotation.SuppressLint
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.platform.debugInspectorInfo import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.platform.inspectable
/** /**
* Applies the [ifTrue] modifier when the [condition] is true, [ifFalse] otherwise. * Applies the [ifTrue] modifier when the [condition] is true, [ifFalse] otherwise.
*/ */
@SuppressLint("UnnecessaryComposedModifier") // It's actually necessary due to the `@Composable` lambdas
fun Modifier.applyIf( fun Modifier.applyIf(
condition: Boolean, condition: Boolean,
ifTrue: @Composable Modifier.() -> Modifier, ifTrue: Modifier.() -> Modifier,
ifFalse: @Composable (Modifier.() -> Modifier)? = null ifFalse: (Modifier.() -> Modifier)? = null
): Modifier = ): Modifier = this then inspectable(
composed( inspectorInfo = debugInspectorInfo {
inspectorInfo = debugInspectorInfo { name = "applyIf"
name = "applyIf" value = condition
value = condition
}
) {
when {
condition -> then(ifTrue(Modifier))
ifFalse != null -> then(ifFalse(Modifier))
else -> this
}
} }
) {
this then when {
condition -> ifTrue(Modifier)
ifFalse != null -> ifFalse(Modifier)
else -> Modifier
}
}

View file

@ -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)