@momo-kits/native-kits 0.162.29-debug → 0.162.30-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.29-debug"
43
+ version = "0.162.30-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
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.29
21
+ version=0.162.30
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
@@ -105,9 +105,25 @@ struct ToolkitHeaderRight: View {
105
105
 
106
106
  // MARK: - Actions
107
107
  private func onPressShortcut() {
108
+ // onToolAction needs the app context (appId/code) so the host knows which app to (un)favorite;
109
+ // without it the favorite is a no-op. Mirrors onPressMore below and the Compose HeaderRight.
110
+ let context = environment.applicationContext
108
111
  environment.composeApi?.request(
109
112
  funcName: "onToolAction",
110
- params: ["item": ["key": "onFavorite"]]
113
+ params: [
114
+ "item": ["key": "onFavorite"],
115
+ "context": [
116
+ "appId": context?.appId,
117
+ "code": context?.appCode,
118
+ "name": context?.appName,
119
+ "icon": context?.appIcon,
120
+ "description": context?.description,
121
+ "support": context?.support,
122
+ "toolkitConfig": context?.toolkitConfig,
123
+ "providerId": context?.providerId,
124
+ "permissions": context?.permissions
125
+ ]
126
+ ]
111
127
  ) { _ in
112
128
  isFavorite.toggle()
113
129
  }
@@ -168,6 +184,22 @@ struct ToolkitHeaderRight: View {
168
184
  }
169
185
  }
170
186
 
187
+ // Load the current favorite state on appear so the star reflects reality; without this the button
188
+ // always renders "not favorited" until the user taps it. Mirrors the Compose LaunchedEffect.
189
+ private func loadFavoriteState() {
190
+ let context = environment.applicationContext
191
+ environment.composeApi?.request(
192
+ funcName: "isFavoriteApp",
193
+ params: ["code": context?.appCode]
194
+ ) { response in
195
+ guard let data = response.data(using: .utf8),
196
+ let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
197
+ return
198
+ }
199
+ isFavorite = (json["response"] as? Bool) ?? false
200
+ }
201
+ }
202
+
171
203
  private func getNavigationButtonConfig() -> NavigationButtonConfig {
172
204
  let totalTools = headerRight?.tools.reduce(0) { $0 + $1.items.count } ?? 0
173
205
  var icon = isFavorite ? "pin_star_checked" : "pin_star"
@@ -231,6 +263,9 @@ struct ToolkitHeaderRight: View {
231
263
  )
232
264
  .padding(.leading, Spacing.S)
233
265
  }
266
+ .onAppear {
267
+ loadFavoriteState()
268
+ }
234
269
  }
235
270
  }
236
271
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.29-debug",
3
+ "version": "0.162.30-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},