sprint-1 #1
38
libary/src/main/java/com/example/libary/Toggle.kt
Normal file
38
libary/src/main/java/com/example/libary/Toggle.kt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package com.example.libary
|
||||||
|
|
||||||
|
import androidx.compose.material3.Checkbox
|
||||||
|
import androidx.compose.material3.CheckboxDefaults
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import com.example.libary.theme.AccentColor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checkboxes allow users to select one or more items from a set. Checkboxes can turn an option on or off.
|
||||||
|
* @param checked whether this checkbox is checked or unchecked
|
||||||
|
* @param onCheckedChange called when this checkbox is clicked. If `null`, then this checkbox will
|
||||||
|
* not be interactable, unless something else handles its input events and updates its state.
|
||||||
|
* @param modifier the [Modifier] to be applied to this checkbox
|
||||||
|
* */
|
||||||
|
@Composable
|
||||||
|
fun Toggle(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
checked: Boolean,
|
||||||
|
onCheckedChange: ((Boolean) -> Unit)? = null,
|
||||||
|
) {
|
||||||
|
Checkbox(
|
||||||
|
checked = checked,
|
||||||
|
onCheckedChange = onCheckedChange,
|
||||||
|
colors = CheckboxDefaults.colors(
|
||||||
|
checkedColor = AccentColor
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
private fun TogglePrev() {
|
||||||
|
Toggle(
|
||||||
|
checked = true
|
||||||
|
)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user