@momo-kits/native-kits 0.112.1-beta.12 → 0.112.1-beta.14
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/NavigationContainer.kt +4 -2
- package/ios/Application/ApplicationEnvironment.swift +31 -14
- package/ios/Application/Components.swift +5 -4
- package/ios/Application/HeaderRight.swift +38 -40
- package/ios/Application/Screen.swift +3 -3
- package/ios/Icon/Icon.swift +3 -3
- package/package.json +1 -1
- package/ios/Application/ApplicationContext.swift +0 -13
|
@@ -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?,
|
|
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()
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
+
public protocol KitComposeApi {
|
|
4
|
+
func request(funcName: String, params: Any?) -> String
|
|
5
|
+
func request(funcName: String, params: Any?, onResponse: ((String) -> Void)?) -> String
|
|
6
|
+
func requestCallback(funcName: String, params: Any?, onResponse: ((String) -> Void)?)
|
|
7
|
+
func removeCallback(id: String)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public class MiniAppContext {
|
|
11
|
+
public var appId: String = ""
|
|
12
|
+
public var appCode: String = ""
|
|
13
|
+
public var appName: Any? = nil
|
|
14
|
+
public var appIcon: String = ""
|
|
15
|
+
public var description: Any? = nil
|
|
16
|
+
|
|
17
|
+
public init(appId: String, appCode: String, appName: Any? = nil, appIcon: String, description: Any? = nil) {
|
|
18
|
+
self.appId = appId
|
|
19
|
+
self.appCode = appCode
|
|
20
|
+
self.appName = appName
|
|
21
|
+
self.appIcon = appIcon
|
|
22
|
+
self.description = description
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
3
26
|
public class ApplicationEnvironment: ObservableObject {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// ) {
|
|
13
|
-
// self.theme = theme
|
|
14
|
-
// self.applicationContext = applicationContext
|
|
15
|
-
// self.composeAPI = composeAPI
|
|
16
|
-
// }
|
|
17
|
-
}
|
|
27
|
+
let applicationContext: MiniAppContext?
|
|
28
|
+
let composeApi: KitComposeApi
|
|
29
|
+
|
|
30
|
+
public init(applicationContext: MiniAppContext?, composeApi: KitComposeApi) {
|
|
31
|
+
self.applicationContext = applicationContext
|
|
32
|
+
self.composeApi = composeApi
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -105,7 +105,7 @@ public struct Header: View {
|
|
|
105
105
|
var headerType: HeaderType = .default
|
|
106
106
|
var titlePosition: TitlePosition
|
|
107
107
|
var title: String
|
|
108
|
-
var headerRight:
|
|
108
|
+
var headerRight: (()->any View)? = {HeaderRight()}
|
|
109
109
|
var goBack: (() -> Void)?
|
|
110
110
|
var opacity: CGFloat? = nil
|
|
111
111
|
var animatedHeader: AnimatedHeader? = nil
|
|
@@ -118,7 +118,7 @@ public struct Header: View {
|
|
|
118
118
|
headerType: HeaderType = .default,
|
|
119
119
|
titlePosition: TitlePosition,
|
|
120
120
|
title: String,
|
|
121
|
-
headerRight:
|
|
121
|
+
headerRight: (()->any View)? = {HeaderRight()},
|
|
122
122
|
goBack: (() -> Void)? = nil,
|
|
123
123
|
opacity: CGFloat? = nil,
|
|
124
124
|
animatedHeader: AnimatedHeader? = nil,
|
|
@@ -162,9 +162,10 @@ public struct Header: View {
|
|
|
162
162
|
|
|
163
163
|
Spacer()
|
|
164
164
|
|
|
165
|
-
if
|
|
166
|
-
|
|
165
|
+
if (headerRight != nil) {
|
|
166
|
+
AnyView(headerRight!())
|
|
167
167
|
}
|
|
168
|
+
|
|
168
169
|
}
|
|
169
170
|
.frame(height: 52)
|
|
170
171
|
.padding(.horizontal)
|
|
@@ -95,54 +95,52 @@ struct ToolkitHeaderRight: View {
|
|
|
95
95
|
|
|
96
96
|
// MARK: - Actions
|
|
97
97
|
private func onPressShortcut() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
environment.composeApi.request(
|
|
99
|
+
funcName: "onToolAction",
|
|
100
|
+
params: ["item": ["key": "onFavorite"]]
|
|
101
|
+
) { _ in
|
|
102
|
+
isFavorite.toggle()
|
|
103
|
+
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
private func onPressHelpCenter() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
print("Press help center")
|
|
107
|
+
let context = environment.applicationContext
|
|
108
|
+
let paramMap: [String: Any] = [
|
|
109
|
+
"appId": context?.appId,
|
|
110
|
+
"code": context?.appCode,
|
|
111
|
+
"name": context?.appName,
|
|
112
|
+
"icon": context?.appIcon,
|
|
113
|
+
"description": context?.description
|
|
114
|
+
]
|
|
115
|
+
environment.composeApi.request(
|
|
116
|
+
funcName: "showHelpCenter",
|
|
117
|
+
params: paramMap
|
|
118
|
+
) { _ in }
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
private func onPressClose() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
environment.composeApi.request(
|
|
123
|
+
funcName: "dismiss",
|
|
124
|
+
params: ""
|
|
125
|
+
) { _ in }
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
private func onPressMore() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
129
|
+
let context = environment.applicationContext
|
|
130
|
+
let params: [String: Any] = [
|
|
131
|
+
"tools": headerRight?.tools.map { $0.toMap() } ?? [],
|
|
132
|
+
"context": [
|
|
133
|
+
"appId": context?.appId,
|
|
134
|
+
"code": context?.appCode,
|
|
135
|
+
"name": context?.appName,
|
|
136
|
+
"icon": context?.appIcon,
|
|
137
|
+
"description": context?.description
|
|
138
|
+
]
|
|
139
|
+
]
|
|
140
|
+
environment.composeApi.request(
|
|
141
|
+
funcName: "showTools",
|
|
142
|
+
params: params
|
|
143
|
+
) { _ in }
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
private func getNavigationButtonConfig() -> NavigationButtonConfig {
|
|
@@ -238,4 +236,4 @@ struct NavigationButton: View {
|
|
|
238
236
|
}
|
|
239
237
|
}
|
|
240
238
|
}
|
|
241
|
-
}
|
|
239
|
+
}
|
|
@@ -20,7 +20,7 @@ public struct Screen<Content: View>: View {
|
|
|
20
20
|
var onContentLayout: ((CGRect) -> Void)?
|
|
21
21
|
var useAvoidKeyboard: Bool
|
|
22
22
|
var footer: (() -> AnyView)?
|
|
23
|
-
var headerRight: (any View)?
|
|
23
|
+
var headerRight: (()->any View)? = {HeaderRight()}
|
|
24
24
|
var animatedHeader: AnimatedHeader? = nil
|
|
25
25
|
var layoutOffset: CGFloat
|
|
26
26
|
var inputSearchProps: InputSearchProps? = nil
|
|
@@ -40,7 +40,7 @@ public struct Screen<Content: View>: View {
|
|
|
40
40
|
onContentLayout: ((CGRect) -> Void)? = nil,
|
|
41
41
|
useAvoidKeyboard: Bool = true,
|
|
42
42
|
footer: (() -> AnyView)? = nil,
|
|
43
|
-
headerRight:
|
|
43
|
+
headerRight: (()->any View)? = {HeaderRight()},
|
|
44
44
|
animatedHeader: AnimatedHeader? = nil,
|
|
45
45
|
layoutOffset: CGFloat = 56,
|
|
46
46
|
inputSearchProps: InputSearchProps? = nil,
|
|
@@ -93,7 +93,7 @@ public struct Screen<Content: View>: View {
|
|
|
93
93
|
headerType: headerType,
|
|
94
94
|
titlePosition: titlePosition,
|
|
95
95
|
title: title,
|
|
96
|
-
|
|
96
|
+
headerRight: headerRight,
|
|
97
97
|
goBack: goBack,
|
|
98
98
|
opacity: min(scrollOffset / 114, 1),
|
|
99
99
|
animatedHeader: animatedHeader,
|
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,13 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
public class ApplicationContext {
|
|
4
|
-
public static let shared = ApplicationContext()
|
|
5
|
-
|
|
6
|
-
public var appId: String = ""
|
|
7
|
-
public var appCode: String = ""
|
|
8
|
-
public var appName: Any? = nil
|
|
9
|
-
public var appIcon: String = ""
|
|
10
|
-
public var description: Any? = nil
|
|
11
|
-
|
|
12
|
-
private init() {}
|
|
13
|
-
}
|