ToggleChipWithSwitch
@Composable
fun ToggleChipWithSwitch() {
var checked by remember { mutableStateOf(true) }
// The primary label should have a maximum 3 lines of text
// and the secondary label should have max 2 lines of text.
ToggleChip(
label = { Text("SwitchIcon", maxLines = 3, overflow = TextOverflow.Ellipsis) },
secondaryLabel = {
Text("With secondary label", maxLines = 2, overflow = TextOverflow.Ellipsis)
},
checked = checked,
// For Switch toggle controls the Wear Material UX guidance is to set the
// unselected toggle control color to ToggleChipDefaults.switchUncheckedIconColor()
// rather than the default.
colors =
ToggleChipDefaults.toggleChipColors(
uncheckedToggleControlColor = ToggleChipDefaults.SwitchUncheckedIconColor
),
toggleControl = { Switch(checked = checked, enabled = true) },
onCheckedChange = { checked = it },
appIcon = {
Icon(
painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
contentDescription = "airplane",
modifier = Modifier.size(24.dp).wrapContentSize(align = Alignment.Center),
)
},
enabled = true,
)
}