@momo-kits/native-kits 0.112.1-beta.4 → 0.112.1-beta.6

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.
@@ -22,8 +22,6 @@ import vn.momo.kits.const.defaultTheme
22
22
  import vn.momo.kits.platform.disableOverscroll
23
23
  import vn.momo.kits.platform.getStatusBarHeight
24
24
 
25
- val PlatformApi = staticCompositionLocalOf<Any?> { null }
26
-
27
25
  interface ComposeApi {
28
26
  fun request(funcName: String, params: String?): String
29
27
  fun request(funcName: String, params: String?, onResponse: ((String) -> Unit)?): String
@@ -31,10 +29,6 @@ interface ComposeApi {
31
29
  fun removeCallback(id: String)
32
30
  }
33
31
 
34
- val AppNavigator = staticCompositionLocalOf<Navigator> {
35
- error("no navigator provided!")
36
- }
37
-
38
32
  class Navigator {
39
33
  fun push(content: @Composable () -> Unit) {
40
34
  }
@@ -67,11 +61,30 @@ class Navigator {
67
61
  }
68
62
  }
69
63
 
64
+ data class MiniAppContext(
65
+ private val appIcon: String = "",
66
+ private val appName: String = "",
67
+ val appId: String = "",
68
+ val appCode: String = "",
69
+ private val description: String? = "",
70
+ )
71
+
72
+ val PlatformApi = staticCompositionLocalOf<Any?> { null }
73
+
74
+ val AppNavigator = staticCompositionLocalOf<Navigator> {
75
+ error("no navigator provided!")
76
+ }
77
+
78
+ val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
79
+ error("no context provided!")
80
+ }
81
+
70
82
  @Composable
71
83
  fun ApplicationContainer(
72
84
  theme: Theme = defaultTheme,
73
85
  composeApi: ComposeApi? = null,
74
86
  statusBarHeight: Dp? = AppStatusBar.current ?: getStatusBarHeight(),
87
+ applicationContext: MiniAppContext? = null,
75
88
  content: @Composable () -> Unit
76
89
  ) {
77
90
  var appTheme by remember { mutableStateOf(theme) }
@@ -97,8 +110,7 @@ fun ApplicationContainer(
97
110
  }
98
111
  }
99
112
  }
100
- }
101
- catch (e: Exception) {
113
+ } catch (e: Exception) {
102
114
  print("@@ == NavigationContainer fetch config error $e")
103
115
  }
104
116
  }
@@ -109,6 +121,7 @@ fun ApplicationContainer(
109
121
  PlatformApi provides composeApi,
110
122
  AppNavigator provides Navigator(),
111
123
  AppStatusBar provides statusBarHeight,
124
+ ApplicationContext provides applicationContext
112
125
  ) {
113
126
  content()
114
127
  }
@@ -23,10 +23,11 @@ import androidx.compose.ui.Modifier
23
23
  import androidx.compose.ui.draw.clip
24
24
  import androidx.compose.ui.graphics.Color
25
25
  import androidx.compose.ui.unit.dp
26
- import vn.momo.compose.utils.datamapping.ModelConvertUtils
26
+ import vn.momo.kits.application.ApplicationContext
27
27
  import vn.momo.kits.application.ComposeApi
28
28
  import vn.momo.kits.application.PlatformApi
29
29
  import vn.momo.kits.const.Colors
30
+ import vn.momo.kits.utils.ModelConvertUtils
30
31
 
31
32
  data class HeaderRightData(
32
33
  val useOnBoarding: Boolean = false,
@@ -78,6 +79,7 @@ fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
78
79
  var isFavorite by remember { mutableStateOf(false) }
79
80
  val isLoading by remember { mutableStateOf(false) }
80
81
  val api = PlatformApi.current as? ComposeApi
82
+ val context = ApplicationContext.current
81
83
 
82
84
  fun onPressShortcut() {
83
85
  isFavorite = !isFavorite
@@ -85,10 +87,7 @@ fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
85
87
 
86
88
  fun onPressHelpCenter() {
87
89
  val params = ModelConvertUtils.encodeToJsonFromAny(
88
- arrayOf<Any>(
89
- mapOf("title" to "title"),
90
- mapOf("title" to "title")
91
- )
90
+ mapOf("context" to context),
92
91
  ).toString()
93
92
  api?.request("showHelpCenter", params, {})
94
93
  }
@@ -1,4 +1,4 @@
1
- package vn.momo.compose.utils.datamapping
1
+ package vn.momo.kits.utils
2
2
 
3
3
  import kotlinx.serialization.json.Json
4
4
  import kotlinx.serialization.json.JsonArray
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.112.1-beta.4",
3
+ "version": "0.112.1-beta.6",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},