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

how to implement enable or disable shimmer #21

Open aisatriani opened 1 year ago

TamasRusvai commented 1 year ago

Check this for enable/disable: https://github.com/valentinilk/compose-shimmer/issues/7

saran2020 commented 5 months ago

Well going through the Readme file, I too had the same question. I feel the example in the "Quick Start" section is very confusing. I feel it should be more simple. I think giving a sample of how to achevie the intro gif will make understanding how to use lot more easier.

If we agree, I can raise a PR.

ocetin00 commented 2 months ago

I think you can do "intro gif" easily, you should set background gray, and use shimmer modifier.

you can enable or disable like below.

`

val showShimmer by remember {
    mutableStateOf(true)
}
Box(
    modifier = Modifier
        .size(50.dp)
        .background(Color.LightGray)
        .shimmer(showShimmer)
) {

}

`

@Composable fun Modifier.shimmer(show: Boolean) = this then Modifier.apply { if (show) shimmer() }