@momo-kits/native-kits 0.113.3-webview.1 → 0.113.3-webview.2
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.
|
@@ -13,20 +13,28 @@ public class MiniAppContext {
|
|
|
13
13
|
public var appName: Any? = nil
|
|
14
14
|
public var appIcon: String = ""
|
|
15
15
|
public var description: Any? = nil
|
|
16
|
-
|
|
17
|
-
public
|
|
16
|
+
public var support: Any? = nil
|
|
17
|
+
public var toolkitConfig: Any? = nil
|
|
18
|
+
public var providerId: String = ""
|
|
19
|
+
public var permissions: Any? = nil
|
|
20
|
+
|
|
21
|
+
public init(appId: String, appCode: String, appName: Any? = nil, appIcon: String, description: Any? = nil, support: Any? = nil, toolkitConfig: Any? = nil, providerId: String, permissions: Any? = nil) {
|
|
18
22
|
self.appId = appId
|
|
19
23
|
self.appCode = appCode
|
|
20
24
|
self.appName = appName
|
|
21
25
|
self.appIcon = appIcon
|
|
22
26
|
self.description = description
|
|
27
|
+
self.support = support
|
|
28
|
+
self.toolkitConfig = toolkitConfig
|
|
29
|
+
self.providerId = providerId
|
|
30
|
+
self.permissions = permissions
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
public class ApplicationEnvironment: ObservableObject {
|
|
27
35
|
let applicationContext: MiniAppContext?
|
|
28
36
|
let composeApi: KitComposeApi
|
|
29
|
-
|
|
37
|
+
|
|
30
38
|
public init(applicationContext: MiniAppContext?, composeApi: KitComposeApi) {
|
|
31
39
|
self.applicationContext = applicationContext
|
|
32
40
|
self.composeApi = composeApi
|
|
@@ -6,7 +6,7 @@ public struct HeaderRightData {
|
|
|
6
6
|
var useMore: Bool
|
|
7
7
|
var tools: [ToolGroup]
|
|
8
8
|
var toolCallback: ((String) -> Void)?
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
public init(
|
|
11
11
|
useShortcut: Bool = false,
|
|
12
12
|
useMore: Bool = false,
|
|
@@ -25,7 +25,7 @@ public struct Tool {
|
|
|
25
25
|
var icon: String
|
|
26
26
|
var showBadge: Bool
|
|
27
27
|
var name: [String: String]
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
public init(
|
|
30
30
|
key: String,
|
|
31
31
|
icon: String,
|
|
@@ -37,7 +37,7 @@ public struct Tool {
|
|
|
37
37
|
self.showBadge = showBadge
|
|
38
38
|
self.name = name
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
func toMap() -> [String: Any] {
|
|
42
42
|
return [
|
|
43
43
|
"key": key,
|
|
@@ -51,7 +51,7 @@ public struct Tool {
|
|
|
51
51
|
public struct ToolGroup {
|
|
52
52
|
var title: [String: String]
|
|
53
53
|
var items: [Tool]
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
public init(
|
|
56
56
|
title: [String: String] = [:],
|
|
57
57
|
items: [Tool]
|
|
@@ -59,7 +59,7 @@ public struct ToolGroup {
|
|
|
59
59
|
self.title = title
|
|
60
60
|
self.items = items
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
func toMap() -> [String: Any] {
|
|
64
64
|
return [
|
|
65
65
|
"title": title,
|
|
@@ -79,7 +79,7 @@ public struct HeaderRight: View {
|
|
|
79
79
|
self.headerRight = headerRight
|
|
80
80
|
}
|
|
81
81
|
var headerRight: HeaderRightData?
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
public var body: some View {
|
|
84
84
|
HStack(alignment: .center) {
|
|
85
85
|
ToolkitHeaderRight(headerRight: headerRight)
|
|
@@ -92,7 +92,7 @@ struct ToolkitHeaderRight: View {
|
|
|
92
92
|
@State private var isFavorite: Bool = false
|
|
93
93
|
@State private var isLoading: Bool = false
|
|
94
94
|
@EnvironmentObject private var environment: ApplicationEnvironment
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
// MARK: - Actions
|
|
97
97
|
private func onPressShortcut() {
|
|
98
98
|
environment.composeApi.request(
|
|
@@ -102,7 +102,7 @@ struct ToolkitHeaderRight: View {
|
|
|
102
102
|
isFavorite.toggle()
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
private func onPressHelpCenter() {
|
|
107
107
|
let context = environment.applicationContext
|
|
108
108
|
let paramMap: [String: Any] = [
|
|
@@ -117,14 +117,15 @@ struct ToolkitHeaderRight: View {
|
|
|
117
117
|
params: paramMap
|
|
118
118
|
) { _ in }
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
private func onPressClose() {
|
|
122
122
|
environment.composeApi.request(
|
|
123
123
|
funcName: "dismiss",
|
|
124
124
|
params: ""
|
|
125
125
|
) { _ in }
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
|
|
128
|
+
|
|
128
129
|
private func onPressMore() {
|
|
129
130
|
let context = environment.applicationContext
|
|
130
131
|
let params: [String: Any] = [
|
|
@@ -134,7 +135,11 @@ struct ToolkitHeaderRight: View {
|
|
|
134
135
|
"code": context?.appCode,
|
|
135
136
|
"name": context?.appName,
|
|
136
137
|
"icon": context?.appIcon,
|
|
137
|
-
"description": context?.description
|
|
138
|
+
"description": context?.description,
|
|
139
|
+
"support": context?.support,
|
|
140
|
+
"toolkitConfig": context?.toolkitConfig,
|
|
141
|
+
"providerId": context?.providerId,
|
|
142
|
+
"permissions": context?.permissions
|
|
138
143
|
]
|
|
139
144
|
]
|
|
140
145
|
environment.composeApi.request(
|
|
@@ -152,12 +157,12 @@ struct ToolkitHeaderRight: View {
|
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
|
-
|
|
160
|
+
|
|
156
161
|
private func getNavigationButtonConfig() -> NavigationButtonConfig {
|
|
157
162
|
let totalTools = headerRight?.tools.reduce(0) { $0 + $1.items.count } ?? 0
|
|
158
163
|
var icon = isFavorite ? "pin_star_checked" : "pin_star"
|
|
159
164
|
var onClickHandler: () -> Void = onPressShortcut
|
|
160
|
-
|
|
165
|
+
|
|
161
166
|
if totalTools > 1 || headerRight?.useMore == true {
|
|
162
167
|
icon = "navigation_more_icon"
|
|
163
168
|
onClickHandler = onPressMore
|
|
@@ -167,16 +172,16 @@ struct ToolkitHeaderRight: View {
|
|
|
167
172
|
headerRight?.toolCallback?(singleTool.key)
|
|
168
173
|
}
|
|
169
174
|
}
|
|
170
|
-
|
|
175
|
+
|
|
171
176
|
return NavigationButtonConfig(icon: icon, onPress: onClickHandler)
|
|
172
177
|
}
|
|
173
|
-
|
|
178
|
+
|
|
174
179
|
var body: some View {
|
|
175
180
|
let navButtonConfig = getNavigationButtonConfig()
|
|
176
181
|
let showBadge = headerRight?.tools.contains { group in
|
|
177
182
|
group.items.contains { $0.showBadge }
|
|
178
183
|
} ?? false
|
|
179
|
-
|
|
184
|
+
|
|
180
185
|
HStack(alignment: .center) {
|
|
181
186
|
if headerRight?.useShortcut == true {
|
|
182
187
|
NavigationButton(
|
|
@@ -186,18 +191,18 @@ struct ToolkitHeaderRight: View {
|
|
|
186
191
|
onClick: navButtonConfig.onPress
|
|
187
192
|
)
|
|
188
193
|
}
|
|
189
|
-
|
|
194
|
+
|
|
190
195
|
HStack(alignment: .center, spacing: 0) {
|
|
191
196
|
Icon(source: "help_center", size: 20)
|
|
192
197
|
.padding(4)
|
|
193
198
|
.onTapGesture {
|
|
194
199
|
onPressHelpCenter()
|
|
195
200
|
}
|
|
196
|
-
|
|
201
|
+
|
|
197
202
|
Rectangle()
|
|
198
203
|
.fill(Colors.black20)
|
|
199
204
|
.frame(width: 0.5, height: 12)
|
|
200
|
-
|
|
205
|
+
|
|
201
206
|
Icon(source: "16_navigation_close_circle", size: 20, color: Colors.black17)
|
|
202
207
|
.padding(4)
|
|
203
208
|
.onTapGesture {
|
|
@@ -221,7 +226,7 @@ struct NavigationButton: View {
|
|
|
221
226
|
var icon: String
|
|
222
227
|
var showBadge: Bool
|
|
223
228
|
var onClick: () -> Void
|
|
224
|
-
|
|
229
|
+
|
|
225
230
|
var body: some View {
|
|
226
231
|
ZStack {
|
|
227
232
|
Circle()
|
|
@@ -230,9 +235,9 @@ struct NavigationButton: View {
|
|
|
230
235
|
Circle()
|
|
231
236
|
.stroke(Color.black.opacity(0.2), lineWidth: 0.2)
|
|
232
237
|
)
|
|
233
|
-
|
|
238
|
+
|
|
234
239
|
Icon(source: icon, size: 16)
|
|
235
|
-
|
|
240
|
+
|
|
236
241
|
if showBadge {
|
|
237
242
|
BadgeDot(size: .small)
|
|
238
243
|
.offset(x: -2, y: -2)
|