Function

combinedAction

Creates an action that's a composite of multiple actions.

CombinedActionSample

@Sampled
@Preview
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun CombinedActionSample() {
    val isBookmarked = remember { MutableRemoteBoolean(false) }
    val nextState = !isBookmarked

    RemoteBox(
        modifier =
            RemoteModifier.clip(RemoteRoundedCornerShape(12.rdp))
                .background(isBookmarked.select(Color(0xFF2E7D32).rc, Color.DarkGray.rc))
                .clickable(
                    combinedAction(
                        valueChangeAction(isBookmarked, nextState),
                        hostAction(name = "bookmark_changed".rs, value = nextState),
                    )
                )
                .padding(16.rdp),
        contentAlignment = RemoteAlignment.Center,
    ) {
        RemoteText(
            text = isBookmarked.select("Bookmarked".rs, "Tap to Bookmark".rs),
            color = Color.White.rc,
        )
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: