I've built compose settings library to build setti...
# compose
a
I've built compose settings library to build settings screens easily with compose: https://github.com/alorma/Compose-Settings Also, added support for preferences so state persists across sessions. Any feedback is welcome!
👍 1
a
One thing you can improve is a11y support. For example in a switch preference, instead of
Modifier.clickable()
, you should use
Modifier.toggleable()
for better a11y support. Here’s the switch preference component I’m using in my project:
Copy code
@Composable
fun SwitchPreferenceItem(
    title: String,
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit,
    modifier: Modifier = Modifier,
    icon: ImageVector? = null,
    secondaryText: String? = null,
    enabled: Boolean = true
) {
    PreferenceItem(
        modifier = modifier.toggleable(
            value = checked,
            enabled = enabled,
            onValueChange = onCheckedChange,
            role = Role.Switch
        ),
        text = { Text(text = title) },
        icon = iconComposable(icon),
        secondaryText = textComposable(secondaryText),
        trailing = {
            Switch(checked = checked, onCheckedChange = null, enabled = enabled)
        },
        enabled = enabled
    )
}
👍 1
👍🏻 1
a
Thanks! I will try to do that!
m
Is that only for Android or would that work in Compose desktop as well?
a
I have someone working on porting it to KMP but not yet...