@momo-kits/native-kits 0.112.1-beta.14 → 0.112.1-beta.16
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 +10 -25
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +2 -2
- package/ios/Application/HeaderRight.swift +14 -4
- package/ios/Badge/BadgeDot.swift +1 -12
- package/ios/Icon/Icon.swift +1 -3
- package/ios/Image/Image.swift +17 -1
- 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
|
|
@@ -6,14 +6,9 @@ import androidx.compose.runtime.LaunchedEffect
|
|
|
6
6
|
import androidx.compose.runtime.getValue
|
|
7
7
|
import androidx.compose.runtime.mutableStateOf
|
|
8
8
|
import androidx.compose.runtime.remember
|
|
9
|
-
import androidx.compose.runtime.rememberCoroutineScope
|
|
10
9
|
import androidx.compose.runtime.setValue
|
|
11
10
|
import androidx.compose.runtime.staticCompositionLocalOf
|
|
12
11
|
import androidx.compose.ui.unit.Dp
|
|
13
|
-
import kotlinx.coroutines.launch
|
|
14
|
-
import kotlinx.serialization.json.Json
|
|
15
|
-
import kotlinx.serialization.json.jsonObject
|
|
16
|
-
import kotlinx.serialization.json.jsonPrimitive
|
|
17
12
|
import vn.momo.kits.const.AppStatusBar
|
|
18
13
|
import vn.momo.kits.const.AppTheme
|
|
19
14
|
import vn.momo.kits.const.Theme
|
|
@@ -68,35 +63,25 @@ val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
|
|
|
68
63
|
fun ApplicationContainer(
|
|
69
64
|
theme: Theme = defaultTheme,
|
|
70
65
|
composeApi: ComposeApi? = null,
|
|
71
|
-
statusBarHeight: Dp
|
|
66
|
+
statusBarHeight: Dp? = null,
|
|
72
67
|
applicationContext: MiniAppContext? = null,
|
|
68
|
+
config: Map<String, Any?>? = null,
|
|
73
69
|
content: @Composable () -> Unit,
|
|
74
70
|
) {
|
|
75
71
|
var appTheme by remember { mutableStateOf(theme) }
|
|
76
|
-
val coroutineScope = rememberCoroutineScope()
|
|
77
72
|
|
|
78
73
|
LaunchedEffect(Unit) {
|
|
79
74
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
?.content
|
|
88
|
-
if (headerBar != null && appTheme.assets.headerBackground == null) {
|
|
89
|
-
coroutineScope.launch {
|
|
90
|
-
appTheme = appTheme.copy(
|
|
91
|
-
assets = ThemeAssets(
|
|
92
|
-
headerBackground = headerBar
|
|
93
|
-
)
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
75
|
+
val headerBar = config?.get("headerBar")?.toString()
|
|
76
|
+
if (headerBar != null && appTheme.assets.headerBackground == null) {
|
|
77
|
+
appTheme = appTheme.copy(
|
|
78
|
+
assets = ThemeAssets(
|
|
79
|
+
headerBackground = headerBar
|
|
80
|
+
)
|
|
81
|
+
)
|
|
97
82
|
}
|
|
98
83
|
} catch (e: Exception) {
|
|
99
|
-
print("@@ == NavigationContainer
|
|
84
|
+
print("@@ == NavigationContainer get config error $e")
|
|
100
85
|
}
|
|
101
86
|
}
|
|
102
87
|
|
|
@@ -23,8 +23,8 @@ import vn.momo.kits.modifier.noFeedbackClickable
|
|
|
23
23
|
|
|
24
24
|
val defaultBanner = TrustBannerData(
|
|
25
25
|
content = mapOf(
|
|
26
|
-
"vi" to "
|
|
27
|
-
"en" to "
|
|
26
|
+
"vi" to "An toàn tài sản & Bảo mật thông tin của bạn là ưu tiên hàng đầu của MoMo.",
|
|
27
|
+
"en" to "Ensuring financial security and data privacy is MoMo's highest priority."
|
|
28
28
|
),
|
|
29
29
|
subContent = mapOf(
|
|
30
30
|
"vi" to "Tìm hiểu thêm",
|
|
@@ -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
|
|
@@ -140,7 +140,17 @@ struct ToolkitHeaderRight: View {
|
|
|
140
140
|
environment.composeApi.request(
|
|
141
141
|
funcName: "showTools",
|
|
142
142
|
params: params
|
|
143
|
-
) {
|
|
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
|
+
}
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
private func getNavigationButtonConfig() -> NavigationButtonConfig {
|
|
@@ -188,7 +198,7 @@ struct ToolkitHeaderRight: View {
|
|
|
188
198
|
.fill(Colors.black20)
|
|
189
199
|
.frame(width: 0.5, height: 12)
|
|
190
200
|
|
|
191
|
-
Icon(source: "16_navigation_close_circle", size: 20)
|
|
201
|
+
Icon(source: "16_navigation_close_circle", size: 20, color: Colors.black17)
|
|
192
202
|
.padding(4)
|
|
193
203
|
.onTapGesture {
|
|
194
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
|
@@ -44,9 +44,7 @@ public struct Icon: View {
|
|
|
44
44
|
|
|
45
45
|
public var body: some View {
|
|
46
46
|
if let uri = iconSources[source]?.uri {
|
|
47
|
-
ImageView(uri)
|
|
48
|
-
.frame(width: size, height: size)
|
|
49
|
-
.foregroundColor(color)
|
|
47
|
+
ImageView(uri, color: color).frame(width: size, height: size)
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
}
|
package/ios/Image/Image.swift
CHANGED
|
@@ -8,11 +8,12 @@ import SwiftUI
|
|
|
8
8
|
public struct ImageView: View {
|
|
9
9
|
// MARK: Lifecycle
|
|
10
10
|
|
|
11
|
-
public init(_ url: String, aspectRatio: CGFloat? = nil, contentMode: ContentMode = ContentMode.fit, placeholder: AnyView? = nil) {
|
|
11
|
+
public init(_ url: String, aspectRatio: CGFloat? = nil, contentMode: ContentMode = ContentMode.fit, placeholder: AnyView? = nil, color: Color? = nil) {
|
|
12
12
|
self.url = url
|
|
13
13
|
self.aspectRatio = aspectRatio
|
|
14
14
|
self.contentMode = contentMode
|
|
15
15
|
self.placeholder = placeholder
|
|
16
|
+
self.color = color
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
// MARK: Public
|
|
@@ -26,6 +27,7 @@ public struct ImageView: View {
|
|
|
26
27
|
error = false
|
|
27
28
|
}
|
|
28
29
|
.resizable()
|
|
30
|
+
.renderingMode(.template)
|
|
29
31
|
.placeholder {
|
|
30
32
|
Rectangle().foregroundColor(.gray)
|
|
31
33
|
VStack(alignment: .center, content: {
|
|
@@ -47,6 +49,7 @@ public struct ImageView: View {
|
|
|
47
49
|
.scaledToFit()
|
|
48
50
|
.transition(.fade)
|
|
49
51
|
.aspectRatio(aspectRatio, contentMode: contentMode)
|
|
52
|
+
.modifier(ColorMultiplyModifier(color: color))
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
// MARK: Internal
|
|
@@ -54,7 +57,20 @@ public struct ImageView: View {
|
|
|
54
57
|
var aspectRatio: CGFloat?
|
|
55
58
|
var contentMode: ContentMode
|
|
56
59
|
var placeholder: AnyView?
|
|
60
|
+
var color: Color?
|
|
57
61
|
|
|
58
62
|
@State var error: Bool = false
|
|
59
63
|
var url: String
|
|
60
64
|
}
|
|
65
|
+
|
|
66
|
+
private struct ColorMultiplyModifier: ViewModifier {
|
|
67
|
+
let color: Color?
|
|
68
|
+
|
|
69
|
+
func body(content: Content) -> some View {
|
|
70
|
+
if let color {
|
|
71
|
+
content.colorMultiply(color)
|
|
72
|
+
} else {
|
|
73
|
+
content
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|