@momo-kits/native-kits 0.162.1-gif.16-debug → 0.162.1-gif.17-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compose/build.gradle.kts +3 -3
- package/compose/build.gradle.kts.backup +2 -2
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +14 -20
- package/gradle/libs.versions.toml +1 -1
- package/gradle.properties +1 -1
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/KitsSketchHttpStack.kt +0 -81
package/compose/build.gradle.kts
CHANGED
|
@@ -30,7 +30,7 @@ kotlin {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
val fwName = gitlabArtifactId
|
|
33
|
-
val iosTargets = listOf(iosArm64(), iosSimulatorArm64()
|
|
33
|
+
val iosTargets = listOf(iosArm64(), iosSimulatorArm64())
|
|
34
34
|
iosTargets.forEach {
|
|
35
35
|
it.binaries.framework {
|
|
36
36
|
baseName = fwName
|
|
@@ -40,7 +40,7 @@ kotlin {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
cocoapods {
|
|
43
|
-
version = "0.162.1-gif.
|
|
43
|
+
version = "0.162.1-gif.17-debug"
|
|
44
44
|
summary = "IOS Shared module"
|
|
45
45
|
homepage = "https://momo.vn"
|
|
46
46
|
ios.deploymentTarget = "15.0"
|
|
@@ -81,7 +81,7 @@ kotlin {
|
|
|
81
81
|
exclude(group = "io.github.panpf.sketch4", module = "sketch-compose-core")
|
|
82
82
|
}
|
|
83
83
|
implementation(project(":sketch-compose-core"))
|
|
84
|
-
implementation(libs.sketch.http.
|
|
84
|
+
implementation(libs.sketch.http.ktor3)
|
|
85
85
|
implementation(libs.sketch.animated.gif)
|
|
86
86
|
}
|
|
87
87
|
androidMain.dependencies {
|
|
@@ -30,7 +30,7 @@ kotlin {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
val fwName = gitlabArtifactId
|
|
33
|
-
val iosTargets = listOf(iosArm64(), iosSimulatorArm64()
|
|
33
|
+
val iosTargets = listOf(iosArm64(), iosSimulatorArm64())
|
|
34
34
|
iosTargets.forEach {
|
|
35
35
|
it.binaries.framework {
|
|
36
36
|
baseName = fwName
|
|
@@ -81,7 +81,7 @@ kotlin {
|
|
|
81
81
|
exclude(group = "io.github.panpf.sketch4", module = "sketch-compose-core")
|
|
82
82
|
}
|
|
83
83
|
implementation(project(":sketch-compose-core"))
|
|
84
|
-
implementation(libs.sketch.http.
|
|
84
|
+
implementation(libs.sketch.http.ktor3)
|
|
85
85
|
implementation(libs.sketch.animated.gif)
|
|
86
86
|
}
|
|
87
87
|
androidMain.dependencies {
|
package/compose/compose.podspec
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package vn.momo.kits.components
|
|
2
2
|
|
|
3
3
|
import androidx.compose.foundation.border
|
|
4
|
+
import androidx.compose.foundation.layout.Box
|
|
4
5
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
6
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
5
7
|
import androidx.compose.runtime.Composable
|
|
6
8
|
import androidx.compose.runtime.LaunchedEffect
|
|
7
9
|
import androidx.compose.runtime.mutableStateOf
|
|
@@ -18,17 +20,13 @@ import androidx.compose.ui.semantics.semantics
|
|
|
18
20
|
import androidx.compose.ui.platform.LocalDensity
|
|
19
21
|
import androidx.compose.ui.unit.dp
|
|
20
22
|
import com.github.panpf.sketch.AsyncImage as SketchAsyncImage
|
|
21
|
-
import com.github.panpf.sketch.LocalPlatformContext
|
|
22
23
|
import com.github.panpf.sketch.PainterState
|
|
23
|
-
import com.github.panpf.sketch.fetch.HttpUriFetcher
|
|
24
|
-
import com.github.panpf.sketch.request.ImageRequest as SketchImageRequest
|
|
25
24
|
import com.github.panpf.sketch.rememberAsyncImageState
|
|
26
25
|
import coil3.compose.AsyncImage as CoilAsyncImage
|
|
27
26
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
28
27
|
import vn.momo.kits.const.AppTheme
|
|
29
28
|
import vn.momo.kits.const.Colors
|
|
30
29
|
import vn.momo.kits.modifier.conditional
|
|
31
|
-
import vn.momo.kits.utils.KitsSketchHttpStack
|
|
32
30
|
|
|
33
31
|
data class Options(
|
|
34
32
|
val alignment: Alignment = Alignment.TopStart,
|
|
@@ -123,7 +121,6 @@ fun Image(
|
|
|
123
121
|
}
|
|
124
122
|
.semantics { contentDescription = "img|$source" },
|
|
125
123
|
) {
|
|
126
|
-
val platformContext = LocalPlatformContext.current
|
|
127
124
|
val urlToLoad = remember(source, maxWidth, maxHeight, density) {
|
|
128
125
|
when (source) {
|
|
129
126
|
is String -> {
|
|
@@ -141,17 +138,10 @@ fun Image(
|
|
|
141
138
|
|
|
142
139
|
if (isGifUrl(urlToLoad)) {
|
|
143
140
|
val asyncImageState = rememberAsyncImageState()
|
|
144
|
-
val request = remember(platformContext, urlToLoad) {
|
|
145
|
-
SketchImageRequest(platformContext, urlToLoad) {
|
|
146
|
-
components {
|
|
147
|
-
add(HttpUriFetcher.Factory(KitsSketchHttpStack))
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
141
|
|
|
152
142
|
SketchAsyncImage(
|
|
153
143
|
modifier = Modifier.matchParentSize(),
|
|
154
|
-
|
|
144
|
+
uri = urlToLoad,
|
|
155
145
|
state = asyncImageState,
|
|
156
146
|
contentDescription = null,
|
|
157
147
|
contentScale = imageOptions.contentScale,
|
|
@@ -211,7 +201,7 @@ private fun processImageUrl(url: String, maxWidth: androidx.compose.ui.unit.Dp,
|
|
|
211
201
|
}
|
|
212
202
|
|
|
213
203
|
@Composable
|
|
214
|
-
private fun
|
|
204
|
+
private fun ImageStateContent(
|
|
215
205
|
imageState: ImageState,
|
|
216
206
|
loading: Boolean,
|
|
217
207
|
onLoadingChanged: (Boolean) -> Unit,
|
|
@@ -230,13 +220,17 @@ private fun androidx.compose.foundation.layout.BoxScope.ImageStateContent(
|
|
|
230
220
|
}
|
|
231
221
|
|
|
232
222
|
@Composable
|
|
233
|
-
private fun
|
|
223
|
+
private fun ImageError() {
|
|
234
224
|
val theme = AppTheme.current
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
225
|
+
Box(
|
|
226
|
+
modifier = Modifier.fillMaxSize(),
|
|
227
|
+
contentAlignment = Alignment.Center
|
|
228
|
+
) {
|
|
229
|
+
Icon(
|
|
230
|
+
source = "media_fail",
|
|
231
|
+
color = theme.colors.text.disable,
|
|
232
|
+
)
|
|
233
|
+
}
|
|
240
234
|
}
|
|
241
235
|
|
|
242
236
|
@Composable
|
|
@@ -56,7 +56,7 @@ material = { module = "com.google.android.material:material", version.ref = "mat
|
|
|
56
56
|
|
|
57
57
|
sketch-compose = { module = "io.github.panpf.sketch4:sketch-compose", version.ref = "sketch" }
|
|
58
58
|
sketch-core = { module = "io.github.panpf.sketch4:sketch-core", version.ref = "sketch" }
|
|
59
|
-
sketch-http-
|
|
59
|
+
sketch-http-ktor3 = { module = "io.github.panpf.sketch4:sketch-http-ktor3", version.ref = "sketch" }
|
|
60
60
|
sketch-animated-gif = { module = "io.github.panpf.sketch4:sketch-animated-gif", version.ref = "sketch" }
|
|
61
61
|
[plugins]
|
|
62
62
|
jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
package/gradle.properties
CHANGED
package/package.json
CHANGED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.utils
|
|
2
|
-
|
|
3
|
-
import com.github.panpf.sketch.http.HttpHeaders
|
|
4
|
-
import com.github.panpf.sketch.http.HttpStack
|
|
5
|
-
import com.github.panpf.sketch.request.Extras
|
|
6
|
-
import io.ktor.client.HttpClient
|
|
7
|
-
import io.ktor.client.request.HttpRequestBuilder
|
|
8
|
-
import io.ktor.client.request.header
|
|
9
|
-
import io.ktor.client.request.prepareRequest
|
|
10
|
-
import io.ktor.client.request.url
|
|
11
|
-
import io.ktor.client.statement.HttpResponse
|
|
12
|
-
import io.ktor.client.statement.bodyAsChannel
|
|
13
|
-
import io.ktor.utils.io.ByteReadChannel
|
|
14
|
-
import io.ktor.utils.io.cancel
|
|
15
|
-
import io.ktor.utils.io.readAvailable
|
|
16
|
-
|
|
17
|
-
internal object KitsSketchHttpStack : HttpStack {
|
|
18
|
-
private val client by lazy { HttpClient() }
|
|
19
|
-
|
|
20
|
-
override suspend fun <T> request(
|
|
21
|
-
url: String,
|
|
22
|
-
httpHeaders: HttpHeaders?,
|
|
23
|
-
extras: Extras?,
|
|
24
|
-
block: suspend (HttpStack.Response) -> T,
|
|
25
|
-
): T {
|
|
26
|
-
val request = HttpRequestBuilder().apply {
|
|
27
|
-
url(url)
|
|
28
|
-
httpHeaders?.addList?.forEach {
|
|
29
|
-
header(it.first, it.second)
|
|
30
|
-
}
|
|
31
|
-
httpHeaders?.setList?.forEach {
|
|
32
|
-
header(it.first, it.second)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return client.prepareRequest(request).execute {
|
|
36
|
-
block(Response(it))
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Deprecated(
|
|
41
|
-
message = "HttpStack.getResponse is deprecated by Sketch. Use request instead.",
|
|
42
|
-
replaceWith = ReplaceWith("request(url, httpHeaders, extras) { it }")
|
|
43
|
-
)
|
|
44
|
-
override suspend fun getResponse(
|
|
45
|
-
url: String,
|
|
46
|
-
httpHeaders: HttpHeaders?,
|
|
47
|
-
extras: Extras?,
|
|
48
|
-
): HttpStack.Response {
|
|
49
|
-
return request(url, httpHeaders, extras) { it }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
override fun toString(): String = "KitsSketchHttpStack"
|
|
53
|
-
|
|
54
|
-
private class Response(
|
|
55
|
-
private val response: HttpResponse,
|
|
56
|
-
) : HttpStack.Response {
|
|
57
|
-
override val code: Int = response.status.value
|
|
58
|
-
override val message: String = response.status.description
|
|
59
|
-
override val contentLength: Long =
|
|
60
|
-
getHeaderField(io.ktor.http.HttpHeaders.ContentLength)?.toLongOrNull() ?: -1L
|
|
61
|
-
override val contentType: String? = getHeaderField(io.ktor.http.HttpHeaders.ContentType)
|
|
62
|
-
|
|
63
|
-
override fun getHeaderField(name: String): String? = response.headers[name]
|
|
64
|
-
|
|
65
|
-
override suspend fun content(): HttpStack.Content {
|
|
66
|
-
return Content(response.bodyAsChannel())
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private class Content(
|
|
71
|
-
private val channel: ByteReadChannel,
|
|
72
|
-
) : HttpStack.Content {
|
|
73
|
-
override suspend fun read(buffer: ByteArray): Int {
|
|
74
|
-
return channel.readAvailable(buffer, 0, buffer.size)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
override fun close() {
|
|
78
|
-
channel.cancel()
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|