Add SwitchPreference

This commit is contained in:
MM20 2021-09-26 22:57:58 +02:00
parent 4554743eba
commit ac283f99b3
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -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)
}
)
}