@momo-kits/native-kits 0.162.1-beta.6-debug → 0.162.1-beta.7-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.
@@ -3,7 +3,9 @@ package vn.momo.kits.components
3
3
  import androidx.compose.foundation.border
4
4
  import androidx.compose.foundation.layout.BoxWithConstraints
5
5
  import androidx.compose.runtime.Composable
6
+ import androidx.compose.runtime.LaunchedEffect
6
7
  import androidx.compose.runtime.remember
8
+ import androidx.compose.runtime.rememberUpdatedState
7
9
  import androidx.compose.ui.Alignment
8
10
  import androidx.compose.ui.Modifier
9
11
  import androidx.compose.ui.graphics.ColorFilter
@@ -29,6 +31,10 @@ data class Options(
29
31
  val alpha: Float = DefaultAlpha,
30
32
  )
31
33
 
34
+ enum class ImageState {
35
+ Loading, Success, Error
36
+ }
37
+
32
38
  // Cached domain set for better performance
33
39
  private val supportedDomains = setOf(
34
40
  "static.momocdn.net",
@@ -95,12 +101,14 @@ fun Image(
95
101
  modifier: Modifier = Modifier,
96
102
  options: Options? = null,
97
103
  loading: Boolean = true,
104
+ onLoadingChanged: (Boolean) -> Unit = {},
98
105
  ) {
99
106
  val imageOptions = remember(options) {
100
107
  options ?: Options()
101
108
  }
102
109
 
103
110
  val asyncImageState = rememberAsyncImageState()
111
+ val currentOnLoadingChanged = rememberUpdatedState(onLoadingChanged)
104
112
  val density = LocalDensity.current
105
113
 
106
114
  BoxWithConstraints(
@@ -136,6 +144,16 @@ fun Image(
136
144
  alpha = imageOptions.alpha,
137
145
  )
138
146
 
147
+ val isLoading = when (asyncImageState.painterState) {
148
+ is PainterState.Success,
149
+ is PainterState.Error -> false
150
+ else -> true
151
+ }
152
+
153
+ LaunchedEffect(isLoading) {
154
+ currentOnLoadingChanged.value(isLoading)
155
+ }
156
+
139
157
  when (asyncImageState.painterState) {
140
158
  is PainterState.Success -> {}
141
159
  is PainterState.Error -> {
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.162.1-beta.6
21
+ version=0.162.1-beta.7
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.1-beta.6-debug",
3
+ "version": "0.162.1-beta.7-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},