@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
|
|
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
|
-
|
|
74
|
-
|
|
77
|
+
var appTheme by remember { mutableStateOf(theme) }
|
|
78
|
+
val coroutineScope = rememberCoroutineScope()
|
|
75
79
|
|
|
76
80
|
LaunchedEffect(Unit) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
appTheme
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
108
|
+
AppTheme provides appTheme,
|
|
98
109
|
PlatformApi provides composeApi,
|
|
99
110
|
AppNavigator provides Navigator(),
|
|
100
|
-
AppStatusBar provides
|
|
111
|
+
AppStatusBar provides statusBarHeight,
|
|
101
112
|
) {
|
|
102
113
|
content()
|
|
103
114
|
}
|