mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-04 10:47:32 +00:00
ci: desktop snapshots render animations at their end (#7916)
* ci: desktop snapshots render animations at their end * ci: re-record the desktop snapshots of the loading link preview
This commit is contained in:
1 parent
501eec671d
commit
bcb1afba40
4 files changed
+8
-2
No files matched your search
@@ -3,6 +3,7 @@ package chat.simplex.app
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.ImageComposeScene
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.MotionDurationScale
|
||||
import androidx.compose.ui.layout.FirstBaseline
|
||||
import androidx.compose.ui.layout.LastBaseline
|
||||
import androidx.compose.ui.layout.layout
|
||||
@@ -12,6 +13,7 @@ import androidx.compose.ui.unit.Constraints
|
||||
import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.use
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import org.jetbrains.skia.Image
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -27,8 +29,12 @@ fun Modifier.fixed(width: Int, height: Int, baseline: Int?): Modifier = layout {
|
||||
layout(width, height, if (baseline == null) emptyMap() else mapOf(FirstBaseline to baseline, LastBaseline to baseline)) { placeable.place(0, 0) }
|
||||
}
|
||||
|
||||
private object InstantMotion : MotionDurationScale {
|
||||
override val scaleFactor = 0f
|
||||
}
|
||||
|
||||
fun renderScene(direction: LayoutDirection = LayoutDirection.Ltr, width: Int = 400, height: Int = 400, frames: Int = 1, content: @Composable () -> Unit): Image =
|
||||
ImageComposeScene(width = width, height = height, density = Density(1f), layoutDirection = direction, content = content).use { scene ->
|
||||
ImageComposeScene(width = width, height = height, density = Density(1f), layoutDirection = direction, coroutineContext = Dispatchers.Unconfined + InstantMotion, content = content).use { scene ->
|
||||
(0 until frames).map { scene.render(it * 1_000_000_000L) }.last()
|
||||
}
|
||||
|
||||
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 679 B |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 977 B After Width: | Height: | Size: 617 B |
Reference in new issue
Block a user