Instantly share code, notes, and snippets.
A Staff Engineer with 25 years of software development experience and 14 years on Android. I enjoy hiking, backpacking, and losing myself in a good book.
- Vancouver, CA
- https://www.francescvilarino.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NavHost( | |
navController = navController, | |
startDestination = "list", | |
modifier = Modifier.fillMaxSize(), | |
enterTransition = { slideInHorizontally { it } + fadeIn() }, | |
exitTransition = { slideOutHorizontally { -it } + fadeOut() }, | |
popEnterTransition = { slideInHorizontally { -it } + fadeIn() }, | |
popExitTransition = { slideOutHorizontally { it } + fadeOut() }, | |
) { | |
// omitted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LoremIpsum( | |
modifier = Modifier | |
.fillMaxWidth() | |
.sharedBounds( | |
rememberSharedContentState( | |
key = "text-$url" | |
), | |
animatedVisibilityScope, | |
), | |
maxLines = 3, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LoremIpsum( | |
modifier = Modifier | |
.fillMaxWidth() | |
.sharedElement( | |
rememberSharedContentState( | |
key = "text-$url" | |
), | |
animatedVisibilityScope, | |
) | |
.skipToLookaheadSize(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun SharedTransitionScope.DetailsScreen( | |
url: String, | |
animatedVisibilityScope: AnimatedVisibilityScope, | |
onClick: () -> Unit, | |
modifier: Modifier = Modifier, | |
) { | |
Column( | |
modifier = modifier | |
.clickable( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun SharedTransitionScope.ListScreen( | |
animatedVisibilityScope: AnimatedVisibilityScope, | |
onItemClick: (String) -> Unit, | |
modifier: Modifier = Modifier | |
) { | |
LazyColumn( | |
modifier = modifier, | |
verticalArrangement = Arrangement.spacedBy(8.dp), | |
contentPadding = PaddingValues(all = 16.dp), |
fvilarino
/ shared_elem_details_calling.kt
Created
April 20, 2024 23:29
Shared Elem - Details Calling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composable( | |
route = "details/{url}" | |
) { backstackEntry -> | |
val encoded = backstackEntry.arguments?.getString("url") ?: error("No URL") | |
val url = URLDecoder.decode(encoded, "UTF-8") | |
DetailsScreen( | |
url = url, | |
animatedVisibilityScope = this@composable, | |
onClick = { navController.popBackStack() }, | |
modifier = Modifier.fillMaxSize(), |
fvilarino
/ shared_elem_animated_details.kt
Created
April 20, 2024 23:26
Share Elem - Animated Details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
// 1 | |
fun SharedTransitionScope.DetailsScreen( | |
url: String, | |
// 2 | |
animatedVisibilityScope: AnimatedVisibilityScope, | |
onClick: () -> Unit, | |
modifier: Modifier = Modifier, | |
) { | |
Column( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composable( | |
route = "list" | |
) { | |
ListScreen( | |
// 1 | |
animatedVisibilityScope = this@composable, | |
onItemClick = { item -> | |
val encoded = URLEncoder.encode(item, "UTF-8") | |
navController.navigate("details/$encoded") | |
}, |
fvilarino
/ shared_elem_animated_list.kt
Last active
April 21, 2024 19:27
Shared Elem - Animated List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
// 1 | |
fun SharedTransitionScope.ListScreen( | |
// 2 | |
animatedVisibilityScope: AnimatedVisibilityScope, | |
onItemClick: (String) -> Unit, | |
modifier: Modifier = Modifier | |
) { | |
LazyColumn( | |
modifier = modifier, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Home(modifier: Modifier = Modifier) { | |
val navController = rememberNavController() | |
// 1 | |
SharedTransitionLayout( | |
modifier = modifier, | |
) { | |
NavHost( | |
navController = navController, | |
startDestination = "list", |
NewerOlder