Skip to content

Latest commit

 

History

History
38 lines (33 loc) · 1.06 KB

Custom Preferences.md

File metadata and controls

38 lines (33 loc) · 1.06 KB

You have 2 options to define custom preferences. If possible, prefer the first one as it will apply all the styling for you.

Option 1: Use the BasePreference composable

BasePreference(
    title = "A custom preference",
    subtitle = "Showing an icon button",
    icon = { Icon(Icons.Default.Android, null) }
) {
    IconButton(onClick = {
        showInfo("IconButton clicked")
    }) {
        Icon(Icons.Default.Android, null)
    }
}

Option 2: Use the BasePreferenceContainer composable

Note

In this case you have to apply the styling yourself - just the most basic stuff is done for you!

BasePreferenceContainer(
    modifier = Modifier.padding(16.dp)
) { modifier ->
    // you should use the modifier, it handles enabled/disabled state + shaping + animation
    Column(modifier) {
        Text("A custom preference", fontWeight = FontWeight.Bold, color = Color.Red)
        Text("Holding a completely customised layout...")
    }
}