-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifierExtensions.kt
More file actions
37 lines (34 loc) · 1.25 KB
/
ModifierExtensions.kt
File metadata and controls
37 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package net.frozendevelopment.openletters.extensions
import androidx.compose.animation.core.FastOutLinearInEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
@Composable
fun Modifier.pulse(
initialScale: Float = 1f,
targetScale: Float = 0.95f,
durationMillis: Int = 600,
): Modifier {
val infiniteTransition = rememberInfiniteTransition(label = "pulseInfiniteTransition")
val scale by infiniteTransition.animateFloat(
label = "pulseAnimation",
initialValue = initialScale,
targetValue = targetScale,
animationSpec =
infiniteRepeatable(
animation =
tween(
durationMillis = durationMillis,
easing = FastOutLinearInEasing,
),
repeatMode = RepeatMode.Reverse,
),
)
return this.scale(scale)
}