-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposed fix to better time Compose UI animations
- Loading branch information
1 parent
0dfd588
commit 3079a30
Showing
13 changed files
with
119 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ android { | |
|
||
dependencies { | ||
implementation libs.composeUi.material | ||
implementation libs.composeUi.uiTooling | ||
} | ||
|
74 changes: 74 additions & 0 deletions
74
...src/test/projects/compose/src/main/java/app/cash/paparazzi/plugin/test/SimpleAnimation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package app.cash.paparazzi.plugin.test | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.animation.animateColor | ||
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.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.scale | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Preview | ||
@Composable | ||
fun SimpleAnimation() { | ||
Box(Modifier.fillMaxSize()) { | ||
var visible by remember { | ||
mutableStateOf(false) | ||
} | ||
|
||
LaunchedEffect(Unit) { | ||
visible = true | ||
} | ||
|
||
val infiniteTransition = rememberInfiniteTransition(label = "infinite-transition") | ||
val boxColor by infiniteTransition.animateColor( | ||
initialValue = Color.Red, | ||
targetValue = Color.Blue, | ||
animationSpec = infiniteRepeatable(tween(200, 300), RepeatMode.Reverse), | ||
label = "color" | ||
) | ||
|
||
AnimatedVisibility( | ||
visible = visible, | ||
enter = fadeIn(tween(delayMillis = 200)), | ||
exit = fadeOut(tween(delayMillis = 100)) | ||
) { | ||
Box( | ||
Modifier | ||
.size(100.dp) | ||
.background(boxColor) | ||
) | ||
} | ||
|
||
val scale by | ||
infiniteTransition.animateFloat( | ||
initialValue = 0.2f, | ||
targetValue = 1f, | ||
animationSpec = infiniteRepeatable(tween(200, 100), RepeatMode.Reverse), | ||
label = "scale" | ||
) | ||
|
||
Text( | ||
modifier = Modifier.scale(scale), | ||
text = "Hello, Paparazzi" | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+3.77 KB
...snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_animation_100ms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.77 KB
...t/snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_animation_1ms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.86 KB
...snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_animation_200ms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
...snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_animation_300ms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.75 KB
...snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_animation_400ms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.01 KB
...snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_animation_500ms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+78.8 KB
.../test/snapshots/videos/app.cash.paparazzi.plugin.test_ComposeTest_animation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.9 KB
...ots/videos/app.cash.paparazzi.plugin.test_ComposeTest_animation_middle-anim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.38 KB
...shots/videos/app.cash.paparazzi.plugin.test_ComposeTest_animation_start-end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters