Skip to content

Instantly share code, notes, and snippets.

View fvilarino's full-sized avatar

Francesc Vilariño Güell fvilarino

View GitHub Profile
@fvilarino
fvilarino / container_transform_animation.kt
Created April 26, 2024 02:56
Container Transform - Animation
@Composable
fun MorphingFab(modifier: Modifier = Modifier) {
val users = remember { mutableStateListOf<User>() }
// 1
var showDialog by remember { mutableStateOf(false) }
// 2
SharedTransitionLayout(
modifier = Modifier
.fillMaxSize(),
) {
@fvilarino
fvilarino / container_transform_input_box.kt
Created April 26, 2024 02:47
Container Transform - Input Box
// 1
@Composable
fun InputBox(
onAddUser: (User) -> Unit,
onCancel: () -> Unit,
modifier: Modifier = Modifier,
) {
// 2
Card(
modifier = modifier,
@fvilarino
fvilarino / container_transform_final.kt
Created April 26, 2024 01:59
Container Transform - Final
data class User(
val name: String,
val email: String,
)
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
fun MorphingFab(modifier: Modifier = Modifier) {
val users = remember { mutableStateListOf<User>() }
var showDialog by remember { mutableStateOf(false) }
@fvilarino
fvilarino / container_transform_baseline.kt
Last active April 26, 2024 02:53
Container Transform - Baseline
@Composable
fun MorphingFab(modifier: Modifier = Modifier) {
val users = remember { mutableStateListOf<User>() }
Box(modifier = modifier) {
UserList(
users = users,
modifier = Modifier.fillMaxSize(),
)
InputBox(
@fvilarino
fvilarino / container_transform_fab.kt
Created April 26, 2024 01:19
Container Transform - FAB
FloatingActionButton(
modifier = Modifier
.align(Alignment.BottomEnd)
.padding(all = 16.dp),
onClick = {
// TODO
}
) {
Icon(
imageVector = Icons.Default.Add,
@fvilarino
fvilarino / container_transform_user_list.kt
Created April 26, 2024 01:12
Container Transform - User List
// 1
data class User(
val name: String,
val email: String,
)
// 2
@Composable
fun UserList(
users: List<User>,
@fvilarino
fvilarino / shared_elem_nav_host.kt
Created April 21, 2024 00:07
Shared Elem - NavHost
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
@fvilarino
fvilarino / shared_elem_shared_bounds.kt
Created April 21, 2024 00:02
Shared Elem - Shared Bounds
LoremIpsum(
modifier = Modifier
.fillMaxWidth()
.sharedBounds(
rememberSharedContentState(
key = "text-$url"
),
animatedVisibilityScope,
),
maxLines = 3,
@fvilarino
fvilarino / shared_elem_skip_ahed.t
Last active April 21, 2024 19:28
Shared Elem - Skip Ahead
LoremIpsum(
modifier = Modifier
.fillMaxWidth()
.sharedElement(
rememberSharedContentState(
key = "text-$url"
),
animatedVisibilityScope,
)
.skipToLookaheadSize(),
@fvilarino
fvilarino / shared_elem_details_text.kt
Created April 20, 2024 23:46
Shared Elem - Details Text
@Composable
fun SharedTransitionScope.DetailsScreen(
url: String,
animatedVisibilityScope: AnimatedVisibilityScope,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier
.clickable(