@momo-kits/native-kits 0.89.33-beta.27 → 0.89.33-beta.32

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.
@@ -39,6 +39,8 @@ kotlin {
39
39
  implementation(libs.coil.multiplatform.compose)
40
40
  implementation(libs.coil.multiplatform.core)
41
41
  implementation(libs.coil.multiplatform.network.ktor)
42
+ implementation("com.google.code.gson:gson:2.10")
43
+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
42
44
  }
43
45
  }
44
46
  val androidMain by getting {
@@ -66,6 +66,7 @@ data class AnimatedHeader(
66
66
  @Composable
67
67
  fun HeaderBackground(
68
68
  headerType: HeaderType = HeaderType.DEFAULT,
69
+ headerBanner: String? = null,
69
70
  scrollState: Int
70
71
  ) {
71
72
  val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
@@ -101,7 +102,7 @@ fun HeaderBackground(
101
102
  )
102
103
  if (AppTheme.current.assets.headerBackground != null) {
103
104
  Image(
104
- source = AppTheme.current.assets.headerBackground!!,
105
+ source = headerBanner ?: AppTheme.current.assets.headerBackground!!,
105
106
  modifier = Modifier.fillMaxWidth().height(height),
106
107
  options = Options(
107
108
  contentScale = ContentScale.FillWidth
@@ -129,7 +130,7 @@ fun HeaderBackground(
129
130
  ) {
130
131
  if (AppTheme.current.assets.headerBackground != null) {
131
132
  Image(
132
- source = AppTheme.current.assets.headerBackground!!,
133
+ source = headerBanner ?: AppTheme.current.assets.headerBackground!!,
133
134
  modifier = Modifier.fillMaxWidth().height(154.dp),
134
135
  options = Options(
135
136
  contentScale = ContentScale.FillWidth
@@ -1,8 +1,5 @@
1
1
  package vn.momo.kits.application
2
2
 
3
- import androidx.compose.foundation.layout.WindowInsets
4
- import androidx.compose.foundation.layout.asPaddingValues
5
- import androidx.compose.foundation.layout.systemBars
6
3
  import androidx.compose.runtime.Composable
7
4
  import androidx.compose.runtime.CompositionLocalProvider
8
5
  import androidx.compose.runtime.staticCompositionLocalOf
@@ -17,6 +14,10 @@ val AppNavigator = staticCompositionLocalOf<Navigator> {
17
14
  error("no navigator provided!")
18
15
  }
19
16
 
17
+ val PlatformApi = staticCompositionLocalOf<ComposeApi> {
18
+ error("no api provided!")
19
+ }
20
+
20
21
  class Navigator {
21
22
  fun push(content: @Composable () -> Unit) {
22
23
  }
@@ -49,14 +50,23 @@ class Navigator {
49
50
  }
50
51
  }
51
52
 
53
+ interface ComposeApi {
54
+ fun request(funcName: String, params: String?): String
55
+ fun request(funcName: String, params: String?, onResponse: ((String) -> Unit)?): String
56
+ fun requestCallback(funcName: String, params: String?, onResponse: ((String) -> Unit)?)
57
+ fun removeCallback(id: String)
58
+ }
59
+
52
60
  @Composable
53
61
  fun ApplicationContainer(
54
62
  theme: Theme = defaultTheme,
63
+ composeApi: ComposeApi,
55
64
  content: @Composable () -> Unit,
56
65
  ) {
57
66
  disableOverscroll()
58
67
  CompositionLocalProvider(
59
68
  AppTheme provides theme,
69
+ PlatformApi provides composeApi,
60
70
  AppNavigator provides Navigator(),
61
71
  AppStatusBar provides getStatusBarHeight(),
62
72
  ) {
@@ -32,6 +32,7 @@ import androidx.compose.ui.unit.Dp
32
32
  import androidx.compose.ui.unit.dp
33
33
  import androidx.compose.ui.unit.min
34
34
  import androidx.compose.ui.zIndex
35
+ import kotlinx.serialization.json.Json
35
36
  import vn.momo.kits.components.InputSearchProps
36
37
  import vn.momo.kits.const.AppStatusBar
37
38
  import vn.momo.kits.const.AppTheme
@@ -47,6 +48,8 @@ enum class HeaderType {
47
48
  NONE
48
49
  }
49
50
 
51
+ data class ConfigData(val headerBanner: String)
52
+
50
53
  @Composable
51
54
  fun Screen(
52
55
  backgroundColor: Color? = null,
@@ -79,6 +82,11 @@ fun Screen(
79
82
  else -> 0.dp
80
83
  }
81
84
 
85
+ val platformApi = PlatformApi.current
86
+ val rawData = platformApi.request("GetConfig", "DESIGN_SYSTEM")
87
+ val json = Json {ignoreUnknownKeys = true}
88
+ val headerBanner = json.decodeFromString<ConfigData>(rawData).headerBanner
89
+
82
90
  val indicator = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
83
91
  val bottomPadding = min(indicator, 21.dp)
84
92
 
@@ -95,7 +103,7 @@ fun Screen(
95
103
  ) {
96
104
 
97
105
  if (animatedHeader === null) {
98
- HeaderBackground(headerType = headerType, scrollState = scrollState.value)
106
+ HeaderBackground(headerType = headerType, scrollState = scrollState.value, headerBanner=headerBanner)
99
107
  } else {
100
108
  Box(
101
109
  Modifier.zIndex(2f)
@@ -98,7 +98,6 @@ data class InputSearchProps(
98
98
  val keyboardActions: KeyboardActions = KeyboardActions.Default,
99
99
  val modifier: Modifier = Modifier,
100
100
  val iconModifier: Modifier = Modifier,
101
- val onClearPress: () -> Unit = {}
102
101
  )
103
102
 
104
103
  @Composable
@@ -196,10 +195,7 @@ fun InputSearch(
196
195
  size = 16.dp,
197
196
  color = AppTheme.current.colors.text.hint,
198
197
  modifier = Modifier.clickable(
199
- onClick = {
200
- inputSearchProps.text.value = ""
201
- inputSearchProps.onClearPress.invoke()
202
- },
198
+ onClick = { inputSearchProps.text.value = "" },
203
199
  interactionSource = remember { MutableInteractionSource() },
204
200
  indication = null
205
201
  )
@@ -106,7 +106,7 @@ val defaultTheme = Theme(
106
106
  ),
107
107
  font = "SFProText",
108
108
  assets = ThemeAssets(
109
- headerBackground = null
109
+ headerBackground = "https://static.momocdn.net/app/img/kits/background/header/header_Tet_2024_transparent.png"
110
110
  )
111
111
  )
112
112
 
@@ -162,7 +162,7 @@ val darkTheme = Theme(
162
162
  ),
163
163
  font = "SFProText",
164
164
  assets = ThemeAssets(
165
- headerBackground = "https://static.momocdn.net/app/img/app/img/header-background.png"
165
+ headerBackground = "https://static.momocdn.net/app/img/kits/background/header/header_Tet_2024_transparent.png"
166
166
  )
167
167
  )
168
168
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.89.33-beta.27",
3
+ "version": "0.89.33-beta.32",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},