Skip to content

Commit 5a44e5e

Browse files
committed
Add placeholder size example
1 parent d6d77eb commit 5a44e5e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/SnippetsActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.navigation.compose.NavHost
2828
import androidx.navigation.compose.composable
2929
import androidx.navigation.compose.rememberNavController
3030
import com.example.compose.snippets.animations.AnimationExamplesScreen
31+
import com.example.compose.snippets.animations.sharedelement.PlaceholderSizeAnimated_Demo
3132
import com.example.compose.snippets.components.AppBarExamples
3233
import com.example.compose.snippets.components.ButtonExamples
3334
import com.example.compose.snippets.components.ChipExamples
@@ -77,6 +78,7 @@ class SnippetsActivity : ComponentActivity() {
7778
)
7879
}
7980
Destination.ShapesExamples -> ApplyPolygonAsClipImage()
81+
Destination.SharedElementExamples ->PlaceholderSizeAnimated_Demo()
8082
}
8183
}
8284
}

compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/CustomizeSharedElementsSnippets.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,15 +542,14 @@ fun PlaceholderSizeAnimated_Demo() {
542542
// This demo shows how other items in a layout can respond to shared elements changing in size.
543543
// [START android_compose_shared_element_placeholder_size]
544544
SharedTransitionLayout {
545-
val boundsTransform = { _: Rect, _: Rect -> tween<Rect>(1000) }
546545

547546
val navController = rememberNavController()
548547
NavHost(
549548
navController = navController,
550549
startDestination = "home"
551550
) {
552551
composable("home", enterTransition = { fadeIn() }, exitTransition = { fadeOut() }) {
553-
Column {
552+
Column(modifier = Modifier.fillMaxSize()) {
554553
Row(modifier = Modifier.horizontalScroll(rememberScrollState())) {
555554
(listSnacks).forEachIndexed { index, snack ->
556555
Image(
@@ -562,7 +561,6 @@ fun PlaceholderSizeAnimated_Demo() {
562561
.sharedBounds(
563562
rememberSharedContentState(key = "image-${snack.name}"),
564563
animatedVisibilityScope = this@composable,
565-
boundsTransform = boundsTransform,
566564
placeHolderSize = SharedTransitionScope.PlaceHolderSize.animatedSize
567565
)
568566
.clickable {
@@ -613,12 +611,11 @@ fun PlaceholderSizeAnimated_Demo() {
613611
.sharedBounds(
614612
rememberSharedContentState(key = "image-${snack.name}"),
615613
animatedVisibilityScope = this@composable,
616-
boundsTransform = boundsTransform,
617614
placeHolderSize = SharedTransitionScope.PlaceHolderSize.animatedSize
618615
)
619616
.clip(RoundedCornerShape(8.dp))
620-
.aspectRatio(9f / 16f)
621617
.fillMaxWidth()
618+
.aspectRatio(9f / 16f)
622619
)
623620
}
624621
}

compose/snippets/src/main/java/com/example/compose/snippets/navigation/Destination.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum class Destination(val route: String, val title: String) {
2323
ComponentsExamples("topComponents", "Top Compose Components"),
2424
ScreenshotExample("screenshotExample", "Screenshot Examples"),
2525
ShapesExamples("shapesExamples", "Shapes Examples"),
26+
SharedElementExamples("sharedElement", "Shared elements")
2627
}
2728

2829
// Enum class for compose components navigation screen.

0 commit comments

Comments
 (0)