@momo-kits/native-kits 0.112.1-beta.13 → 0.112.1-beta.15
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/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +14 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +4 -2
- package/ios/Application/HeaderRight.swift +14 -6
- package/ios/Badge/BadgeDot.swift +1 -12
- package/ios/Icon/Icon.swift +3 -3
- package/package.json +1 -1
- package/ios/Application/Badge.swift +0 -1
|
@@ -27,6 +27,9 @@ import vn.momo.kits.components.BadgeDot
|
|
|
27
27
|
import vn.momo.kits.components.DotSize
|
|
28
28
|
import vn.momo.kits.components.Icon
|
|
29
29
|
import vn.momo.kits.const.Colors
|
|
30
|
+
import kotlinx.serialization.json.Json
|
|
31
|
+
import kotlinx.serialization.json.jsonObject
|
|
32
|
+
import kotlinx.serialization.json.jsonPrimitive
|
|
30
33
|
|
|
31
34
|
data class HeaderRightData(
|
|
32
35
|
val useShortcut: Boolean = false,
|
|
@@ -127,8 +130,16 @@ fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
|
|
|
127
130
|
"description" to context?.description
|
|
128
131
|
)
|
|
129
132
|
)
|
|
130
|
-
) {
|
|
131
|
-
|
|
133
|
+
) { response ->
|
|
134
|
+
try {
|
|
135
|
+
val json = Json.parseToJsonElement(response).jsonObject
|
|
136
|
+
val toolResponse = json["response"]?.jsonPrimitive?.content
|
|
137
|
+
if (toolResponse != null) {
|
|
138
|
+
headerRight?.toolCallback?.invoke(toolResponse)
|
|
139
|
+
}
|
|
140
|
+
} catch (e: Exception) {
|
|
141
|
+
println("Error parsing response: $e")
|
|
142
|
+
}
|
|
132
143
|
}
|
|
133
144
|
}
|
|
134
145
|
|
|
@@ -238,7 +249,7 @@ fun NavigationButton(
|
|
|
238
249
|
)
|
|
239
250
|
}
|
|
240
251
|
|
|
241
|
-
if (showBadge
|
|
252
|
+
if (showBadge == true) {
|
|
242
253
|
BadgeDot(
|
|
243
254
|
size = DotSize.Small,
|
|
244
255
|
modifier = Modifier
|
|
@@ -68,7 +68,7 @@ val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
|
|
|
68
68
|
fun ApplicationContainer(
|
|
69
69
|
theme: Theme = defaultTheme,
|
|
70
70
|
composeApi: ComposeApi? = null,
|
|
71
|
-
statusBarHeight: Dp? =
|
|
71
|
+
statusBarHeight: Dp? = null,
|
|
72
72
|
applicationContext: MiniAppContext? = null,
|
|
73
73
|
content: @Composable () -> Unit,
|
|
74
74
|
) {
|
|
@@ -100,12 +100,14 @@ fun ApplicationContainer(
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
val appStatusBarHeight = statusBarHeight ?: getStatusBarHeight()
|
|
104
|
+
|
|
103
105
|
disableOverscroll()
|
|
104
106
|
CompositionLocalProvider(
|
|
105
107
|
AppTheme provides appTheme,
|
|
106
108
|
PlatformApi provides composeApi,
|
|
107
109
|
AppNavigator provides Navigator(),
|
|
108
|
-
AppStatusBar provides
|
|
110
|
+
AppStatusBar provides appStatusBarHeight,
|
|
109
111
|
ApplicationContext provides applicationContext,
|
|
110
112
|
) {
|
|
111
113
|
content()
|
|
@@ -29,8 +29,8 @@ public struct Tool {
|
|
|
29
29
|
public init(
|
|
30
30
|
key: String,
|
|
31
31
|
icon: String,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
name: [String: String] = [:],
|
|
33
|
+
showBadge: Bool = false
|
|
34
34
|
) {
|
|
35
35
|
self.key = key
|
|
36
36
|
self.icon = icon
|
|
@@ -116,8 +116,6 @@ struct ToolkitHeaderRight: View {
|
|
|
116
116
|
funcName: "showHelpCenter",
|
|
117
117
|
params: paramMap
|
|
118
118
|
) { _ in }
|
|
119
|
-
|
|
120
|
-
print("Press help center")
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
private func onPressClose() {
|
|
@@ -142,7 +140,17 @@ struct ToolkitHeaderRight: View {
|
|
|
142
140
|
environment.composeApi.request(
|
|
143
141
|
funcName: "showTools",
|
|
144
142
|
params: params
|
|
145
|
-
) {
|
|
143
|
+
) { response in
|
|
144
|
+
do {
|
|
145
|
+
if let jsonData = response.data(using: .utf8),
|
|
146
|
+
let json = try JSONSerialization.jsonObject(with: jsonData) as? [String: Any],
|
|
147
|
+
let toolResponse = json["response"] as? String {
|
|
148
|
+
headerRight?.toolCallback?(toolResponse)
|
|
149
|
+
}
|
|
150
|
+
} catch {
|
|
151
|
+
print("Error parsing response:", error)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
private func getNavigationButtonConfig() -> NavigationButtonConfig {
|
|
@@ -190,7 +198,7 @@ struct ToolkitHeaderRight: View {
|
|
|
190
198
|
.fill(Colors.black20)
|
|
191
199
|
.frame(width: 0.5, height: 12)
|
|
192
200
|
|
|
193
|
-
Icon(source: "16_navigation_close_circle", size: 20)
|
|
201
|
+
Icon(source: "16_navigation_close_circle", size: 20, color: Colors.black17)
|
|
194
202
|
.padding(4)
|
|
195
203
|
.onTapGesture {
|
|
196
204
|
onPressClose()
|
package/ios/Badge/BadgeDot.swift
CHANGED
|
@@ -28,15 +28,4 @@ public struct BadgeDot: View {
|
|
|
28
28
|
.stroke(Colors.black01, lineWidth: 1)
|
|
29
29
|
)
|
|
30
30
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
#if DEBUG
|
|
34
|
-
struct BadgeDot_Previews: PreviewProvider {
|
|
35
|
-
static var previews: some View {
|
|
36
|
-
VStack(spacing: 10) {
|
|
37
|
-
BadgeDot(size: .small)
|
|
38
|
-
BadgeDot(size: .large)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
#endif
|
|
31
|
+
}
|
package/ios/Icon/Icon.swift
CHANGED
|
@@ -43,11 +43,11 @@ public struct Icon: View {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public var body: some View {
|
|
46
|
-
|
|
47
|
-
ImageView(
|
|
46
|
+
if let uri = iconSources[source]?.uri {
|
|
47
|
+
ImageView(uri)
|
|
48
48
|
.frame(width: size, height: size)
|
|
49
49
|
.foregroundColor(color)
|
|
50
|
-
|
|
50
|
+
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|