@momo-kits/native-kits 0.89.33-beta.41 → 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.
@@ -6,8 +6,11 @@ import androidx.compose.runtime.LaunchedEffect
6
6
  import androidx.compose.runtime.getValue
7
7
  import androidx.compose.runtime.mutableStateOf
8
8
  import androidx.compose.runtime.remember
9
+ import androidx.compose.runtime.rememberCoroutineScope
9
10
  import androidx.compose.runtime.setValue
10
11
  import androidx.compose.runtime.staticCompositionLocalOf
12
+ import androidx.compose.ui.unit.Dp
13
+ import kotlinx.coroutines.launch
11
14
  import kotlinx.serialization.json.Json
12
15
  import kotlinx.serialization.json.jsonObject
13
16
  import kotlinx.serialization.json.jsonPrimitive
@@ -66,38 +69,46 @@ interface ComposeApi {
66
69
 
67
70
  @Composable
68
71
  fun ApplicationContainer(
69
- theme: Theme? = null,
70
- composeApi: ComposeApi,
72
+ theme: Theme = defaultTheme,
73
+ composeApi: ComposeApi? = null,
71
74
  content: @Composable () -> Unit,
75
+ statusBarHeight: Dp? = AppStatusBar.current ?: getStatusBarHeight()
72
76
  ) {
73
- val platformApi = PlatformApi.current
74
- var appTheme by remember { mutableStateOf(defaultTheme) }
77
+ var appTheme by remember { mutableStateOf(theme) }
78
+ val coroutineScope = rememberCoroutineScope()
75
79
 
76
80
  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
- )
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
+ }
91
99
  }
92
100
  }
101
+ catch (e: Exception) {
102
+ print("@@ == NavigationContainer fetch config error $e")
103
+ }
93
104
  }
94
105
 
95
106
  disableOverscroll()
96
107
  CompositionLocalProvider(
97
- AppTheme provides (theme ?: appTheme),
108
+ AppTheme provides appTheme,
98
109
  PlatformApi provides composeApi,
99
110
  AppNavigator provides Navigator(),
100
- AppStatusBar provides getStatusBarHeight(),
111
+ AppStatusBar provides statusBarHeight,
101
112
  ) {
102
113
  content()
103
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.89.33-beta.41",
3
+ "version": "0.89.33-beta.42",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},