A Nice switch with animation for its thumb

A switch that uses 0 for the inactive state and 1 for the active state, and it has an animation for changing its value. this library written with Jetpack Compose.

Normal Bouncy

Add JitPack Maven to setting.gradle file like this:

dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven { url "https://jitpack.io" }  
       
    }
}

If you are using a lower version 7.x.x of Gradle build tools, you must add JitPack Maven to your root build.gradle file like this:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

And then add dependency to the module’s build.gradle

dependencies {
...
  implementation "com.github.mfarzan80:ZOneSwitch:1.0.2"
}

See this example code to understand how to use and customize the switch

val value = remember { mutableStateOf(false) }
ZeroOneSwitch(
    checked = value.value,
    animationDuration = 1000,  
    thumbBounce = true,        //thumb's bouncing animation
    colors = SwitchDefaults.colors(
    checkedTrackColor = Color(0xFF47e789),
    uncheckedTrackColor = Color(0xFFFB4550),
    checkedTrackAlpha = 1f,
    uncheckedTrackAlpha = 1f,
    checkedThumbColor = Color.White,
    uncheckedThumbColor = Color.White,
    ),
    onCheckedChange = { value.value = it }
)

GitHub

View Github