Fork of this article with refactoring and improvements such as custom size, colors, vertical variant and more.
slider.mp4
- Update your
settings.gradle
dependencyResolutionManagement {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Update your module level
build.gradle
. Check latest version on the tags page
dependencies {
implementation 'com.github.mdrlzy:ComposeCounterSlider:$version'
}
var valueCounter by remember {
mutableStateOf(0)
}
HorizontalCounterSlider(
modifier = Modifier,
size = DpSize(200.dp, 80.dp),
value = valueCounter.toString(),
allowTopToReset = true,
allowBottomToReset = true,
customization = CounterSliderCustomization(),
colors = CounterSliderColors(),
onValueIncreaseClick = {
valueCounter += 1
},
onValueDecreaseClick = {
valueCounter = maxOf(valueCounter - 1, 0)
},
onValueClearClick = {
valueCounter = 0
}
)