@momo-kits/native-kits 0.162.1-beta.5-debug → 0.162.1-beta.6-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.
@@ -77,6 +77,10 @@ kotlin {
77
77
  implementation(libs.kotlinx.datetime)
78
78
  api(libs.native.max.api)
79
79
  implementation(libs.compottie)
80
+ implementation(libs.sketch.compose)
81
+ implementation(libs.sketch.http)
82
+ implementation(libs.sketch.animated.core)
83
+ implementation(libs.sketch.animated.gif)
80
84
  }
81
85
  androidMain.dependencies {
82
86
  implementation(libs.ktor.client.okhttp)
@@ -77,6 +77,10 @@ kotlin {
77
77
  implementation(libs.kotlinx.datetime)
78
78
  api(libs.native.max.api)
79
79
  implementation(libs.compottie)
80
+ implementation(libs.sketch.compose)
81
+ implementation(libs.sketch.http)
82
+ implementation(libs.sketch.animated.core)
83
+ implementation(libs.sketch.animated.gif)
80
84
  }
81
85
  androidMain.dependencies {
82
86
  implementation(libs.ktor.client.okhttp)
@@ -3,10 +3,7 @@ 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.getValue
7
- import androidx.compose.runtime.mutableStateOf
8
6
  import androidx.compose.runtime.remember
9
- import androidx.compose.runtime.setValue
10
7
  import androidx.compose.ui.Alignment
11
8
  import androidx.compose.ui.Modifier
12
9
  import androidx.compose.ui.graphics.ColorFilter
@@ -17,7 +14,9 @@ import androidx.compose.ui.semantics.contentDescription
17
14
  import androidx.compose.ui.semantics.semantics
18
15
  import androidx.compose.ui.platform.LocalDensity
19
16
  import androidx.compose.ui.unit.dp
20
- import coil3.compose.AsyncImage
17
+ import com.github.panpf.sketch.AsyncImage as SketchAsyncImage
18
+ import com.github.panpf.sketch.PainterState
19
+ import com.github.panpf.sketch.rememberAsyncImageState
21
20
  import vn.momo.kits.application.IsShowBaseLineDebug
22
21
  import vn.momo.kits.const.AppTheme
23
22
  import vn.momo.kits.const.Colors
@@ -30,10 +29,6 @@ data class Options(
30
29
  val alpha: Float = DefaultAlpha,
31
30
  )
32
31
 
33
- enum class ImageState {
34
- Loading, Success, Error
35
- }
36
-
37
32
  // Cached domain set for better performance
38
33
  private val supportedDomains = setOf(
39
34
  "static.momocdn.net",
@@ -73,6 +68,11 @@ private fun getHostFromUrl(url: String): String? {
73
68
  }
74
69
  }
75
70
 
71
+ private fun isGifUrl(url: String): Boolean {
72
+ val path = url.substringBefore('#').substringBefore('?')
73
+ return path.endsWith(".gif", ignoreCase = true)
74
+ }
75
+
76
76
  // Optimized query parameter appending
77
77
  private fun appendSizeQueryParam(url: String, value: String): String {
78
78
  val fragmentIndex = url.indexOf('#')
@@ -100,7 +100,7 @@ fun Image(
100
100
  options ?: Options()
101
101
  }
102
102
 
103
- var imageState by remember { mutableStateOf(ImageState.Loading) }
103
+ val asyncImageState = rememberAsyncImageState()
104
104
  val density = LocalDensity.current
105
105
 
106
106
  BoxWithConstraints(
@@ -121,26 +121,24 @@ fun Image(
121
121
  processedUrl
122
122
  }
123
123
  }
124
- else -> source
124
+ else -> source.toString()
125
125
  }
126
126
  }
127
127
 
128
- AsyncImage(
128
+ SketchAsyncImage(
129
129
  modifier = Modifier.matchParentSize(),
130
- model = urlToLoad,
130
+ uri = urlToLoad,
131
+ state = asyncImageState,
131
132
  contentDescription = null,
132
133
  contentScale = imageOptions.contentScale,
133
134
  alignment = imageOptions.alignment,
134
135
  colorFilter = imageOptions.colorFilter,
135
136
  alpha = imageOptions.alpha,
136
- onLoading = { imageState = ImageState.Loading },
137
- onSuccess = { imageState = ImageState.Success },
138
- onError = { imageState = ImageState.Error },
139
137
  )
140
138
 
141
- when (imageState) {
142
- ImageState.Loading -> if (loading) Skeleton()
143
- ImageState.Error -> {
139
+ when (asyncImageState.painterState) {
140
+ is PainterState.Success -> {}
141
+ is PainterState.Error -> {
144
142
  val theme = AppTheme.current
145
143
  Icon(
146
144
  source = "media_fail",
@@ -148,7 +146,7 @@ fun Image(
148
146
  modifier = Modifier.align(Alignment.Center)
149
147
  )
150
148
  }
151
- ImageState.Success -> {}
149
+ else -> if (loading) Skeleton()
152
150
  }
153
151
  }
154
152
  }
@@ -156,7 +154,7 @@ fun Image(
156
154
  // Extracted URL processing logic for better performance
157
155
  private fun processImageUrl(url: String, maxWidth: androidx.compose.ui.unit.Dp, density: androidx.compose.ui.unit.Density): String {
158
156
  val host = getHostFromUrl(url)
159
- return if (host != null && supportedDomains.contains(host)) {
157
+ return if (!isGifUrl(url) && host != null && supportedDomains.contains(host)) {
160
158
  val widthPx = with(density) { maxWidth.roundToPx() }
161
159
  val pixelRatio = density.density
162
160
  val pixelFitForWidth = widthPx * pixelRatio
@@ -185,4 +183,4 @@ fun Image(
185
183
  colorFilter = colorFilter,
186
184
  alpha = alpha,
187
185
  )
188
- }
186
+ }
@@ -23,7 +23,7 @@ import vn.momo.kits.application.IsShowBaseLineDebug
23
23
  import vn.momo.kits.const.*
24
24
  import vn.momo.kits.modifier.conditional
25
25
 
26
- const val MAX_LENGTH = 300
26
+ internal const val MAX_LENGTH = 300
27
27
  internal val DEFAULT_HEIGHT = 104.dp
28
28
 
29
29
  @Composable
@@ -23,7 +23,6 @@ import vn.momo.kits.navigation.LocalNavigator
23
23
  import vn.momo.kits.navigation.NavigationOptions
24
24
  import vn.momo.kits.navigation.StackScreen
25
25
  import vn.momo.kits.navigation.component.HeaderType
26
- import vn.momo.kits.platform.getScreenHeight
27
26
 
28
27
  private var bottomTabOptionItems : MutableList<NavigationOptions?> = mutableListOf()
29
28
  internal fun setBottomTabOption(index: Int, options: NavigationOptions){
@@ -45,6 +44,8 @@ fun BottomTab(
45
44
  val navigation = LocalNavigation.current
46
45
  val navigator = LocalNavigator.current
47
46
  val navController = rememberNavController()
47
+ val keyboardBottomPadding = WindowInsets.ime.asPaddingValues().calculateBottomPadding()
48
+ val shouldShowBottomTab = keyboardBottomPadding == 0.dp
48
49
 
49
50
  bottomTabOptionItems = items.mapIndexed { index, item ->
50
51
  item.options ?: NavigationOptions()
@@ -57,10 +58,16 @@ fun BottomTab(
57
58
  )
58
59
  }
59
60
 
60
- Box(modifier = Modifier.fillMaxWidth().height(getScreenHeight()), contentAlignment = Alignment.BottomCenter) {
61
+ Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) {
61
62
  Box(modifier = Modifier
62
63
  .fillMaxSize()
63
- .padding(bottom = BOTTOM_TAB_BAR_HEIGHT.dp + AppNavigationBar.current)
64
+ .padding(
65
+ bottom = if (shouldShowBottomTab) {
66
+ BOTTOM_TAB_BAR_HEIGHT.dp + AppNavigationBar.current
67
+ } else {
68
+ 0.dp
69
+ }
70
+ )
64
71
  ) {
65
72
  NavHost(
66
73
  navController = navController,
@@ -119,20 +126,22 @@ fun BottomTab(
119
126
  }
120
127
  }
121
128
  }
122
- Column {
123
- BottomTabBar(
124
- items = items,
125
- floatingButton = floatingButton,
126
- navController = navController,
127
- onTabSelected = {
128
- val currentRoute = navController.currentBackStackEntry?.destination?.route
129
- val targetRoute = "option$it"
130
- if (currentRoute != targetRoute){
131
- navController.navigate(targetRoute)
129
+ if (shouldShowBottomTab) {
130
+ Column {
131
+ BottomTabBar(
132
+ items = items,
133
+ floatingButton = floatingButton,
134
+ navController = navController,
135
+ onTabSelected = {
136
+ val currentRoute = navController.currentBackStackEntry?.destination?.route
137
+ val targetRoute = "option$it"
138
+ if (currentRoute != targetRoute) {
139
+ navController.navigate(targetRoute)
140
+ }
132
141
  }
133
- }
134
- )
135
- Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
142
+ )
143
+ Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
144
+ }
136
145
  }
137
146
  }
138
147
  }
@@ -28,7 +28,7 @@ import vn.momo.kits.modifier.noFeedbackClickable
28
28
  import vn.momo.kits.platform.getScreenDimensions
29
29
 
30
30
  internal val floatingButtonWidth = 75.dp
31
- const val BOTTOM_TAB_BAR_HEIGHT = 64
31
+ internal const val BOTTOM_TAB_BAR_HEIGHT = 64
32
32
 
33
33
  @Composable
34
34
  internal fun BottomTabBar(
@@ -44,7 +44,7 @@ import vn.momo.kits.navigation.LocalOptions
44
44
  import vn.momo.kits.navigation.LocalScrollState
45
45
  import vn.momo.kits.navigation.getInputSearchType
46
46
 
47
- const val HEADER_HEIGHT = 52
47
+ internal const val HEADER_HEIGHT = 52
48
48
  internal enum class InputSearchType { None, Header, Animated }
49
49
  enum class TitlePosition { LEFT, CENTER }
50
50
 
@@ -21,6 +21,7 @@ maxapi = "0.1.1"
21
21
  vanniktechMavenPublish = "0.34.0"
22
22
  kits = "0.159.1-beta.7"
23
23
  nativemaxapi = "0.0.6"
24
+ sketch = "4.4.0"
24
25
 
25
26
  [libraries]
26
27
  ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor-version" }
@@ -53,6 +54,10 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a
53
54
  androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
54
55
  material = { module = "com.google.android.material:material", version.ref = "material" }
55
56
 
57
+ sketch-compose = { module = "io.github.panpf.sketch4:sketch-compose", version.ref = "sketch" }
58
+ sketch-http = { module = "io.github.panpf.sketch4:sketch-http", version.ref = "sketch" }
59
+ sketch-animated-core = { module = "io.github.panpf.sketch4:sketch-animated-core", version.ref = "sketch" }
60
+ sketch-animated-gif = { module = "io.github.panpf.sketch4:sketch-animated-gif", version.ref = "sketch" }
56
61
  [plugins]
57
62
  jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
58
63
  jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
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.5
21
+ version=0.162.1-beta.6
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.5-debug",
3
+ "version": "0.162.1-beta.6-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},