@momo-kits/native-kits 0.162.8-debug → 0.162.9-debug
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.
package/compose/build.gradle.kts
CHANGED
|
@@ -22,7 +22,7 @@ fun NavigationContainer(
|
|
|
22
22
|
initialScreen: @Composable () -> Unit,
|
|
23
23
|
options: NavigationOptions? = null,
|
|
24
24
|
initialTheme: Theme = defaultTheme,
|
|
25
|
-
|
|
25
|
+
miniAppContext: MiniAppContext? = null,
|
|
26
26
|
maxApi: IMaxApi?,
|
|
27
27
|
setNavigator: ((Navigator) -> Unit)? = null,
|
|
28
28
|
statusBarHeight: Dp? = null,
|
|
@@ -35,23 +35,28 @@ fun NavigationContainer(
|
|
|
35
35
|
val navigationBarHeight = getNavigationBarHeight()
|
|
36
36
|
|
|
37
37
|
val parentContext = LocalContext.current
|
|
38
|
-
val mergedContext = MiniAppContext.merge(parentContext,
|
|
38
|
+
val mergedContext = MiniAppContext.merge(parentContext, miniAppContext)
|
|
39
|
+
|
|
40
|
+
val theme = remember { mutableStateOf(initialTheme) }
|
|
41
|
+
val fallbackLocalize = remember { Localize() }
|
|
42
|
+
|
|
43
|
+
val resolvedLocalize = localize ?: fallbackLocalize
|
|
39
44
|
|
|
40
45
|
var observerFontScaleConfig by remember { mutableStateOf(mergedContext?.fontScaleConfig) }
|
|
41
|
-
LaunchedEffect(maxApi) {
|
|
46
|
+
LaunchedEffect(maxApi, resolvedLocalize) {
|
|
42
47
|
val api = maxApi ?: return@LaunchedEffect
|
|
43
48
|
runCatching {
|
|
49
|
+
api.getLanguage(callback = { data ->
|
|
50
|
+
if (parseLanguage(data) == Localize.EN) {
|
|
51
|
+
resolvedLocalize.changeLanguage(Localize.EN)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
44
54
|
api.observer(FONT_SCALE_OBSERVER_KEY).collect { data ->
|
|
45
55
|
observerFontScaleConfig = parseFontScaleConfig(data)
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
59
|
|
|
50
|
-
val theme = remember { mutableStateOf(initialTheme) }
|
|
51
|
-
|
|
52
|
-
val fallbackLocalize = remember { Localize() }
|
|
53
|
-
val resolvedLocalize = localize ?: fallbackLocalize
|
|
54
|
-
|
|
55
60
|
val screenId = rememberSaveable { registry.nextId() }
|
|
56
61
|
registry.bind(screenId, initialScreenName, initialScreen, options)
|
|
57
62
|
val startDestination = remember(screenId) { DynamicScreenRoute(screenId) }
|
|
@@ -148,6 +153,12 @@ val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> {
|
|
|
148
153
|
|
|
149
154
|
private const val FONT_SCALE_OBSERVER_KEY = "font_scale_config"
|
|
150
155
|
|
|
156
|
+
private fun parseLanguage(raw: Map<String, Any?>?): String? {
|
|
157
|
+
val code = (raw?.get("response") as? String)?.trim()?.lowercase()
|
|
158
|
+
if (code.isNullOrEmpty()) return null
|
|
159
|
+
return if (code.startsWith(Localize.EN)) Localize.EN else Localize.VI
|
|
160
|
+
}
|
|
161
|
+
|
|
151
162
|
private fun parseFontScaleConfig(raw: Map<String, Any?>?): FontScaleConfig? {
|
|
152
163
|
if (raw.isNullOrEmpty()) return null
|
|
153
164
|
@Suppress("UNCHECKED_CAST")
|
package/gradle.properties
CHANGED