Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amirsinarz/lcswitch

Android Jetpack Compose implementation of switch animation from Oleg Frolov
https://github.com/amirsinarz/lcswitch

android compose-ui jetpack-compose kotlin kotlin-android

Last synced: about 2 months ago
JSON representation

Android Jetpack Compose implementation of switch animation from Oleg Frolov

Awesome Lists containing this project

README

        

# Preview


heart-switch Demo


LCSwitch


A Circular and Linear toggle switch component built using Jetpack Compose. Inspired by Oleg Frolov



[![Platform](https://img.shields.io/badge/platform-android-green.svg)](http://developer.android.com/index.html)
[![API](https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=21)

USAGE
-----
Just add [LCSwitch.kt](https://github.com/AmirSinaRZ/LCSwitch/blob/master/app/src/main/java/com/amirsinarz/lcswitch/LCSwitch.kt) file in your project .
Examples are in the [MainActivity.kt](https://github.com/AmirSinaRZ/LCSwitch/blob/master/app/src/main/java/com/amirsinarz/lcswitch/MainActivity.kt)

### Circular Switch:
```kotlin
@Composable
fun SwitcherC(
modifier: Modifier = Modifier,
width: Dp = 46.dp,
height: Dp = 26.dp,
checked: Boolean = true,
onCheckedChange: ((Boolean) -> Unit)? = null,
elevation: Dp = 4.dp,
onColor: Color = Color(0xFF48ea8b),
offColor: Color = Color(0xFFff4651),
iconColor: Color = Color.White,
)
```
### Linear Switch
```kotlin
@Composable
fun SwitcherL(
modifier: Modifier = Modifier,
width: Dp = 46.dp,
height: Dp = 26.dp,
checked: Boolean = true,
onCheckedChange: ((Boolean) -> Unit)? = null,
elevation: Dp = 4.dp,
onColor: Color = Color(0xFF48ea8b),
offColor: Color = Color(0xFFff4651),
iconColor: Color = Color.White,
)
```