@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.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.162.8-debug"
43
+ version = "0.162.9-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -22,7 +22,7 @@ fun NavigationContainer(
22
22
  initialScreen: @Composable () -> Unit,
23
23
  options: NavigationOptions? = null,
24
24
  initialTheme: Theme = defaultTheme,
25
- miniappContext: MiniAppContext? = null,
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, miniappContext)
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
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.162.8
21
+ version=0.162.9
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.8-debug",
3
+ "version": "0.162.9-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},