switch
README.md
:OCSwitch - A Custom Composable UI Component
This OCSwitch is a custom Jetpack Compose component designed to toggle its state to On or Off.
Features:
- Configurable control with customizable colors.
- Create switch with active, inactive, selected and deselected states.
:How to use OCSwitch
-
Add the necessary imports:
import your.package.name.OCSwitch -
Use the
OCSwitchwithin your Composable:val switchState = remember { mutableStateOf(true) }
val activeStatus = remember { mutableStateOf(false) }
OCSwitch(
isOn = switchState.value,
isEnabled = activeStatus.value,
onSwitchToggled = {
switchState.value = it
},
)
Parameters:
isOn: Boolean denotes if switch is On of Off state.isSelected: Boolean denotes if switch is enabled or disabled.switchConfig: (Optional) Configuration to change style of the switch.onSwitchToggled: A lambda function called when a switch is toggled.