iamthevoid
08/09/2021, 9:00 AMexpandIn + slideInVertically
will do the thing. But whatever alignment param looks like it not working at all, i set it as Center
, but next screen expands from side (video, gray background for better vision). Why can be that? (Code in Thread)iamthevoid
08/09/2021, 9:01 AM@OptIn(ExperimentalAnimationApi::class)
@Composable
fun NewStackScreenAnim(content: @Composable AnimatedVisibilityScope.() -> Unit) {
fun expandInitialSize(size: IntSize): IntSize = IntSize(size.width / 2, size.height / 2)
EnterAnimation(
enter = expandIn(
Alignment.Center,
::expandInitialSize,
animationSpec = tween(durationMillis = AnimationDuration)
),
exit = shrinkOut(
Alignment.Center,
::expandInitialSize,
animationSpec = tween(durationMillis = AnimationDuration)
),
content
)
}
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun EnterAnimation(
enter: EnterTransition = fadeIn(),
exit: ExitTransition = fadeOut(),
content: @Composable AnimatedVisibilityScope.() -> Unit
) {
AnimatedVisibility(
visibleState = remember { MutableTransitionState(initialState = false) }
.apply { targetState = true },
modifier = Modifier,
enter = enter,
exit = exit,
content = content
)
}
iamthevoid
08/09/2021, 9:01 AMiamthevoid
08/09/2021, 9:02 AMclip
as true as false with same resultiamthevoid
08/09/2021, 9:04 AMNavHost(navController = navController, startDestination = Screen.Splash.route) {
................
composable(Screen.Login.route) {
it.arguments?.onLoginCodeExtracted { authorized, code ->
NewStackScreenAnim {
AuthorizationGraph(authorized, code, events, stateProvider)
}
}
}
}
iamthevoid
08/09/2021, 10:02 AMBox
all became work normally
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun NewStackScreenAnim(content: @Composable AnimatedVisibilityScope.() -> Unit) {
fun initialSize(size: IntSize) = IntSize(width = size.width / 10 * 9, height = size.height / 10 * 9)
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
EnterAnimation(
enter = expandIn(
expandFrom = Alignment.Center,
initialSize = ::initialSize,
animationSpec = tween(AnimationDuration)
) +
slideInVertically({ it / 4 }, animationSpec = tween(AnimationDuration)) +
fadeIn(animationSpec = tween(AnimationDuration)),
content = content
)
}
}