1 /*
<lambda>null2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.compose.animation
18 
19 import androidx.compose.animation.core.Easing
20 import androidx.core.animation.Interpolator
21 import com.android.app.animation.InterpolatorsAndroidX
22 
23 /**
24  * Compose-compatible definition of Android motion eases, see
25  * https://carbon.googleplex.com/android-motion/pages/easing
26  */
27 object Easings {
28 
29     /** The standard interpolator that should be used on every normal animation */
30     val Standard = fromInterpolator(InterpolatorsAndroidX.STANDARD)
31 
32     /**
33      * The standard accelerating interpolator that should be used on every regular movement of
34      * content that is disappearing e.g. when moving off screen.
35      */
36     val StandardAccelerate = fromInterpolator(InterpolatorsAndroidX.STANDARD_ACCELERATE)
37 
38     /**
39      * The standard decelerating interpolator that should be used on every regular movement of
40      * content that is appearing e.g. when coming from off screen.
41      */
42     val StandardDecelerate = fromInterpolator(InterpolatorsAndroidX.STANDARD_DECELERATE)
43 
44     /** The default emphasized interpolator. Used for hero / emphasized movement of content. */
45     val Emphasized = fromInterpolator(InterpolatorsAndroidX.EMPHASIZED)
46 
47     /**
48      * The accelerated emphasized interpolator. Used for hero / emphasized movement of content that
49      * is disappearing e.g. when moving off screen.
50      */
51     val EmphasizedAccelerate = fromInterpolator(InterpolatorsAndroidX.EMPHASIZED_ACCELERATE)
52 
53     /**
54      * The decelerating emphasized interpolator. Used for hero / emphasized movement of content that
55      * is appearing e.g. when coming from off screen
56      */
57     val EmphasizedDecelerate = fromInterpolator(InterpolatorsAndroidX.EMPHASIZED_DECELERATE)
58 
59     /** The linear interpolator. */
60     val Linear = fromInterpolator(InterpolatorsAndroidX.LINEAR)
61 
62     /** The default legacy interpolator as defined in Material 1. Also known as FAST_OUT_SLOW_IN. */
63     val Legacy = fromInterpolator(InterpolatorsAndroidX.LEGACY)
64 
65     /**
66      * The default legacy accelerating interpolator as defined in Material 1. Also known as
67      * FAST_OUT_LINEAR_IN.
68      */
69     val LegacyAccelerate = fromInterpolator(InterpolatorsAndroidX.LEGACY_ACCELERATE)
70 
71     /**
72      * T The default legacy decelerating interpolator as defined in Material 1. Also known as
73      * LINEAR_OUT_SLOW_IN.
74      */
75     val LegacyDecelerate = fromInterpolator(InterpolatorsAndroidX.LEGACY_DECELERATE)
76 
77     private fun fromInterpolator(source: Interpolator) = Easing { x -> source.getInterpolation(x) }
78 }
79