Slackbot
12/01/2021, 9:11 AMZoltan Demant
12/01/2021, 9:13 AMval transition = updateTransition(
targetState = BackStackState(
key = key,
size = stack.size
),
label = null
)
transition.AnimatedContent(
contentKey = BackStackState::key,
transitionSpec = {
contentTransform(
forward = targetState.size >= initialState.size
)
},
content = { (key) ->
val render = renders.getValue(key)
stateKeeper.SavedState(
key = key,
content = {
Render(render)
}
)
}
)
private fun contentTransform(
forward: Boolean
): ContentTransform {
return when {
forward -> {
ContentTransform(
targetContentEnter = slideInVertically(
initialOffsetY = { height -> height },
animationSpec = SlideSpec
),
initialContentExit = fadeOut(
animationSpec = FloatSpec
),
targetContentZIndex = 1f,
sizeTransform = null
)
}
else -> {
ContentTransform(
targetContentEnter = fadeIn(
animationSpec = FloatSpec
),
initialContentExit = slideOutVertically(
targetOffsetY = { height -> height },
animationSpec = SlideSpec
),
targetContentZIndex = -1f,
sizeTransform = null
)
}
}
}
Zoltan Demant
12/01/2021, 9:14 AMval transition = updateTransition(
targetState = MultiPaneState(
key = key,
mode = mode
),
label = null
)
transition.AnimatedContent(
contentKey = MultiPaneState::key,
transitionSpec = {
contentTransform(
forward = targetState.mode >= initialState.mode,
)
},
content = { (key) ->
val render = renders.getValue(key)
stateKeeper.SavedState(
key = key,
content = {
Render(render)
}
)
}
)
private fun contentTransform(
forward: Boolean
): ContentTransform {
return when {
forward -> {
ContentTransform(
targetContentEnter = slideInHorizontally(
initialOffsetX = { width -> width },
animationSpec = SlideSpec
),
initialContentExit = slideOutHorizontally(
targetOffsetX = { width -> -width },
animationSpec = SlideSpec
),
targetContentZIndex = 1f,
sizeTransform = null
)
}
else -> {
ContentTransform(
targetContentEnter = slideInHorizontally(
initialOffsetX = { width -> -width },
animationSpec = SlideSpec
),
initialContentExit = slideOutHorizontally(
targetOffsetX = { width -> width },
animationSpec = SlideSpec
),
targetContentZIndex = -1f,
sizeTransform = null
)
}
}
}
Zach Klippenstein (he/him) [MOD]
12/01/2021, 6:42 PMZoltan Demant
12/02/2021, 4:59 AM