@Composable
fun IconButtonSample() {
IconButton(onClick = { /* Do something */ }) {
Icon(imageVector = Icons.Filled.Favorite, contentDescription = "Favorite icon")
}
}
@Composable
fun IconButtonWithCornerAnimationSample(
colors: IconButtonColors = IconButtonDefaults.filledIconButtonColors()
) {
FilledIconButton(
onClick = { /* Do something */ },
shapes = IconButtonDefaults.animatedShapes(),
colors = colors,
) {
Icon(imageVector = Icons.Filled.Favorite, contentDescription = "Favorite icon")
}
}
@Composable
fun IconButtonWithImageSample(
painter: Painter,
enabled: Boolean,
shapes: IconButtonShapes = IconButtonDefaults.shapes(),
) {
IconButton(onClick = { /* Do something */ }, shapes = shapes, enabled = enabled) {
Image(
painter = painter,
contentDescription = null,
contentScale = ContentScale.Crop,
modifier =
if (enabled) Modifier else Modifier.alpha(IconButtonDefaults.DisabledImageOpacity),
)
}
}
@Composable
fun IconButtonWithOnLongClickSample(onLongClick: () -> Unit) {
IconButton(
onClick = { /* Do something for onClick*/ },
onLongClick = onLongClick,
onLongClickLabel = "Long click",
) {
Icon(imageVector = Icons.Filled.Favorite, contentDescription = "Favorite icon")
}
}