I updated to latest compose alpha and now I have t...
# compose
c
I updated to latest compose alpha and now I have this compile error regarding a
Card
My code
Copy code
Card(
    modifier = modifier,
    backgroundColor = color,
    onClick = onClick ?: {},
    indication = if (onClick == null) null else LocalIndication.current,
) { content() }
if I use the alt+enter helper it removes the
indication =...
. How can I set an indication on the card now though?
For now I just did this /shruggie
Copy code
if (onClick == null) {
  Card(modifier = modifier, backgroundColor = color) { content() }
} else {
  Card(onClick = onClick, modifier = modifier, backgroundColor = color) {
    content()
  }
}
l
Indication was removed for consistency with other Material APIs - indication is an implementation detail here, as a Card should always use a ripple, in the same way Button will always have a ripple
In any case, your previous code probably doesn’t work as expected - the component would still appear clickable for accessibility, visible to focus traversal, consume input events, etc.
c
New code seems fine to you though?
l
If the goal is to provide a single Card function that can switch between being clickable, and not-clickable, then yeah 🙂
1
z
Your new code will lose any state inside your card if you switch between those if cases though. Consider putting
content
in a
movableContentOf
.
🤔 1
l
True. Then again, I think it would be very unexpected to switch the same card between clickable and non-clickable - since there would be no visual indication that the card is now no longer clickable 🙂 So if you want to swap the same card, this probably is just going to be confusing for users
c
yeah. the "clickability" of a card can almost be guaranteed not to change. but now im intrigued by this whole movableContentOf business. 😄
💯 1