1 /*
2  * Copyright 2024 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.photopicker.core.animations
18 
19 import android.view.animation.PathInterpolator
20 import androidx.compose.animation.core.Easing
21 import androidx.compose.animation.core.FiniteAnimationSpec
22 import androidx.compose.animation.core.spring
23 import androidx.compose.animation.core.tween
24 import androidx.compose.ui.unit.IntOffset
25 import androidx.compose.ui.unit.IntSize
26 
27 /** From the material-3 emphasized easing set */
28 val emphasizedDecelerate: FiniteAnimationSpec<IntOffset> =
29     tween(
30         durationMillis = 400,
<lambda>null31         easing = Easing { PathInterpolator(0.05f, 0.7f, 0.1f, 1f).getInterpolation(it) },
32     )
33 
34 /** From the material-3 emphasized easing set */
35 val emphasizedAccelerate: FiniteAnimationSpec<IntOffset> =
36     tween(
37         durationMillis = 200,
<lambda>null38         easing = Easing { PathInterpolator(0.03f, 0f, 0.8f, 0.15f).getInterpolation(it) },
39     )
40 
41 /** From the material-3 motion physics system */
42 val springDefaultEffectFloat: FiniteAnimationSpec<Float> =
43     spring(dampingRatio = 0.8f, stiffness = 380f)
44 
45 /** From the material-3 motion physics system */
46 val springDefaultEffectOffset: FiniteAnimationSpec<IntOffset> =
47     spring(dampingRatio = 0.8f, stiffness = 380f)
48 
49 /** From the material-3 emphasized easing set */
50 val emphasizedAccelerateFloat: FiniteAnimationSpec<Float> =
51     tween(
52         durationMillis = 150,
<lambda>null53         easing = Easing { PathInterpolator(0.3f, 0f, 0.8f, 0.15f).getInterpolation(it) },
54     )
55 
56 /** From the material-3 standard easing set */
standardDeceleratenull57 fun standardDecelerate(durationMillis: Int = 200): FiniteAnimationSpec<IntSize> =
58     tween(
59         durationMillis = durationMillis,
60         easing = Easing { PathInterpolator(0f, 0f, 0f, 1f).getInterpolation(it) },
61     )
62