Interface

SurfaceTransformation

Object to be used to apply different transformation to the content and the container (i.e.

SurfaceTransformationButtonSample

@Sampled
@Preview
@Composable
fun SurfaceTransformationButtonSample() {
    val transformationSpec =
        rememberTransformationSpec(
            ResponsiveTransformationSpec.smallScreen(
                contentAlpha =
                    TransformationVariableSpec(
                        0f,
                        transformationZoneEnterFraction = 0.4f,
                        transformationZoneExitFraction = 0.8f,
                    ),
                containerAlpha = TransformationVariableSpec(0.3f),
            )
        )

    TransformingLazyColumn {
        items(count = 100) {
            Button(
                onClick = {},
                transformation = SurfaceTransformation(transformationSpec),
                modifier =
                    Modifier.transformedHeight(this, transformationSpec)
                        .minimumVerticalContentPadding(
                            ButtonDefaults.minimumVerticalListContentPadding
                        ),
            ) {
                Text("Button #$it")
            }
        }
    }
}

SurfaceTransformationCardSample

@Sampled
@Preview
@Composable
fun SurfaceTransformationCardSample() {
    val transformationSpec = rememberTransformationSpec()
    var expandedIndex by remember { mutableIntStateOf(-1) }
    val state = rememberTransformingLazyColumnState()

    AppScaffold {
        ScreenScaffold(state) { contentPadding ->
            TransformingLazyColumn(state = state, contentPadding = contentPadding) {
                items(count = 100) {
                    TitleCard(
                        onClick = { expandedIndex = if (expandedIndex == it) -1 else it },
                        title = { Text("Card #$it") },
                        subtitle = { Text("Subtitle #$it") },
                        transformation = SurfaceTransformation(transformationSpec),
                        modifier =
                            Modifier.transformedHeight(this, transformationSpec)
                                .minimumVerticalContentPadding(
                                    CardDefaults.minimumVerticalListContentPadding
                                ),
                    ) {
                        if (it == expandedIndex) {
                            Text("Expanded content #$it")
                        }
                    }
                }
            }
        }
    }
}

SurfaceTransformationOnCustomComponent

@Sampled
@Preview
@Composable
fun SurfaceTransformationOnCustomComponent() {
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: