mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 01:39:22 +02:00
Add swap animation
This commit is contained in:
parent
2971e3f55d
commit
ca0e33e942
2 changed files with 31 additions and 1 deletions
|
@ -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 ->
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
/*
|
||||
* TimeLimit Copyright <C> 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 <T> phase1() = tween<T>(speed, 0, FastOutLinearInEasing)
|
||||
fun <T> phase2() = tween<T>(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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue