From 831386a656056c60a18a0da080043bbbaa96e1ea Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 20 Sep 2023 18:57:11 -0400 Subject: [PATCH] Using Slide in and out instead of crossfade for the top and bottom bars. --- .../amethyst/ui/screen/loggedIn/MainScreen.kt | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt index 3c9aeaf1d..d9f3084c5 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt @@ -2,8 +2,14 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn import android.content.res.Configuration import androidx.activity.compose.BackHandler +import androidx.compose.animation.AnimatedContent import androidx.compose.animation.Crossfade +import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.core.tween +import androidx.compose.animation.slideInVertically +import androidx.compose.animation.slideOutVertically +import androidx.compose.animation.togetherWith +import androidx.compose.animation.with import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding @@ -51,7 +57,7 @@ import com.vitorpamplona.amethyst.ui.screen.NotificationViewModel import com.vitorpamplona.amethyst.ui.screen.ThemeViewModel import kotlinx.coroutines.launch -@OptIn(ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterialApi::class, ExperimentalAnimationApi::class) @Composable fun MainScreen( accountViewModel: AccountViewModel, @@ -216,21 +222,27 @@ fun MainScreen( .statusBarsPadding() .nestedScroll(nestedScrollConnection), bottomBar = { - Crossfade( + AnimatedContent( targetState = shouldShow, - animationSpec = tween(durationMillis = 100) - ) { state -> - if (state) { + transitionSpec = { + slideInVertically { height -> height } togetherWith + slideOutVertically { height -> height } + } + ) { isVisible -> + if (isVisible) { AppBottomBar(accountViewModel, navState, navBottomRow) } } }, topBar = { - Crossfade( + AnimatedContent( targetState = shouldShow, - animationSpec = tween(durationMillis = 100) - ) { state -> - if (state) { + transitionSpec = { + slideInVertically { height -> 0 } togetherWith + slideOutVertically { height -> 0 } + } + ) { isVisible -> + if (isVisible) { AppTopBar( followLists, navState,