is there a better way to do this? Some items are d...
# compose
m
is there a better way to do this? Some items are disabled so they wont need click:
Copy code
.then(if (isEnabled) Modifier.clickable { onItemClicked(index) } else Modifier)
f
I believe the
clickable
modifier has
enabled
parameter 🤔
👍🏼 1
👍 1
👌 1
b
Because this often doesn't only apply to Modifiers that have an
enabled
field I made this function
Copy code
inline fun Modifier.thenIf(take: Boolean, other: Modifier.() -> Modifier): Modifier =
    if (take) then(other()) else this
Which you can use like so:
Copy code
Modifier.thenIf(myBoldean) {
    background(color).padding(12.dp)
}
z
I think including the modifier but setting it to disabled changes how accessibility services see it. Would recommend testing with eg talkback to see which effect fits your design