Add SwitchPreference
This commit is contained in:
parent
4554743eba
commit
ac283f99b3
@ -0,0 +1,28 @@
|
|||||||
|
package de.mm20.launcher2.ui.component.preferences
|
||||||
|
|
||||||
|
import androidx.compose.material.Switch
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun SwitchPreference(
|
||||||
|
title: String,
|
||||||
|
icon: ImageVector? = null,
|
||||||
|
summary: String? = null,
|
||||||
|
value: Boolean,
|
||||||
|
onValueChanged: (Boolean) -> Unit,
|
||||||
|
enabled: Boolean = true
|
||||||
|
) {
|
||||||
|
Preference(
|
||||||
|
title = title,
|
||||||
|
icon = icon,
|
||||||
|
summary = summary,
|
||||||
|
enabled = enabled,
|
||||||
|
onClick = {
|
||||||
|
onValueChanged(!value)
|
||||||
|
},
|
||||||
|
controls = {
|
||||||
|
Switch(checked = value, onCheckedChange = onValueChanged)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user