@momo-kits/native-kits 0.162.1-beta.1-debug → 0.162.1-beta.12-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.
- package/CLAUDE.md +78 -0
- package/compose/build.gradle.kts +59 -58
- package/compose/build.gradle.kts.backup +61 -60
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +13 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +5 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +21 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +69 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +2 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +6 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +5 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +21 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +66 -25
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +42 -28
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +25 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +4 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -10
- package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +46 -0
- package/gradle/libs.versions.toml +2 -0
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +1 -0
- package/ios/Application/Components.swift +1 -0
- package/ios/Application/FloatingButton.swift +1 -0
- package/ios/Application/FontScaleStore.swift +59 -0
- package/ios/Badge/Badge.swift +1 -0
- package/ios/Badge/BadgeRibbon.swift +2 -0
- package/ios/Button/Button.swift +1 -1
- package/ios/Checkbox/Checkbox.swift +1 -0
- package/ios/Information/Information.swift +151 -0
- package/ios/Input/Input.swift +1 -0
- package/ios/Input/InputPhoneNumber.swift +1 -0
- package/ios/Input/InputSearch.swift +3 -0
- package/ios/Input/InputTextArea.swift +1 -0
- package/ios/OTPKeyboard/KeyboardButton.swift +1 -1
- package/ios/Popup/PopupDisplay.swift +6 -0
- package/ios/Popup/PopupInput.swift +2 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -0
- package/ios/Typography/Text.swift +13 -7
- package/ios/Typography/Typography.swift +22 -8
- package/local.properties +2 -2
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Deprecated.kt +0 -107
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
package vn.momo.kits.application
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Immutable
|
|
4
|
+
import androidx.compose.runtime.Stable
|
|
5
|
+
import androidx.compose.runtime.getValue
|
|
6
|
+
import androidx.compose.runtime.mutableStateOf
|
|
7
|
+
import androidx.compose.runtime.setValue
|
|
8
|
+
import androidx.compose.runtime.staticCompositionLocalOf
|
|
9
|
+
|
|
10
|
+
/** Translation dictionary keyed by language; both `vi` and `en` are required. */
|
|
11
|
+
@Immutable
|
|
12
|
+
data class LocalizationObject(
|
|
13
|
+
val vi: Map<String, String> = emptyMap(),
|
|
14
|
+
val en: Map<String, String> = emptyMap(),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Translation gateway, ported from momo-kits React Native (`Application/Localize.ts`).
|
|
19
|
+
* Holds the merged dictionary (kit defaults + host overrides) and the active language,
|
|
20
|
+
* switched at runtime via [changeLanguage]. Language is snapshot-backed, so a switch
|
|
21
|
+
* recomposes consumers of [translate]/[translateData].
|
|
22
|
+
*/
|
|
23
|
+
@Stable
|
|
24
|
+
class Localize(translations: LocalizationObject = LocalizationObject()) {
|
|
25
|
+
|
|
26
|
+
private var assets by mutableStateOf(merge(defaultLanguage, translations))
|
|
27
|
+
|
|
28
|
+
private var language by mutableStateOf(VI)
|
|
29
|
+
|
|
30
|
+
val currentLanguage: String get() = language
|
|
31
|
+
|
|
32
|
+
fun changeLanguage(language: String?) {
|
|
33
|
+
this.language = if (language == EN) EN else VI
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun translate(key: String): String {
|
|
37
|
+
val dictionary = if (language == EN) assets.en else assets.vi
|
|
38
|
+
return dictionary[key]?.takeIf { it.isNotEmpty() } ?: key
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun translateData(data: Map<String, String>): String =
|
|
42
|
+
data[language] ?: data.entries.joinToString(prefix = "{", postfix = "}") {
|
|
43
|
+
"\"${it.key}\":\"${it.value}\""
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fun translateData(vi: String, en: String): String = if (language == EN) en else vi
|
|
47
|
+
|
|
48
|
+
fun addTranslations(translations: LocalizationObject) {
|
|
49
|
+
assets = merge(translations, assets)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
companion object {
|
|
53
|
+
const val VI = "vi"
|
|
54
|
+
const val EN = "en"
|
|
55
|
+
|
|
56
|
+
private fun merge(base: LocalizationObject, override: LocalizationObject) = LocalizationObject(vi = base.vi + override.vi, en = base.en + override.en)
|
|
57
|
+
|
|
58
|
+
private val defaultLanguage = LocalizationObject(
|
|
59
|
+
vi = mapOf(
|
|
60
|
+
"errorCode" to "Mã lỗi: ",
|
|
61
|
+
"seeMore" to "Xem thêm",
|
|
62
|
+
"cancel" to "Huỷ",
|
|
63
|
+
"done" to "Xong",
|
|
64
|
+
"confirm" to "Xác nhận",
|
|
65
|
+
"month" to "tháng",
|
|
66
|
+
"day" to "ngày",
|
|
67
|
+
"choose" to "Chọn",
|
|
68
|
+
"sent" to "Đã gửi",
|
|
69
|
+
"received" to "Đã tiếp nhận",
|
|
70
|
+
"processing" to "Đang xử lý",
|
|
71
|
+
"processed" to "Đã xử lý",
|
|
72
|
+
"addImg" to "Thêm hình",
|
|
73
|
+
"chooseBtn" to "Chọn button",
|
|
74
|
+
"imgEg" to "Hình ảnh tham khảo",
|
|
75
|
+
"filter" to "Sắp xếp",
|
|
76
|
+
"shipping" to "Đang giao hàng",
|
|
77
|
+
"men" to "Nam",
|
|
78
|
+
"women" to "Nữ",
|
|
79
|
+
"more" to "Khác",
|
|
80
|
+
"expDate" to "Ngày hết hạn",
|
|
81
|
+
"exp" to "HSD",
|
|
82
|
+
"inActive" to "Chưa kích hoạt",
|
|
83
|
+
"voucherRemindHour" to "Hết hạn sau {hours} giờ",
|
|
84
|
+
"voucherRemindMinute" to "Hết hạn sau {minutes} phút",
|
|
85
|
+
"voucherRemindSecond" to "Hết hạn sau {seconds} giây",
|
|
86
|
+
"voucherRemindDay" to "Hết hạn sau {days} ngày",
|
|
87
|
+
"chooseRoundtrip" to "Chọn vé khứ hồi",
|
|
88
|
+
"depart" to "Ngày đi",
|
|
89
|
+
"return" to "Ngày về",
|
|
90
|
+
"departing" to "Đi",
|
|
91
|
+
"returning" to "Về",
|
|
92
|
+
"jan" to "Tháng 1",
|
|
93
|
+
"feb" to "Tháng 2",
|
|
94
|
+
"mar" to "Tháng 3",
|
|
95
|
+
"apr" to "Tháng 4",
|
|
96
|
+
"may" to "Tháng 5",
|
|
97
|
+
"jun" to "Tháng 6",
|
|
98
|
+
"jul" to "Tháng 7",
|
|
99
|
+
"aug" to "Tháng 8",
|
|
100
|
+
"sep" to "Tháng 9",
|
|
101
|
+
"oct" to "Tháng 10",
|
|
102
|
+
"nov" to "Tháng 11",
|
|
103
|
+
"dec" to "Tháng 12",
|
|
104
|
+
"mon" to "T2",
|
|
105
|
+
"tue" to "T3",
|
|
106
|
+
"wed" to "T4",
|
|
107
|
+
"thu" to "T5",
|
|
108
|
+
"fri" to "T6",
|
|
109
|
+
"sat" to "T7",
|
|
110
|
+
"sun" to "CN",
|
|
111
|
+
"showLunar" to "Hiển thị lịch âm",
|
|
112
|
+
"newYear" to "Tết Dương lịch",
|
|
113
|
+
"valentine" to "Ngày Lễ Tình nhân",
|
|
114
|
+
"womenDay" to "Ngày Quốc tế Phụ nữ",
|
|
115
|
+
"liberationDay" to "Ngày giải phóng Miền Nam thống nhất đất nước",
|
|
116
|
+
"laborDay" to "Ngày Quốc tế Lao động",
|
|
117
|
+
"childrenDay" to "Ngày Quốc tế Thiếu nhi",
|
|
118
|
+
"nationalDay" to "Quốc khánh nước CHXHCN Việt Nam",
|
|
119
|
+
"womenDayVN" to "Ngày Phụ nữ Việt Nam",
|
|
120
|
+
"teacherDay" to "Ngày Nhà giáo Việt Nam",
|
|
121
|
+
"christmasEve" to "Ngày Lễ Giáng Sinh",
|
|
122
|
+
"christmas" to "Ngày Lễ Giáng Sinh",
|
|
123
|
+
"lunarNewYear" to "Tết Nguyên Đán",
|
|
124
|
+
"hungKingDay" to "Giỗ Tổ Hùng Vương",
|
|
125
|
+
"balance" to "Số dư trong ví",
|
|
126
|
+
"chooseDate" to "Chọn ngày tháng năm",
|
|
127
|
+
"year" to "năm",
|
|
128
|
+
"hour" to "giờ",
|
|
129
|
+
"minute" to "phút",
|
|
130
|
+
"from" to "Từ",
|
|
131
|
+
"to" to "Đến",
|
|
132
|
+
"connected" to "Đã kết nối",
|
|
133
|
+
"disconnected" to "Mất kết nối",
|
|
134
|
+
"hide" to "Ẩn",
|
|
135
|
+
"viewAllTitle" to "Xem tất cả",
|
|
136
|
+
"headerTitle" to "Lịch sử thanh toán",
|
|
137
|
+
"SHORTEN" to "THU GỌN",
|
|
138
|
+
"viewMoreBank" to "XEM THÊM (\${otherItemCount} ngân hàng)",
|
|
139
|
+
"transaction_success" to "Thành công",
|
|
140
|
+
"transaction_fail" to "Thất bại",
|
|
141
|
+
"transaction_processing" to "Đang xử lý",
|
|
142
|
+
"viewMore" to "Xem thêm",
|
|
143
|
+
"shorten" to "Thu gọn",
|
|
144
|
+
"Payment" to "Thanh toán \${serviceName}",
|
|
145
|
+
"currencyUnit" to "đ",
|
|
146
|
+
"Month" to "Tháng",
|
|
147
|
+
"save" to "Lưu",
|
|
148
|
+
"favoriteIn" to "Thêm dịch vụ yêu thích",
|
|
149
|
+
"favoriteOut" to "Xóa dịch vụ yêu thích",
|
|
150
|
+
"deviceIn" to "Thêm vào thiết bị",
|
|
151
|
+
"setting" to "Cài đặt",
|
|
152
|
+
"transaction" to "Lịch sử giao dịch",
|
|
153
|
+
"share" to "Chia sẽ dịch vụ",
|
|
154
|
+
"information" to "Thông tin chung",
|
|
155
|
+
"tutorial" to "Hướng dẫn sử dụng",
|
|
156
|
+
"question" to "Câu hỏi thường gặp",
|
|
157
|
+
"support" to "Trung tâm hỗ trợ",
|
|
158
|
+
"skip" to "Bỏ qua",
|
|
159
|
+
"enterPhoneNumber" to "Vui lòng nhập số điện thoại",
|
|
160
|
+
"invalidPhoneNumber" to "Số điện thoại không đúng",
|
|
161
|
+
),
|
|
162
|
+
en = mapOf(
|
|
163
|
+
"seeMore" to "See more",
|
|
164
|
+
"cancel" to "Cancel",
|
|
165
|
+
"done" to "Done",
|
|
166
|
+
"confirm" to "Confirm",
|
|
167
|
+
"month" to "month",
|
|
168
|
+
"day" to "day",
|
|
169
|
+
"choose" to "Choose",
|
|
170
|
+
"sent" to "Sent",
|
|
171
|
+
"received" to "Received",
|
|
172
|
+
"processing" to "Processing",
|
|
173
|
+
"processed" to "Done",
|
|
174
|
+
"addImg" to "Add image",
|
|
175
|
+
"chooseBtn" to "Choose button",
|
|
176
|
+
"imgEg" to "Example images",
|
|
177
|
+
"filter" to "Filter",
|
|
178
|
+
"shipping" to "Shipping",
|
|
179
|
+
"men" to "Men",
|
|
180
|
+
"women" to "Women",
|
|
181
|
+
"more" to "More",
|
|
182
|
+
"expDate" to "Expiration date",
|
|
183
|
+
"exp" to "EXP",
|
|
184
|
+
"inActive" to "Not Activated",
|
|
185
|
+
"voucherRemindHour" to "Revoke after {hours} hours",
|
|
186
|
+
"voucherRemindMinute" to "Revoke after {minutes} minutes",
|
|
187
|
+
"voucherRemindSecond" to "Revoke after {seconds} seconds",
|
|
188
|
+
"voucherRemindDay" to "Revoke after {days} days",
|
|
189
|
+
"chooseRoundtrip" to "Choose roundtrip ticket",
|
|
190
|
+
"depart" to "Departing",
|
|
191
|
+
"return" to "Returning",
|
|
192
|
+
"departing" to "De",
|
|
193
|
+
"returning" to "Re",
|
|
194
|
+
"jan" to "January",
|
|
195
|
+
"feb" to "February",
|
|
196
|
+
"mar" to "March",
|
|
197
|
+
"apr" to "April",
|
|
198
|
+
"may" to "May",
|
|
199
|
+
"jun" to "June",
|
|
200
|
+
"jul" to "July",
|
|
201
|
+
"aug" to "August",
|
|
202
|
+
"sep" to "September",
|
|
203
|
+
"oct" to "October",
|
|
204
|
+
"nov" to "November",
|
|
205
|
+
"dec" to "December",
|
|
206
|
+
"mon" to "Mon",
|
|
207
|
+
"tue" to "Tue",
|
|
208
|
+
"wed" to "Wed",
|
|
209
|
+
"thu" to "Thu",
|
|
210
|
+
"fri" to "Fri",
|
|
211
|
+
"sat" to "Sat",
|
|
212
|
+
"sun" to "Sun",
|
|
213
|
+
"showLunar" to "Show Lunar Calendar",
|
|
214
|
+
"newYear" to "New Year's Day",
|
|
215
|
+
"valentine" to "Valentine's Day",
|
|
216
|
+
"womenDay" to "International Women's Day",
|
|
217
|
+
"liberationDay" to "Liberation Day",
|
|
218
|
+
"laborDay" to "Internation Labor's Day",
|
|
219
|
+
"childrenDay" to "International Labor's Day",
|
|
220
|
+
"nationalDay" to "National Day",
|
|
221
|
+
"womenDayVN" to "Vietnamese Women's Day",
|
|
222
|
+
"teacherDay" to "Teacher's Day",
|
|
223
|
+
"christmasEve" to "Christmas Eve",
|
|
224
|
+
"christmas" to "Christmas Day",
|
|
225
|
+
"lunarNewYear" to "Lunar New Year",
|
|
226
|
+
"hungKingDay" to "Hung Kings' Festival",
|
|
227
|
+
"balance" to "Wallet Balance",
|
|
228
|
+
"chooseDate" to "Choose date",
|
|
229
|
+
"year" to "year",
|
|
230
|
+
"hour" to "hour",
|
|
231
|
+
"minute" to "minute",
|
|
232
|
+
"from" to "From",
|
|
233
|
+
"to" to "To",
|
|
234
|
+
"connected" to "Connected",
|
|
235
|
+
"disconnected" to "Disconnected",
|
|
236
|
+
"hide" to "Hide",
|
|
237
|
+
"viewAllTitle" to "View all",
|
|
238
|
+
"headerTitle" to "Transaction history",
|
|
239
|
+
"SHORTEN" to "SHORTEN",
|
|
240
|
+
"viewMoreBank" to "VIEW MORE (\${otherItemCount} banks)",
|
|
241
|
+
"transaction_success" to "Success",
|
|
242
|
+
"transaction_fail" to "Fail",
|
|
243
|
+
"transaction_processing" to "Processing",
|
|
244
|
+
"viewMore" to "View more",
|
|
245
|
+
"shorten" to "Shorten",
|
|
246
|
+
"Payment" to "\${serviceName} payment",
|
|
247
|
+
"currencyUnit" to "VND",
|
|
248
|
+
"Month" to "Month",
|
|
249
|
+
"save" to "Save",
|
|
250
|
+
"favoriteIn" to "Add to favorite services",
|
|
251
|
+
"favoriteOut" to "Remove to favorite services",
|
|
252
|
+
"deviceIn" to "Add to device",
|
|
253
|
+
"setting" to "Settings",
|
|
254
|
+
"transaction" to "Transaction History",
|
|
255
|
+
"share" to "Share",
|
|
256
|
+
"information" to "Information",
|
|
257
|
+
"tutorial" to "Instruction",
|
|
258
|
+
"question" to "FAQ",
|
|
259
|
+
"support" to "Support center",
|
|
260
|
+
"errorCode" to "Error code: ",
|
|
261
|
+
"skip" to "Skip",
|
|
262
|
+
"enterPhoneNumber" to "Please enter your phone number",
|
|
263
|
+
"invalidPhoneNumber" to "Invalid phone number",
|
|
264
|
+
),
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
val LocalLocalize = staticCompositionLocalOf { Localize() }
|
|
@@ -6,7 +6,7 @@ import androidx.compose.runtime.*
|
|
|
6
6
|
import androidx.compose.ui.Modifier
|
|
7
7
|
import androidx.compose.ui.unit.Dp
|
|
8
8
|
import vn.momo.kits.const.*
|
|
9
|
-
import vn.momo.kits.
|
|
9
|
+
import vn.momo.kits.modifier.DeprecatedModifier
|
|
10
10
|
import vn.momo.kits.platform.getStatusBarHeight
|
|
11
11
|
|
|
12
12
|
@Deprecated("Use IMaxApi instead", ReplaceWith("IMaxApi"))
|
|
@@ -69,7 +69,7 @@ fun ApplicationContainer(
|
|
|
69
69
|
composeApi: ComposeApi? = null,
|
|
70
70
|
statusBarHeight: Dp? = AppStatusBar.current,
|
|
71
71
|
applicationContext: MiniAppContext? = null,
|
|
72
|
-
config:
|
|
72
|
+
config: DesignSystemConfig? = null,
|
|
73
73
|
language: String? = null,
|
|
74
74
|
isWhiteList: Boolean = false,
|
|
75
75
|
content: @Composable () -> Unit,
|
|
@@ -97,13 +97,11 @@ fun ApplicationContainer(
|
|
|
97
97
|
AppTheme provides appTheme,
|
|
98
98
|
PlatformApi provides composeApi,
|
|
99
99
|
AppStatusBar provides appStatusBarHeight,
|
|
100
|
-
|
|
101
|
-
AppConfig provides config,
|
|
102
|
-
AppLanguage provides language,
|
|
100
|
+
LocalContext provides applicationContext,
|
|
103
101
|
) {
|
|
104
|
-
Box(Modifier.wrapContentSize().then(
|
|
102
|
+
Box(Modifier.wrapContentSize().then(DeprecatedModifier())) {
|
|
105
103
|
content()
|
|
106
104
|
}
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
}
|
|
107
|
+
}
|
|
@@ -29,7 +29,7 @@ import vn.momo.kits.const.AppTheme
|
|
|
29
29
|
import vn.momo.kits.const.Colors
|
|
30
30
|
import vn.momo.kits.const.Spacing
|
|
31
31
|
import vn.momo.kits.modifier.conditional
|
|
32
|
-
import vn.momo.kits.
|
|
32
|
+
import vn.momo.kits.modifier.DeprecatedModifier
|
|
33
33
|
import vn.momo.kits.modifier.shadow
|
|
34
34
|
import vn.momo.kits.navigation.component.SnackBar
|
|
35
35
|
import vn.momo.kits.platform.supportsImePadding
|
|
@@ -111,7 +111,7 @@ fun Screen(
|
|
|
111
111
|
.background(backgroundColor ?: AppTheme.current.colors.background.default)
|
|
112
112
|
.conditional(useAvoidKeyboard && supportsImePadding()) {
|
|
113
113
|
imePadding()
|
|
114
|
-
}.then(
|
|
114
|
+
}.then(DeprecatedModifier())
|
|
115
115
|
) {
|
|
116
116
|
val footerHeightPx = remember { mutableStateOf(0) }
|
|
117
117
|
|
|
@@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable
|
|
|
11
11
|
import androidx.compose.ui.Alignment
|
|
12
12
|
import androidx.compose.ui.Modifier
|
|
13
13
|
import androidx.compose.ui.graphics.Color
|
|
14
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
14
15
|
import androidx.compose.ui.unit.dp
|
|
15
16
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
16
17
|
import vn.momo.kits.const.*
|
|
@@ -18,7 +19,7 @@ import vn.momo.kits.modifier.conditional
|
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
@Composable
|
|
21
|
-
fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Modifier
|
|
22
|
+
fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Modifier = Modifier) {
|
|
22
23
|
val primaryColors = listOf(
|
|
23
24
|
Color(0xFFF0F0F0),
|
|
24
25
|
Color(0xFFEB2F96),
|
|
@@ -58,23 +59,24 @@ fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Mod
|
|
|
58
59
|
}
|
|
59
60
|
val scaleSize = scaleSize(16f)
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
Box(
|
|
63
|
+
modifier = modifier
|
|
64
|
+
.height(scaleSize.dp)
|
|
65
|
+
.widthIn(min = scaleSize.dp)
|
|
66
|
+
.background(color = badgeColor, shape = RoundedCornerShape(Radius.M))
|
|
67
|
+
.border(width = 1.dp, shape = RoundedCornerShape(Radius.M), color = Colors.black_01)
|
|
68
|
+
.conditional(IsShowBaseLineDebug) {
|
|
69
|
+
border(1.dp, Colors.blue_03)
|
|
70
|
+
}
|
|
71
|
+
.padding(horizontal = Spacing.XS),
|
|
72
|
+
contentAlignment = Alignment.Center
|
|
73
|
+
) {
|
|
74
|
+
Text(
|
|
75
|
+
text = formatTitle(label),
|
|
76
|
+
color = Colors.black_01,
|
|
77
|
+
style = Typography.actionXxsBold,
|
|
78
|
+
maxLines = 1,
|
|
79
|
+
overflow = TextOverflow.Ellipsis
|
|
80
|
+
)
|
|
79
81
|
}
|
|
80
82
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package vn.momo.kits.components
|
|
2
2
|
|
|
3
3
|
import androidx.compose.foundation.border
|
|
4
|
+
import androidx.compose.foundation.layout.Box
|
|
4
5
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
6
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
5
7
|
import androidx.compose.runtime.Composable
|
|
6
8
|
import androidx.compose.runtime.getValue
|
|
7
9
|
import androidx.compose.runtime.mutableStateOf
|
|
@@ -17,10 +19,12 @@ import androidx.compose.ui.semantics.contentDescription
|
|
|
17
19
|
import androidx.compose.ui.semantics.semantics
|
|
18
20
|
import androidx.compose.ui.platform.LocalDensity
|
|
19
21
|
import androidx.compose.ui.unit.dp
|
|
20
|
-
import coil3.compose.AsyncImage
|
|
22
|
+
import coil3.compose.AsyncImage as CoilAsyncImage
|
|
21
23
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
22
24
|
import vn.momo.kits.const.AppTheme
|
|
23
25
|
import vn.momo.kits.const.Colors
|
|
26
|
+
import vn.momo.kits.gifimage.GifImage
|
|
27
|
+
import vn.momo.kits.gifimage.GifImageState
|
|
24
28
|
import vn.momo.kits.modifier.conditional
|
|
25
29
|
|
|
26
30
|
data class Options(
|
|
@@ -73,6 +77,19 @@ private fun getHostFromUrl(url: String): String? {
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
private fun isGifUrl(url: String): Boolean {
|
|
81
|
+
val path = url.substringBefore('#').substringBefore('?')
|
|
82
|
+
return path.endsWith(".gif", ignoreCase = true)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private fun GifImageState.toImageState(): ImageState {
|
|
86
|
+
return when (this) {
|
|
87
|
+
GifImageState.Success -> ImageState.Success
|
|
88
|
+
GifImageState.Error -> ImageState.Error
|
|
89
|
+
GifImageState.Loading -> ImageState.Loading
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
76
93
|
// Optimized query parameter appending
|
|
77
94
|
private fun appendSizeQueryParam(url: String, value: String): String {
|
|
78
95
|
val fragmentIndex = url.indexOf('#')
|
|
@@ -95,12 +112,12 @@ fun Image(
|
|
|
95
112
|
modifier: Modifier = Modifier,
|
|
96
113
|
options: Options? = null,
|
|
97
114
|
loading: Boolean = true,
|
|
115
|
+
onStateChanged: (ImageState) -> Unit = {},
|
|
98
116
|
) {
|
|
99
117
|
val imageOptions = remember(options) {
|
|
100
118
|
options ?: Options()
|
|
101
119
|
}
|
|
102
120
|
|
|
103
|
-
var imageState by remember { mutableStateOf(ImageState.Loading) }
|
|
104
121
|
val density = LocalDensity.current
|
|
105
122
|
|
|
106
123
|
BoxWithConstraints(
|
|
@@ -121,34 +138,46 @@ fun Image(
|
|
|
121
138
|
processedUrl
|
|
122
139
|
}
|
|
123
140
|
}
|
|
124
|
-
else -> source
|
|
141
|
+
else -> source.toString()
|
|
125
142
|
}
|
|
126
143
|
}
|
|
127
144
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
var imageState by remember(urlToLoad) { mutableStateOf(ImageState.Loading) }
|
|
146
|
+
fun updateImageState(state: ImageState) {
|
|
147
|
+
imageState = state
|
|
148
|
+
onStateChanged(state)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (isGifUrl(urlToLoad)) {
|
|
152
|
+
GifImage(
|
|
153
|
+
modifier = Modifier.matchParentSize(),
|
|
154
|
+
url = urlToLoad,
|
|
155
|
+
contentDescription = null,
|
|
156
|
+
contentScale = imageOptions.contentScale,
|
|
157
|
+
alignment = imageOptions.alignment,
|
|
158
|
+
colorFilter = imageOptions.colorFilter,
|
|
159
|
+
alpha = imageOptions.alpha,
|
|
160
|
+
onStateChanged = { updateImageState(it.toImageState()) },
|
|
161
|
+
)
|
|
162
|
+
} else {
|
|
163
|
+
CoilAsyncImage(
|
|
164
|
+
modifier = Modifier.matchParentSize(),
|
|
165
|
+
model = urlToLoad,
|
|
166
|
+
contentDescription = null,
|
|
167
|
+
contentScale = imageOptions.contentScale,
|
|
168
|
+
alignment = imageOptions.alignment,
|
|
169
|
+
colorFilter = imageOptions.colorFilter,
|
|
170
|
+
alpha = imageOptions.alpha,
|
|
171
|
+
onLoading = { updateImageState(ImageState.Loading) },
|
|
172
|
+
onSuccess = { updateImageState(ImageState.Success) },
|
|
173
|
+
onError = { updateImageState(ImageState.Error) },
|
|
174
|
+
)
|
|
175
|
+
}
|
|
140
176
|
|
|
141
177
|
when (imageState) {
|
|
142
|
-
ImageState.Loading -> if (loading) Skeleton()
|
|
143
|
-
ImageState.Error -> {
|
|
144
|
-
val theme = AppTheme.current
|
|
145
|
-
Icon(
|
|
146
|
-
source = "media_fail",
|
|
147
|
-
color = theme.colors.text.disable,
|
|
148
|
-
modifier = Modifier.align(Alignment.Center)
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
178
|
ImageState.Success -> {}
|
|
179
|
+
ImageState.Error -> ImageError()
|
|
180
|
+
ImageState.Loading -> if (loading) Skeleton()
|
|
152
181
|
}
|
|
153
182
|
}
|
|
154
183
|
}
|
|
@@ -156,7 +185,7 @@ fun Image(
|
|
|
156
185
|
// Extracted URL processing logic for better performance
|
|
157
186
|
private fun processImageUrl(url: String, maxWidth: androidx.compose.ui.unit.Dp, density: androidx.compose.ui.unit.Density): String {
|
|
158
187
|
val host = getHostFromUrl(url)
|
|
159
|
-
return if (host != null && supportedDomains.contains(host)) {
|
|
188
|
+
return if (!isGifUrl(url) && host != null && supportedDomains.contains(host)) {
|
|
160
189
|
val widthPx = with(density) { maxWidth.roundToPx() }
|
|
161
190
|
val pixelRatio = density.density
|
|
162
191
|
val pixelFitForWidth = widthPx * pixelRatio
|
|
@@ -167,6 +196,20 @@ private fun processImageUrl(url: String, maxWidth: androidx.compose.ui.unit.Dp,
|
|
|
167
196
|
}
|
|
168
197
|
}
|
|
169
198
|
|
|
199
|
+
@Composable
|
|
200
|
+
private fun ImageError() {
|
|
201
|
+
val theme = AppTheme.current
|
|
202
|
+
Box(
|
|
203
|
+
modifier = Modifier.fillMaxSize(),
|
|
204
|
+
contentAlignment = Alignment.Center
|
|
205
|
+
) {
|
|
206
|
+
Icon(
|
|
207
|
+
source = "media_fail",
|
|
208
|
+
color = theme.colors.text.disable,
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
170
213
|
@Composable
|
|
171
214
|
fun Image(
|
|
172
215
|
source: Painter,
|
|
@@ -185,4 +228,4 @@ fun Image(
|
|
|
185
228
|
colorFilter = colorFilter,
|
|
186
229
|
alpha = alpha,
|
|
187
230
|
)
|
|
188
|
-
}
|
|
231
|
+
}
|
|
@@ -21,9 +21,11 @@ import androidx.compose.ui.unit.sp
|
|
|
21
21
|
import androidx.compose.ui.zIndex
|
|
22
22
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
23
23
|
import vn.momo.kits.const.*
|
|
24
|
+
import vn.momo.kits.modifier.InternalApi
|
|
24
25
|
import vn.momo.kits.modifier.conditional
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
@InternalApi
|
|
28
|
+
const val MAX_LENGTH = 300
|
|
27
29
|
internal val DEFAULT_HEIGHT = 104.dp
|
|
28
30
|
|
|
29
31
|
@Composable
|
|
@@ -15,8 +15,8 @@ import androidx.compose.ui.platform.LocalDensity
|
|
|
15
15
|
import androidx.compose.ui.text.TextLayoutResult
|
|
16
16
|
import androidx.compose.ui.unit.Dp
|
|
17
17
|
import androidx.compose.ui.unit.dp
|
|
18
|
-
import vn.momo.kits.application.AppLanguage
|
|
19
18
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
19
|
+
import vn.momo.kits.application.LocalLocalize
|
|
20
20
|
import vn.momo.kits.const.*
|
|
21
21
|
import vn.momo.kits.modifier.conditional
|
|
22
22
|
import vn.momo.kits.modifier.setAutomationId
|
|
@@ -83,9 +83,6 @@ fun PopupNotify(
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
val language = AppLanguage.current ?: "vi"
|
|
87
|
-
val errorCode: Map<String, String> = mapOf("vi" to "Mã lỗi: ", "en" to "Error code: ")
|
|
88
|
-
|
|
89
86
|
LaunchedEffect(layoutResult.value) {
|
|
90
87
|
layoutResult.value?.let { v ->
|
|
91
88
|
// cap visible height at ~8.5 lines
|
|
@@ -161,7 +158,7 @@ fun PopupNotify(
|
|
|
161
158
|
content(Modifier.padding(top = Spacing.S))
|
|
162
159
|
if (props.error.isNotEmpty()) {
|
|
163
160
|
Text(
|
|
164
|
-
text = errorCode
|
|
161
|
+
text = LocalLocalize.current.translate("errorCode") + props.error,
|
|
165
162
|
style = Typography.descriptionXsRegular,
|
|
166
163
|
color = AppTheme.current.colors.text.hint,
|
|
167
164
|
maxLines = 1,
|
|
@@ -36,6 +36,7 @@ fun Text(
|
|
|
36
36
|
softWrap: Boolean = true,
|
|
37
37
|
accessibilityId: String? = null,
|
|
38
38
|
inlineContent: Map<String, InlineTextContent> = mapOf(),
|
|
39
|
+
userScaleRate: Float? = null,
|
|
39
40
|
) {
|
|
40
41
|
Text(
|
|
41
42
|
text = AnnotatedString(text),
|
|
@@ -52,7 +53,8 @@ fun Text(
|
|
|
52
53
|
letterSpacing = letterSpacing,
|
|
53
54
|
softWrap = softWrap,
|
|
54
55
|
accessibilityId = accessibilityId,
|
|
55
|
-
inlineContent = inlineContent
|
|
56
|
+
inlineContent = inlineContent,
|
|
57
|
+
userScaleRate = userScaleRate
|
|
56
58
|
)
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -74,13 +76,14 @@ fun Text(
|
|
|
74
76
|
softWrap: Boolean = true,
|
|
75
77
|
accessibilityId: String? = null,
|
|
76
78
|
inlineContent: Map<String, InlineTextContent> = mapOf(),
|
|
79
|
+
userScaleRate: Float? = null,
|
|
77
80
|
) {
|
|
78
81
|
// Cache theme access to avoid repeated lookups
|
|
79
82
|
val theme = AppTheme.current
|
|
80
83
|
|
|
81
84
|
// Call @Composable functions directly in composable context
|
|
82
|
-
val scaledFontSize = scaleSize(style.fontSize)
|
|
83
|
-
val scaledLineHeight = scaleSize(style.lineHeight)
|
|
85
|
+
val scaledFontSize = scaleSize(style.fontSize, userScaleRate)
|
|
86
|
+
val scaledLineHeight = scaleSize(style.lineHeight, userScaleRate)
|
|
84
87
|
val fontFamilyResult = getFontFamily(fontFamily ?: theme.font, style.fontWeight)
|
|
85
88
|
|
|
86
89
|
// Now memoize the results
|