valentinilk / compose-shimmer

A simple shimmer library for Jetpack Compose.
https://valentinilk.github.io/compose-shimmer/
Apache License 2.0
670 stars 37 forks source link

Start and stop shimmering #7

Closed WebTiger89 closed 2 years ago

WebTiger89 commented 2 years ago

Is it possible to start and stop the shimmering? I have a "ScannerButton" and when isScanning = true, the shimmer effect should start otherwise the button is non-shimmering.

Would it make sense to implement such a behavior or should I just swap the composable at the right time, e.g. when isScanning = true, then show shimmering version of button and when false show non-shimmering version. What do you think?

WebTiger89 commented 2 years ago

How stupid, after opening the issue I noticed I can just do this:

    val shimmeringModifier = remember(isScanning) {
        if (isScanning) Modifier.shimmer()
        else Modifier
    }