https://kotlinlang.org logo
m

Marcin Wisniowski

06/04/2023, 4:35 PM
I am migrating some code from Material2 to Material3 and I cannot find the Material3 equivalent of
rememberRipple()
, for passing into
Modifier.clickable(indication = ...)
. Where did it go?
s

Stylianos Gakis

06/04/2023, 4:44 PM
Even material3.MaterialTheme seems to be using the ripple from material as seen here https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]in/kotlin/androidx/compose/material3/MaterialTheme.kt;l=25-71 Maybe that one doesn’t have a m2/m3 difference?
Maybe there are some things that don’t really have an m2/m3 mapping but are more like generic material components? I think PullToRefresh is like that too, it doesn’t have an m3 equivalent, but not sure if there’s a need for such a thing to exist, since it’d probably look the same? Definitely not sure about it. With that said, you may even just use
LocalIndication.current
if you want the one provided by the material theme, since I see it passes it in that place which I linked to you.
m

Marcin Wisniowski

06/04/2023, 5:12 PM
That was a good clue, turns out it was moved to a separate dependency shared between M2 and M3:
androidx.compose.material:material-ripple
doesn’t have an m3 equivalent, but not sure if there’s a need for such a thing to exist
The thing is, if you use M3, you don't want to include the M2 dependency just to use a single thing from it.
s

Stylianos Gakis

06/04/2023, 5:26 PM
The thing is, if you use M3, you don’t want to include the M2 dependency just to use a single thing from it.
Yeah I absolutely agree. I haven’t looked into it since we’re using both themes right now (and will be for a long time as I see it) so I haven’t tried to see what’s left in order to drop the dependency completely. But yes, sounds like pull to refresh should be similarly pulled out of the core material dependency just like material-ripple is. You could make a bug report (If no similar bug exists) if you have the time, I’d love to upvote it to see what google thinks about this.
r

raenardev

06/05/2023, 1:43 PM
It is mentioned in code. Although i didn't find artifact for it yet, only for ripple
Copy code
...
 */
// TODO(b/244423199): Move pullRefresh into its own material library similar to material-ripple.
@ExperimentalMaterialApi
fun Modifier.pullRefresh(
    state: PullRefreshState,
    enabled: Boolean = true
) = inspectable(inspectorInfo =
...
6 Views