feat: 引入 sketch4 显示 GIF 动画,新增 AnimatedGif 组件

- 添加 sketch4 依赖(compose / animated-gif / compose-resources)
- 升级 tyme4kt 1.4.4 → 1.4.5
- 新增 puppy_1.gif 资源与 AnimatedGif 通用组件

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-19 13:36:14 +08:00
parent 49487a00e8
commit feb7db718e
5 changed files with 33 additions and 1 deletions

View File

@ -14,7 +14,8 @@ junit = "4.13.2"
kotlin = "2.3.21"
material3 = "1.10.0-alpha05"
kotlinx-datetime = "0.8.0"
tyme4kt = "1.4.4"
tyme4kt = "1.4.5"
sketch = "4.4.0"
[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
@ -30,6 +31,9 @@ compose-uiToolingPreview = { module = "org.jetbrains.compose.ui:ui-tooling-previ
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version = "1.11.0" }
tyme4kt = { module = "cn.6tail:tyme4kt", version.ref = "tyme4kt" }
sketch-compose = { module = "io.github.panpf.sketch4:sketch-compose", version.ref = "sketch" }
sketch-animated-gif = { module = "io.github.panpf.sketch4:sketch-animated-gif", version.ref = "sketch" }
sketch-compose-resources = { module = "io.github.panpf.sketch4:sketch-compose-resources", version.ref = "sketch" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }

View File

@ -46,6 +46,9 @@ kotlin {
implementation(libs.androidx.lifecycle.runtimeCompose)
implementation(libs.kotlinx.datetime)
implementation(libs.tyme4kt)
implementation(libs.sketch.compose)
implementation(libs.sketch.animated.gif)
implementation(libs.sketch.compose.resources)
}
commonTest.dependencies {
implementation(libs.kotlin.test)

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,25 @@
package plus.rua.project.ui
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.github.panpf.sketch.AsyncImage
/**
* 显示动画 GIF 图片
*
* @param modifier 应用于图片的 Modifier
* @param contentDescription 无障碍描述
*/
@Composable
fun AnimatedGif(
modifier: Modifier = Modifier,
contentDescription: String? = null,
) {
AsyncImage(
uri = "compose.resource://files/puppy_1.gif",
contentDescription = contentDescription,
modifier = modifier,
)
}