@momo-kits/native-kits 0.89.33-beta.40 → 0.89.33-beta.41

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.
@@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.Box
10
10
  import androidx.compose.foundation.layout.BoxWithConstraints
11
11
  import androidx.compose.foundation.layout.Row
12
12
  import androidx.compose.foundation.layout.Spacer
13
- import androidx.compose.foundation.layout.fillMaxSize
14
13
  import androidx.compose.foundation.layout.fillMaxWidth
15
14
  import androidx.compose.foundation.layout.height
16
15
  import androidx.compose.foundation.layout.padding
@@ -67,7 +66,6 @@ data class AnimatedHeader(
67
66
  @Composable
68
67
  fun HeaderBackground(
69
68
  headerType: HeaderType = HeaderType.DEFAULT,
70
- headerBanner: String? = null,
71
69
  scrollState: Int
72
70
  ) {
73
71
  val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
@@ -75,7 +73,6 @@ fun HeaderBackground(
75
73
  targetValue = (1 - (scrollState / 200f)).coerceIn(0f, 1f),
76
74
  )
77
75
 
78
-
79
76
  val backgroundColor = if (scrollState == 0) {
80
77
  Color.Transparent
81
78
  } else {
@@ -112,7 +109,7 @@ fun HeaderBackground(
112
109
  )
113
110
  if (AppTheme.current.assets.headerBackground != null) {
114
111
  Image(
115
- source = headerBanner ?: AppTheme.current.assets.headerBackground!!,
112
+ source = AppTheme.current.assets.headerBackground!!,
116
113
  modifier = Modifier.fillMaxWidth().height(height),
117
114
  options = Options(
118
115
  contentScale = ContentScale.FillWidth
@@ -125,33 +122,33 @@ fun HeaderBackground(
125
122
 
126
123
  HeaderType.EXTENDED -> {
127
124
 
128
- Box(
129
- modifier = Modifier.fillMaxWidth().height(154.dp)
130
- .alpha(opacityAni)
131
- .background(
132
- Brush.linearGradient(
133
- colors = listOf(
134
- Color(0xFFFDCADE),
135
- Color(0x00FDCADE)
136
- ),
137
- start = Offset(0f, 0f),
138
- end = Offset(0f, with(LocalDensity.current) { 154.dp.toPx() })
139
- )
125
+ Box(
126
+ modifier = Modifier.fillMaxWidth().height(154.dp)
127
+ .alpha(opacityAni)
128
+ .background(
129
+ Brush.linearGradient(
130
+ colors = listOf(
131
+ Color(0xFFFDCADE),
132
+ Color(0x00FDCADE)
133
+ ),
134
+ start = Offset(0f, 0f),
135
+ end = Offset(0f, with(LocalDensity.current) { 154.dp.toPx() })
140
136
  )
141
- ) {
142
- if (AppTheme.current.assets.headerBackground != null) {
143
- Box(
144
- modifier = Modifier.fillMaxWidth()
145
- .background(backgroundColor)
146
- ) {
147
- Image(
148
- source = headerBanner ?: AppTheme.current.assets.headerBackground!!,
149
- modifier = Modifier.fillMaxWidth().height(154.dp),
150
- options = Options(
151
- contentScale = ContentScale.FillWidth
152
- )
137
+ )
138
+ ) {
139
+ if (AppTheme.current.assets.headerBackground != null) {
140
+ Box(
141
+ modifier = Modifier.fillMaxWidth()
142
+ .background(backgroundColor)
143
+ ) {
144
+ Image(
145
+ source = AppTheme.current.assets.headerBackground!!,
146
+ modifier = Modifier.fillMaxWidth().height(154.dp),
147
+ options = Options(
148
+ contentScale = ContentScale.FillWidth
153
149
  )
154
- }
150
+ )
151
+ }
155
152
  }
156
153
  }
157
154
  }
@@ -263,7 +260,7 @@ fun Header(
263
260
  }
264
261
  if (inputSearchProps != null) {
265
262
  InputSearch(inputSearchProps = inputSearchProps.copy(backgroundColor = backgroundSearch))
266
- } else{
263
+ } else {
267
264
  Box(
268
265
  Modifier.weight(1f).graphicsLayer {
269
266
  alpha = if (animatedHeader !== null) opacity ?: 1f else 1f
@@ -2,10 +2,19 @@ package vn.momo.kits.application
2
2
 
3
3
  import androidx.compose.runtime.Composable
4
4
  import androidx.compose.runtime.CompositionLocalProvider
5
+ import androidx.compose.runtime.LaunchedEffect
6
+ import androidx.compose.runtime.getValue
7
+ import androidx.compose.runtime.mutableStateOf
8
+ import androidx.compose.runtime.remember
9
+ import androidx.compose.runtime.setValue
5
10
  import androidx.compose.runtime.staticCompositionLocalOf
11
+ import kotlinx.serialization.json.Json
12
+ import kotlinx.serialization.json.jsonObject
13
+ import kotlinx.serialization.json.jsonPrimitive
6
14
  import vn.momo.kits.const.AppStatusBar
7
15
  import vn.momo.kits.const.AppTheme
8
16
  import vn.momo.kits.const.Theme
17
+ import vn.momo.kits.const.ThemeAssets
9
18
  import vn.momo.kits.const.defaultTheme
10
19
  import vn.momo.kits.platform.disableOverscroll
11
20
  import vn.momo.kits.platform.getStatusBarHeight
@@ -57,13 +66,35 @@ interface ComposeApi {
57
66
 
58
67
  @Composable
59
68
  fun ApplicationContainer(
60
- theme: Theme = defaultTheme,
69
+ theme: Theme? = null,
61
70
  composeApi: ComposeApi,
62
71
  content: @Composable () -> Unit,
63
72
  ) {
73
+ val platformApi = PlatformApi.current
74
+ var appTheme by remember { mutableStateOf(defaultTheme) }
75
+
76
+ LaunchedEffect(Unit) {
77
+ platformApi?.request("getConfig", "DESIGN_SYSTEM") {
78
+ val json = Json { ignoreUnknownKeys = true }
79
+ val response = json.parseToJsonElement(it).jsonObject
80
+ val headerBar = response["response"]
81
+ ?.jsonObject
82
+ ?.get("headerBar")
83
+ ?.jsonPrimitive
84
+ ?.content
85
+ if (headerBar != null) {
86
+ appTheme = defaultTheme.copy(
87
+ assets = ThemeAssets(
88
+ headerBackground = headerBar
89
+ )
90
+ )
91
+ }
92
+ }
93
+ }
94
+
64
95
  disableOverscroll()
65
96
  CompositionLocalProvider(
66
- AppTheme provides theme,
97
+ AppTheme provides (theme ?: appTheme),
67
98
  PlatformApi provides composeApi,
68
99
  AppNavigator provides Navigator(),
69
100
  AppStatusBar provides getStatusBarHeight(),
@@ -19,11 +19,7 @@ import androidx.compose.foundation.layout.systemBars
19
19
  import androidx.compose.foundation.rememberScrollState
20
20
  import androidx.compose.foundation.verticalScroll
21
21
  import androidx.compose.runtime.Composable
22
- import androidx.compose.runtime.LaunchedEffect
23
22
  import androidx.compose.runtime.getValue
24
- import androidx.compose.runtime.mutableStateOf
25
- import androidx.compose.runtime.remember
26
- import androidx.compose.runtime.setValue
27
23
  import androidx.compose.ui.Alignment
28
24
  import androidx.compose.ui.Modifier
29
25
  import androidx.compose.ui.graphics.Color
@@ -36,8 +32,6 @@ import androidx.compose.ui.unit.Dp
36
32
  import androidx.compose.ui.unit.dp
37
33
  import androidx.compose.ui.unit.min
38
34
  import androidx.compose.ui.zIndex
39
- import kotlinx.serialization.json.Json
40
- import kotlinx.serialization.json.jsonObject
41
35
  import vn.momo.kits.components.InputSearchProps
42
36
  import vn.momo.kits.const.AppStatusBar
43
37
  import vn.momo.kits.const.AppTheme
@@ -85,17 +79,6 @@ fun Screen(
85
79
  else -> 0.dp
86
80
  }
87
81
 
88
- val platformApi = PlatformApi.current
89
- var headerBanner by remember { mutableStateOf("") }
90
-
91
- LaunchedEffect(Unit) {
92
- platformApi?.request("getConfig", "DESIGN_SYSTEM") {
93
- val json = Json { ignoreUnknownKeys = true }
94
- val response = json.parseToJsonElement(it).jsonObject.toMap()
95
- headerBanner = response["response"]?.jsonObject?.toMap()?.get("headerBar").toString()
96
- }
97
- }
98
-
99
82
  val indicator = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
100
83
  val bottomPadding = min(indicator, 21.dp)
101
84
 
@@ -117,7 +100,6 @@ fun Screen(
117
100
  HeaderBackground(
118
101
  headerType = headerType,
119
102
  scrollState = scrollState.value,
120
- headerBanner = headerBanner
121
103
  )
122
104
  } else {
123
105
  Box(
@@ -127,7 +109,7 @@ fun Screen(
127
109
  ) {
128
110
  HeaderBackground(
129
111
  headerType = headerType,
130
- scrollState = scrollState.value
112
+ scrollState = scrollState.value,
131
113
  )
132
114
  }
133
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.89.33-beta.40",
3
+ "version": "0.89.33-beta.41",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},