diff --git a/app/src/main/java/io/timelimit/android/ui/MainActivity.kt b/app/src/main/java/io/timelimit/android/ui/MainActivity.kt index be5d5bc..a45b227 100644 --- a/app/src/main/java/io/timelimit/android/ui/MainActivity.kt +++ b/app/src/main/java/io/timelimit/android/ui/MainActivity.kt @@ -242,7 +242,7 @@ class MainActivity : AppCompatActivity(), ActivityViewModelHolder, U2fManager.De if (isOpening) Transition.openScreen else if (isClosing) Transition.closeScreen - else Transition.none + else Transition.swap } } ) { screen -> diff --git a/app/src/main/java/io/timelimit/android/ui/animation/Transition.kt b/app/src/main/java/io/timelimit/android/ui/animation/Transition.kt index d13fb78..c6b31db 100644 --- a/app/src/main/java/io/timelimit/android/ui/animation/Transition.kt +++ b/app/src/main/java/io/timelimit/android/ui/animation/Transition.kt @@ -1,6 +1,24 @@ +/* + * TimeLimit Copyright 2019 - 2023 Jonas Lochmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package io.timelimit.android.ui.animation import androidx.compose.animation.* +import androidx.compose.animation.core.FastOutLinearInEasing +import androidx.compose.animation.core.LinearOutSlowInEasing +import androidx.compose.animation.core.tween @OptIn(ExperimentalAnimationApi::class) object Transition { @@ -15,6 +33,18 @@ object Transition { targetContentZIndex = -1f ) + val swap = run { + val speed = 250 + + fun phase1() = tween(speed, 0, FastOutLinearInEasing) + fun phase2() = tween(speed, speed, LinearOutSlowInEasing) + + ContentTransform( + initialContentExit = slideOutVertically(phase1()) { it / 2 } + fadeOut(phase1()), + targetContentEnter = slideInVertically(phase2()) { it / 2 } + fadeIn(phase2()) + ) + } + val none = ContentTransform( targetContentEnter = EnterTransition.None, initialContentExit = ExitTransition.None