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

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,22 @@ 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.rememberCoroutineScope
10
+ import androidx.compose.runtime.setValue
5
11
  import androidx.compose.runtime.staticCompositionLocalOf
12
+ import androidx.compose.ui.unit.Dp
13
+ import kotlinx.coroutines.launch
14
+ import kotlinx.serialization.json.Json
15
+ import kotlinx.serialization.json.jsonObject
16
+ import kotlinx.serialization.json.jsonPrimitive
6
17
  import vn.momo.kits.const.AppStatusBar
7
18
  import vn.momo.kits.const.AppTheme
8
19
  import vn.momo.kits.const.Theme
20
+ import vn.momo.kits.const.ThemeAssets
9
21
  import vn.momo.kits.const.defaultTheme
10
22
  import vn.momo.kits.platform.disableOverscroll
11
23
  import vn.momo.kits.platform.getStatusBarHeight
@@ -58,15 +70,45 @@ interface ComposeApi {
58
70
  @Composable
59
71
  fun ApplicationContainer(
60
72
  theme: Theme = defaultTheme,
61
- composeApi: ComposeApi,
73
+ composeApi: ComposeApi? = null,
62
74
  content: @Composable () -> Unit,
75
+ statusBarHeight: Dp? = AppStatusBar.current ?: getStatusBarHeight()
63
76
  ) {
77
+ var appTheme by remember { mutableStateOf(theme) }
78
+ val coroutineScope = rememberCoroutineScope()
79
+
80
+ LaunchedEffect(Unit) {
81
+ try {
82
+ composeApi?.request("getConfig", "DESIGN_SYSTEM") {
83
+ val json = Json { ignoreUnknownKeys = true }
84
+ val response = json.parseToJsonElement(it).jsonObject["response"]
85
+ val headerBar = response
86
+ ?.jsonObject
87
+ ?.get("headerBar")
88
+ ?.jsonPrimitive
89
+ ?.content
90
+ if (headerBar != null && appTheme.assets.headerBackground == null) {
91
+ coroutineScope.launch {
92
+ appTheme = appTheme.copy(
93
+ assets = ThemeAssets(
94
+ headerBackground = headerBar
95
+ )
96
+ )
97
+ }
98
+ }
99
+ }
100
+ }
101
+ catch (e: Exception) {
102
+ print("@@ == NavigationContainer fetch config error $e")
103
+ }
104
+ }
105
+
64
106
  disableOverscroll()
65
107
  CompositionLocalProvider(
66
- AppTheme provides theme,
108
+ AppTheme provides appTheme,
67
109
  PlatformApi provides composeApi,
68
110
  AppNavigator provides Navigator(),
69
- AppStatusBar provides getStatusBarHeight(),
111
+ AppStatusBar provides statusBarHeight,
70
112
  ) {
71
113
  content()
72
114
  }
@@ -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.42",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},