deviant
08/12/2022, 12:09 PMMR3Y
08/12/2022, 12:18 PMAnimatedContent
like : https://gist.github.com/c5inco/38e5075a883e5cc1136308bd3c44686ddeviant
08/12/2022, 12:52 PMMR3Y
08/12/2022, 12:56 PMdeviant
08/12/2022, 1:34 PMval updater = updateTransition(isExpanded, "updater")
val cornerAnimated by updater.animateInt(label = "corner") {
if (it) 10 else 50
}
Surface(
color = MaterialTheme.colors.secondary,
elevation = 16.dp,
modifier = Modifier
.clip(RoundedCornerShape(percent = cornerAnimated))
) {
updater.AnimatedContent(
transitionSpec = { fadeIn() with fadeOut() using SizeTransform() }
) { expanded ->
if (!expanded) {
Box(
modifier = Modifier
.defaultMinSize(minWidth = 56.dp, minHeight = 56.dp)
.clickable {
isExpanded = true
},
contentAlignment = Alignment.Center
) {
Icon(
Icons.Default.Share, null, modifier = Modifier
//.padding(8.dp)
)
}
} else {
Column {
MenuItem(Icons.Default.Link, stringResource(R.string.share_link), onShareUrl)
MenuItem(Icons.Default.Image, stringResource(R.string.share_img), onShareImage)
}
}
}
}
Colton Idle
08/13/2022, 8:19 AMdeviant
08/13/2022, 8:22 AMColton Idle
08/13/2022, 8:23 AMdeviant
08/13/2022, 8:25 AMColton Idle
08/13/2022, 8:35 AMDoris Liu
08/15/2022, 8:25 PMAnimatedContent
in a Surface
will give you a close look to ContainerTransform, although it won't scale the incoming or outgoing content to fit in the resizing container. Container transform is something we are looking at to support in the near future.
Shared element is being actively worked on. We have built & released a fundamental pre-requisite to shared element - LookaheadLayout
. It allows a pre-calculation of size & position of any layout change, therefore allowing layout changes to be animated. Orbital lib linked above leverages the latest features in LookaheadLayout. Highly recommend trying it out!