SwipeToRevealChipSample
@OptIn(ExperimentalWearMaterialApi::class)
@Composable
fun SwipeToRevealChipSample(swipeToDismissBoxState: SwipeToDismissBoxState) {
val revealState = rememberRevealState()
SwipeToRevealChip(
revealState = revealState,
modifier =
Modifier.fillMaxWidth()
// Use edgeSwipeToDismiss to allow SwipeToDismissBox to capture swipe events
.edgeSwipeToDismiss(swipeToDismissBoxState),
primaryAction = {
SwipeToRevealPrimaryAction(
revealState = revealState,
icon = { Icon(SwipeToRevealDefaults.Delete, "Delete") },
label = { Text("Delete") },
onClick = { /* Add the click handler here */ },
)
},
secondaryAction = {
SwipeToRevealSecondaryAction(
revealState = revealState,
onClick = { /* Add the click handler here */ },
) {
Icon(SwipeToRevealDefaults.MoreOptions, "More Options")
}
},
undoPrimaryAction = {
SwipeToRevealUndoAction(
revealState = revealState,
label = { Text("Undo") },
onClick = { /* Add the undo handler for primary action */ },
)
},
undoSecondaryAction = {
SwipeToRevealUndoAction(
revealState = revealState,
label = { Text("Undo") },
onClick = { /* Add the undo handler for secondary action */ },
)
},
onFullSwipe = { /* Add the full swipe handler here */ },
) {
Chip(
modifier =
Modifier.fillMaxWidth().semantics {
// Use custom actions to make the primary and secondary actions accessible
customActions =
listOf(
CustomAccessibilityAction("Delete") {
/* Add the primary action click handler here */
true
},
CustomAccessibilityAction("More Options") {
/* Add the secondary click handler here */
true
},
)
},
onClick = { /* Add the chip click handler here */ },
colors = ChipDefaults.primaryChipColors(),
border = ChipDefaults.outlinedChipBorder(),
label = { Text("Swipe to Reveal Chip", maxLines = 3) },
)
}
}