@momo-kits/native-kits 0.112.1-beta.15 → 0.112.1-beta.17
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.
|
@@ -6,14 +6,10 @@ 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
|
|
14
|
-
import kotlinx.serialization.json.Json
|
|
15
|
-
import kotlinx.serialization.json.jsonObject
|
|
16
|
-
import kotlinx.serialization.json.jsonPrimitive
|
|
12
|
+
import vn.momo.kits.components.TrustBannerData
|
|
17
13
|
import vn.momo.kits.const.AppStatusBar
|
|
18
14
|
import vn.momo.kits.const.AppTheme
|
|
19
15
|
import vn.momo.kits.const.Theme
|
|
@@ -64,39 +60,39 @@ val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
|
|
|
64
60
|
error("no context provided!")
|
|
65
61
|
}
|
|
66
62
|
|
|
63
|
+
val AppConfig = staticCompositionLocalOf<DesignSystemConfig?> {
|
|
64
|
+
error("no config provided!")
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
data class DesignSystemConfig(
|
|
68
|
+
val trustBanner: TrustBannerData? = null,
|
|
69
|
+
val headerBar: String? = null,
|
|
70
|
+
val headerGradient: String? = null
|
|
71
|
+
)
|
|
72
|
+
|
|
67
73
|
@Composable
|
|
68
74
|
fun ApplicationContainer(
|
|
69
75
|
theme: Theme = defaultTheme,
|
|
70
76
|
composeApi: ComposeApi? = null,
|
|
71
77
|
statusBarHeight: Dp? = null,
|
|
72
78
|
applicationContext: MiniAppContext? = null,
|
|
79
|
+
config: DesignSystemConfig? = null,
|
|
73
80
|
content: @Composable () -> Unit,
|
|
74
81
|
) {
|
|
75
82
|
var appTheme by remember { mutableStateOf(theme) }
|
|
76
|
-
val coroutineScope = rememberCoroutineScope()
|
|
77
83
|
|
|
78
84
|
LaunchedEffect(Unit) {
|
|
79
85
|
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
|
-
}
|
|
86
|
+
val headerBar = config?.headerBar
|
|
87
|
+
if (headerBar != null && appTheme.assets.headerBackground == null) {
|
|
88
|
+
appTheme = appTheme.copy(
|
|
89
|
+
assets = ThemeAssets(
|
|
90
|
+
headerBackground = headerBar
|
|
91
|
+
)
|
|
92
|
+
)
|
|
97
93
|
}
|
|
98
94
|
} catch (e: Exception) {
|
|
99
|
-
print("@@ == NavigationContainer
|
|
95
|
+
print("@@ == NavigationContainer get config error $e")
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
98
|
|
|
@@ -109,6 +105,7 @@ fun ApplicationContainer(
|
|
|
109
105
|
AppNavigator provides Navigator(),
|
|
110
106
|
AppStatusBar provides appStatusBarHeight,
|
|
111
107
|
ApplicationContext provides applicationContext,
|
|
108
|
+
AppConfig provides config
|
|
112
109
|
) {
|
|
113
110
|
content()
|
|
114
111
|
}
|
|
@@ -19,12 +19,13 @@ import androidx.compose.ui.graphics.Color
|
|
|
19
19
|
import androidx.compose.ui.layout.ContentScale
|
|
20
20
|
import androidx.compose.ui.unit.dp
|
|
21
21
|
import androidx.compose.ui.unit.sp
|
|
22
|
+
import vn.momo.kits.application.AppConfig
|
|
22
23
|
import vn.momo.kits.modifier.noFeedbackClickable
|
|
23
24
|
|
|
24
25
|
val defaultBanner = TrustBannerData(
|
|
25
26
|
content = mapOf(
|
|
26
|
-
"vi" to "
|
|
27
|
-
"en" to "
|
|
27
|
+
"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.",
|
|
28
|
+
"en" to "Ensuring financial security and data privacy is MoMo's highest priority."
|
|
28
29
|
),
|
|
29
30
|
subContent = mapOf(
|
|
30
31
|
"vi" to "Tìm hiểu thêm",
|
|
@@ -47,25 +48,25 @@ const val contentColor = 0xFF484848
|
|
|
47
48
|
const val subContentColor = 0xFFEB2F96
|
|
48
49
|
|
|
49
50
|
data class TrustBannerData(
|
|
50
|
-
val content: Map<String, String
|
|
51
|
-
val subContent: Map<String, String
|
|
52
|
-
val pciImage: String,
|
|
53
|
-
val momoImage: String,
|
|
54
|
-
val sslImage: String,
|
|
55
|
-
val icons: List<String
|
|
56
|
-
val urlConfig: String
|
|
51
|
+
val content: Map<String, String> = mapOf("vi" to "", "en" to ""),
|
|
52
|
+
val subContent: Map<String, String> = mapOf("vi" to "", "en" to ""),
|
|
53
|
+
val pciImage: String? = null,
|
|
54
|
+
val momoImage: String? = null,
|
|
55
|
+
val sslImage: String? = null,
|
|
56
|
+
val icons: List<String>? = null,
|
|
57
|
+
val urlConfig: String = ""
|
|
57
58
|
)
|
|
58
59
|
|
|
59
60
|
@Composable
|
|
60
61
|
fun TrustBanner(
|
|
61
|
-
trustBanner: TrustBannerData = defaultBanner,
|
|
62
62
|
serviceName: String = "",
|
|
63
63
|
screenName: String = "",
|
|
64
64
|
onPress: ((Map<String, String>) -> Unit)? = null,
|
|
65
65
|
trackEvent: ((String, Map<String, String>) -> Unit)? = null,
|
|
66
66
|
language: String = "vi"
|
|
67
|
-
|
|
68
67
|
) {
|
|
68
|
+
val appConfig = AppConfig.current
|
|
69
|
+
val trustBanner = appConfig?.trustBanner ?: defaultBanner
|
|
69
70
|
val trackParams = mapOf(
|
|
70
71
|
"service_name" to serviceName,
|
|
71
72
|
"screen_name" to screenName,
|
|
@@ -103,15 +104,17 @@ fun TrustBanner(
|
|
|
103
104
|
}
|
|
104
105
|
)
|
|
105
106
|
) {
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
if (trustBanner.momoImage != null) {
|
|
108
|
+
Image(
|
|
109
|
+
source = trustBanner.momoImage,
|
|
110
|
+
modifier = Modifier
|
|
111
|
+
.width(64.dp)
|
|
112
|
+
.height(64.dp)
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
Column(
|
|
108
116
|
modifier = Modifier
|
|
109
|
-
.
|
|
110
|
-
.height(64.dp)
|
|
111
|
-
)
|
|
112
|
-
Column (
|
|
113
|
-
modifier = Modifier
|
|
114
|
-
.padding(start = 10.dp)
|
|
117
|
+
.padding(start = 10.dp)
|
|
115
118
|
) {
|
|
116
119
|
Text(
|
|
117
120
|
text = trustBanner.content[language] ?: "",
|
|
@@ -121,10 +124,13 @@ fun TrustBanner(
|
|
|
121
124
|
color = Color(contentColor),
|
|
122
125
|
maxLines = 2
|
|
123
126
|
)
|
|
124
|
-
Row(
|
|
125
|
-
|
|
127
|
+
Row(
|
|
128
|
+
modifier = Modifier.fillMaxWidth(),
|
|
129
|
+
horizontalArrangement = Arrangement.SpaceBetween
|
|
130
|
+
) {
|
|
131
|
+
Row(
|
|
126
132
|
verticalAlignment = Alignment.CenterVertically,
|
|
127
|
-
)
|
|
133
|
+
) {
|
|
128
134
|
Text(
|
|
129
135
|
text = trustBanner.subContent[language] ?: "",
|
|
130
136
|
lineHeight = 16.sp,
|
|
@@ -138,23 +144,27 @@ fun TrustBanner(
|
|
|
138
144
|
)
|
|
139
145
|
}
|
|
140
146
|
Row {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
if (trustBanner.pciImage != null) {
|
|
148
|
+
Image(
|
|
149
|
+
source = trustBanner.pciImage, modifier = Modifier
|
|
150
|
+
.padding(end = 4.dp)
|
|
151
|
+
.width(27.dp)
|
|
152
|
+
.height(20.dp), options = Options(
|
|
153
|
+
contentScale = ContentScale.Fit,
|
|
154
|
+
)
|
|
148
155
|
)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
}
|
|
157
|
+
if (trustBanner.sslImage != null) {
|
|
158
|
+
Image(
|
|
159
|
+
source = trustBanner.sslImage, modifier = Modifier
|
|
160
|
+
.width(52.dp)
|
|
161
|
+
.height(20.dp),
|
|
162
|
+
options = Options(
|
|
163
|
+
contentScale = ContentScale.Fit,
|
|
164
|
+
)
|
|
156
165
|
)
|
|
157
|
-
|
|
166
|
+
}
|
|
167
|
+
|
|
158
168
|
}
|
|
159
169
|
}
|
|
160
170
|
}
|
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
|
+
}
|