@momo-kits/native-kits 0.162.2-sp.7-debug → 0.162.2-sp.8-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/settings.local.json +15 -1
- package/CLAUDE.md +78 -0
- package/compose/build.gradle.kts +12 -31
- package/compose/build.gradle.kts.backup +11 -30
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +4 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +1 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +6 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +6 -101
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +8 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +8 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +22 -25
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +27 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +3 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +30 -31
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +3 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +3 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +3 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +11 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +42 -65
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +69 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +84 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +13 -71
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +10 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +6 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +4 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +16 -75
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +5 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +3 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +16 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -28
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +2 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +4 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +4 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +3 -28
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +8 -47
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +4 -25
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +2 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +1 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +1 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +50 -111
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +4 -96
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +5 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +2 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +9 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +9 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +94 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +3 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +9 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +36 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +48 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +67 -61
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +6 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +13 -31
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +11 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +9 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +3 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +1 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +2 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +3 -3
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -3
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -2
- package/gradle/libs.versions.toml +2 -0
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +4 -2
- package/ios/Application/Components.swift +16 -0
- package/ios/Application/Localize.swift +277 -0
- package/ios/Application/MaxApi.swift +18 -0
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +1 -0
- package/ios/Application/Navigation/NavigationContainer.swift +27 -3
- package/ios/Application/Navigation/Navigator.swift +50 -29
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +87 -19
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +6 -0
- package/ios/Application/Navigation/Tracking/ScreenTracker.swift +117 -0
- package/ios/Application/Screen.swift +1 -1
- package/ios/Application/StackScreen.swift +49 -1
- package/ios/Badge/BadgeRibbon.swift +80 -0
- package/ios/Button/Button.swift +68 -12
- package/ios/Carousel/Carousel.swift +16 -1
- package/ios/Checkbox/Checkbox.swift +14 -20
- package/ios/Chip/Chip.swift +35 -26
- package/ios/Collapse/Collapse.swift +11 -1
- package/ios/Colors+Radius+Spacing/Colors.swift +9 -6
- package/ios/Colors+Radius+Spacing/Spacing.swift +3 -1
- package/ios/DateTimePicker/DateTimePicker.swift +4 -2
- package/ios/DateTimePicker/WheelPicker.swift +7 -3
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +14 -0
- package/ios/Extensions/Color++.swift +5 -2
- package/ios/Icon/Icon.swift +5 -1
- package/ios/IconButton/IconButton.swift +35 -7
- package/ios/Image/Image.swift +16 -3
- package/ios/Information/Information.swift +3 -1
- package/ios/Input/ErrorView.swift +3 -1
- package/ios/Input/Input.swift +31 -8
- package/ios/Input/InputPhoneNumber.swift +14 -3
- package/ios/Input/InputSearch.swift +7 -1
- package/ios/Input/InputTextArea.swift +78 -34
- package/ios/InputDropDown/InputDropDown.swift +4 -1
- package/ios/InputMoney/InputMoney.swift +16 -4
- package/ios/PARITY_AUDIT.md +641 -0
- package/ios/Popup/PopupDisplay.swift +3 -4
- package/ios/Popup/PopupNotify.swift +3 -4
- package/ios/Popup/PopupPromotion.swift +16 -8
- package/ios/ProgressInfo/ProgressInfo.swift +4 -2
- package/ios/Radio/Radio.swift +12 -13
- package/ios/Rating/Rating.swift +1 -1
- package/ios/Stepper/Stepper.swift +2 -2
- package/ios/Steps/Steps.swift +22 -6
- package/ios/SuggestAction/SuggestAction.swift +5 -3
- package/ios/Swipeable/SwipeCell.swift +5 -3
- package/ios/Switch/Switch.swift +53 -28
- package/ios/TabView/TabView.swift +18 -14
- package/ios/Template/TrustBanner/TrustBanner.swift +6 -7
- package/ios/Tooltip/Tooltip.swift +3 -0
- package/ios/Typography/FontScaleStore.swift +19 -0
- package/ios/Typography/Text.swift +3 -0
- package/ios/Typography/Typography.swift +8 -5
- package/ios/Uploader/Uploader.swift +0 -9
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/package.json +1 -1
- package/ios/Colors+Radius+Spacing/MoMoUIKitsResources.swift +0 -2
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Localize.swift
|
|
3
|
+
// MoMoUIKits
|
|
4
|
+
//
|
|
5
|
+
// SwiftUI mirror of Compose's `application/Localize.kt`, itself a port of
|
|
6
|
+
// momo-kits React Native's `Application/Localize.ts`. Holds the merged
|
|
7
|
+
// dictionary (kit defaults + host overrides) and the active language,
|
|
8
|
+
// switched at runtime via `changeLanguage`. `Localize` is an `ObservableObject`
|
|
9
|
+
// so a language switch republishes to consumers of `translate`/`translateData`,
|
|
10
|
+
// mirroring Compose's snapshot-state-backed `language`.
|
|
11
|
+
//
|
|
12
|
+
|
|
13
|
+
import Foundation
|
|
14
|
+
|
|
15
|
+
/// Translation dictionary keyed by language; both `vi` and `en` are required.
|
|
16
|
+
public struct LocalizationObject {
|
|
17
|
+
public var vi: [String: String]
|
|
18
|
+
public var en: [String: String]
|
|
19
|
+
|
|
20
|
+
public init(vi: [String: String] = [:], en: [String: String] = [:]) {
|
|
21
|
+
self.vi = vi
|
|
22
|
+
self.en = en
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public final class Localize: ObservableObject {
|
|
27
|
+
public static let VI = "vi"
|
|
28
|
+
public static let EN = "en"
|
|
29
|
+
|
|
30
|
+
private var assets: LocalizationObject
|
|
31
|
+
@Published public private(set) var currentLanguage: String = Localize.VI
|
|
32
|
+
|
|
33
|
+
public init(_ translations: LocalizationObject = LocalizationObject()) {
|
|
34
|
+
self.assets = Localize.merge(base: Localize.defaultLanguage, override: translations)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public func changeLanguage(_ language: String?) {
|
|
38
|
+
currentLanguage = (language == Localize.EN) ? Localize.EN : Localize.VI
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public func translate(_ key: String) -> String {
|
|
42
|
+
let dictionary = currentLanguage == Localize.EN ? assets.en : assets.vi
|
|
43
|
+
if let value = dictionary[key], !value.isEmpty { return value }
|
|
44
|
+
return key
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public func translateData(_ data: [String: String]) -> String {
|
|
48
|
+
if let value = data[currentLanguage] { return value }
|
|
49
|
+
let body = data.map { "\"\($0.key)\":\"\($0.value)\"" }.joined(separator: ",")
|
|
50
|
+
return "{\(body)}"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public func translateData(vi: String, en: String) -> String {
|
|
54
|
+
currentLanguage == Localize.EN ? en : vi
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/// Existing keys win (mirrors Compose: `merge(translations, assets)`).
|
|
58
|
+
public func addTranslations(_ translations: LocalizationObject) {
|
|
59
|
+
assets = Localize.merge(base: translations, override: assets)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private static func merge(base: LocalizationObject, override: LocalizationObject) -> LocalizationObject {
|
|
63
|
+
LocalizationObject(
|
|
64
|
+
vi: base.vi.merging(override.vi) { _, new in new },
|
|
65
|
+
en: base.en.merging(override.en) { _, new in new }
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private static let defaultLanguage = LocalizationObject(
|
|
70
|
+
vi: [
|
|
71
|
+
"errorCode": "Mã lỗi: ",
|
|
72
|
+
"seeMore": "Xem thêm",
|
|
73
|
+
"cancel": "Huỷ",
|
|
74
|
+
"done": "Xong",
|
|
75
|
+
"confirm": "Xác nhận",
|
|
76
|
+
"month": "tháng",
|
|
77
|
+
"day": "ngày",
|
|
78
|
+
"choose": "Chọn",
|
|
79
|
+
"sent": "Đã gửi",
|
|
80
|
+
"received": "Đã tiếp nhận",
|
|
81
|
+
"processing": "Đang xử lý",
|
|
82
|
+
"processed": "Đã xử lý",
|
|
83
|
+
"addImg": "Thêm hình",
|
|
84
|
+
"chooseBtn": "Chọn button",
|
|
85
|
+
"imgEg": "Hình ảnh tham khảo",
|
|
86
|
+
"filter": "Sắp xếp",
|
|
87
|
+
"shipping": "Đang giao hàng",
|
|
88
|
+
"men": "Nam",
|
|
89
|
+
"women": "Nữ",
|
|
90
|
+
"more": "Khác",
|
|
91
|
+
"expDate": "Ngày hết hạn",
|
|
92
|
+
"exp": "HSD",
|
|
93
|
+
"inActive": "Chưa kích hoạt",
|
|
94
|
+
"voucherRemindHour": "Hết hạn sau {hours} giờ",
|
|
95
|
+
"voucherRemindMinute": "Hết hạn sau {minutes} phút",
|
|
96
|
+
"voucherRemindSecond": "Hết hạn sau {seconds} giây",
|
|
97
|
+
"voucherRemindDay": "Hết hạn sau {days} ngày",
|
|
98
|
+
"chooseRoundtrip": "Chọn vé khứ hồi",
|
|
99
|
+
"depart": "Ngày đi",
|
|
100
|
+
"return": "Ngày về",
|
|
101
|
+
"departing": "Đi",
|
|
102
|
+
"returning": "Về",
|
|
103
|
+
"jan": "Tháng 1",
|
|
104
|
+
"feb": "Tháng 2",
|
|
105
|
+
"mar": "Tháng 3",
|
|
106
|
+
"apr": "Tháng 4",
|
|
107
|
+
"may": "Tháng 5",
|
|
108
|
+
"jun": "Tháng 6",
|
|
109
|
+
"jul": "Tháng 7",
|
|
110
|
+
"aug": "Tháng 8",
|
|
111
|
+
"sep": "Tháng 9",
|
|
112
|
+
"oct": "Tháng 10",
|
|
113
|
+
"nov": "Tháng 11",
|
|
114
|
+
"dec": "Tháng 12",
|
|
115
|
+
"mon": "T2",
|
|
116
|
+
"tue": "T3",
|
|
117
|
+
"wed": "T4",
|
|
118
|
+
"thu": "T5",
|
|
119
|
+
"fri": "T6",
|
|
120
|
+
"sat": "T7",
|
|
121
|
+
"sun": "CN",
|
|
122
|
+
"showLunar": "Hiển thị lịch âm",
|
|
123
|
+
"newYear": "Tết Dương lịch",
|
|
124
|
+
"valentine": "Ngày Lễ Tình nhân",
|
|
125
|
+
"womenDay": "Ngày Quốc tế Phụ nữ",
|
|
126
|
+
"liberationDay": "Ngày giải phóng Miền Nam thống nhất đất nước",
|
|
127
|
+
"laborDay": "Ngày Quốc tế Lao động",
|
|
128
|
+
"childrenDay": "Ngày Quốc tế Thiếu nhi",
|
|
129
|
+
"nationalDay": "Quốc khánh nước CHXHCN Việt Nam",
|
|
130
|
+
"womenDayVN": "Ngày Phụ nữ Việt Nam",
|
|
131
|
+
"teacherDay": "Ngày Nhà giáo Việt Nam",
|
|
132
|
+
"christmasEve": "Ngày Lễ Giáng Sinh",
|
|
133
|
+
"christmas": "Ngày Lễ Giáng Sinh",
|
|
134
|
+
"lunarNewYear": "Tết Nguyên Đán",
|
|
135
|
+
"hungKingDay": "Giỗ Tổ Hùng Vương",
|
|
136
|
+
"balance": "Số dư trong ví",
|
|
137
|
+
"chooseDate": "Chọn ngày tháng năm",
|
|
138
|
+
"year": "năm",
|
|
139
|
+
"hour": "giờ",
|
|
140
|
+
"minute": "phút",
|
|
141
|
+
"from": "Từ",
|
|
142
|
+
"to": "Đến",
|
|
143
|
+
"connected": "Đã kết nối",
|
|
144
|
+
"disconnected": "Mất kết nối",
|
|
145
|
+
"hide": "Ẩn",
|
|
146
|
+
"viewAllTitle": "Xem tất cả",
|
|
147
|
+
"headerTitle": "Lịch sử thanh toán",
|
|
148
|
+
"SHORTEN": "THU GỌN",
|
|
149
|
+
"viewMoreBank": "XEM THÊM (${otherItemCount} ngân hàng)",
|
|
150
|
+
"transaction_success": "Thành công",
|
|
151
|
+
"transaction_fail": "Thất bại",
|
|
152
|
+
"transaction_processing": "Đang xử lý",
|
|
153
|
+
"viewMore": "Xem thêm",
|
|
154
|
+
"shorten": "Thu gọn",
|
|
155
|
+
"Payment": "Thanh toán ${serviceName}",
|
|
156
|
+
"currencyUnit": "đ",
|
|
157
|
+
"Month": "Tháng",
|
|
158
|
+
"save": "Lưu",
|
|
159
|
+
"favoriteIn": "Thêm dịch vụ yêu thích",
|
|
160
|
+
"favoriteOut": "Xóa dịch vụ yêu thích",
|
|
161
|
+
"deviceIn": "Thêm vào thiết bị",
|
|
162
|
+
"setting": "Cài đặt",
|
|
163
|
+
"transaction": "Lịch sử giao dịch",
|
|
164
|
+
"share": "Chia sẽ dịch vụ",
|
|
165
|
+
"information": "Thông tin chung",
|
|
166
|
+
"tutorial": "Hướng dẫn sử dụng",
|
|
167
|
+
"question": "Câu hỏi thường gặp",
|
|
168
|
+
"support": "Trung tâm hỗ trợ",
|
|
169
|
+
"skip": "Bỏ qua",
|
|
170
|
+
"enterPhoneNumber": "Vui lòng nhập số điện thoại",
|
|
171
|
+
"invalidPhoneNumber": "Số điện thoại không đúng",
|
|
172
|
+
],
|
|
173
|
+
en: [
|
|
174
|
+
"seeMore": "See more",
|
|
175
|
+
"cancel": "Cancel",
|
|
176
|
+
"done": "Done",
|
|
177
|
+
"confirm": "Confirm",
|
|
178
|
+
"month": "month",
|
|
179
|
+
"day": "day",
|
|
180
|
+
"choose": "Choose",
|
|
181
|
+
"sent": "Sent",
|
|
182
|
+
"received": "Received",
|
|
183
|
+
"processing": "Processing",
|
|
184
|
+
"processed": "Done",
|
|
185
|
+
"addImg": "Add image",
|
|
186
|
+
"chooseBtn": "Choose button",
|
|
187
|
+
"imgEg": "Example images",
|
|
188
|
+
"filter": "Filter",
|
|
189
|
+
"shipping": "Shipping",
|
|
190
|
+
"men": "Men",
|
|
191
|
+
"women": "Women",
|
|
192
|
+
"more": "More",
|
|
193
|
+
"expDate": "Expiration date",
|
|
194
|
+
"exp": "EXP",
|
|
195
|
+
"inActive": "Not Activated",
|
|
196
|
+
"voucherRemindHour": "Revoke after {hours} hours",
|
|
197
|
+
"voucherRemindMinute": "Revoke after {minutes} minutes",
|
|
198
|
+
"voucherRemindSecond": "Revoke after {seconds} seconds",
|
|
199
|
+
"voucherRemindDay": "Revoke after {days} days",
|
|
200
|
+
"chooseRoundtrip": "Choose roundtrip ticket",
|
|
201
|
+
"depart": "Departing",
|
|
202
|
+
"return": "Returning",
|
|
203
|
+
"departing": "De",
|
|
204
|
+
"returning": "Re",
|
|
205
|
+
"jan": "January",
|
|
206
|
+
"feb": "February",
|
|
207
|
+
"mar": "March",
|
|
208
|
+
"apr": "April",
|
|
209
|
+
"may": "May",
|
|
210
|
+
"jun": "June",
|
|
211
|
+
"jul": "July",
|
|
212
|
+
"aug": "August",
|
|
213
|
+
"sep": "September",
|
|
214
|
+
"oct": "October",
|
|
215
|
+
"nov": "November",
|
|
216
|
+
"dec": "December",
|
|
217
|
+
"mon": "Mon",
|
|
218
|
+
"tue": "Tue",
|
|
219
|
+
"wed": "Wed",
|
|
220
|
+
"thu": "Thu",
|
|
221
|
+
"fri": "Fri",
|
|
222
|
+
"sat": "Sat",
|
|
223
|
+
"sun": "Sun",
|
|
224
|
+
"showLunar": "Show Lunar Calendar",
|
|
225
|
+
"newYear": "New Year's Day",
|
|
226
|
+
"valentine": "Valentine's Day",
|
|
227
|
+
"womenDay": "International Women's Day",
|
|
228
|
+
"liberationDay": "Liberation Day",
|
|
229
|
+
"laborDay": "Internation Labor's Day",
|
|
230
|
+
"childrenDay": "International Labor's Day",
|
|
231
|
+
"nationalDay": "National Day",
|
|
232
|
+
"womenDayVN": "Vietnamese Women's Day",
|
|
233
|
+
"teacherDay": "Teacher's Day",
|
|
234
|
+
"christmasEve": "Christmas Eve",
|
|
235
|
+
"christmas": "Christmas Day",
|
|
236
|
+
"lunarNewYear": "Lunar New Year",
|
|
237
|
+
"hungKingDay": "Hung Kings' Festival",
|
|
238
|
+
"balance": "Wallet Balance",
|
|
239
|
+
"chooseDate": "Choose date",
|
|
240
|
+
"year": "year",
|
|
241
|
+
"hour": "hour",
|
|
242
|
+
"minute": "minute",
|
|
243
|
+
"from": "From",
|
|
244
|
+
"to": "To",
|
|
245
|
+
"connected": "Connected",
|
|
246
|
+
"disconnected": "Disconnected",
|
|
247
|
+
"hide": "Hide",
|
|
248
|
+
"viewAllTitle": "View all",
|
|
249
|
+
"headerTitle": "Transaction history",
|
|
250
|
+
"SHORTEN": "SHORTEN",
|
|
251
|
+
"viewMoreBank": "VIEW MORE (${otherItemCount} banks)",
|
|
252
|
+
"transaction_success": "Success",
|
|
253
|
+
"transaction_fail": "Fail",
|
|
254
|
+
"transaction_processing": "Processing",
|
|
255
|
+
"viewMore": "View more",
|
|
256
|
+
"shorten": "Shorten",
|
|
257
|
+
"Payment": "${serviceName} payment",
|
|
258
|
+
"currencyUnit": "VND",
|
|
259
|
+
"Month": "Month",
|
|
260
|
+
"save": "Save",
|
|
261
|
+
"favoriteIn": "Add to favorite services",
|
|
262
|
+
"favoriteOut": "Remove to favorite services",
|
|
263
|
+
"deviceIn": "Add to device",
|
|
264
|
+
"setting": "Settings",
|
|
265
|
+
"transaction": "Transaction History",
|
|
266
|
+
"share": "Share",
|
|
267
|
+
"information": "Information",
|
|
268
|
+
"tutorial": "Instruction",
|
|
269
|
+
"question": "FAQ",
|
|
270
|
+
"support": "Support center",
|
|
271
|
+
"errorCode": "Error code: ",
|
|
272
|
+
"skip": "Skip",
|
|
273
|
+
"enterPhoneNumber": "Please enter your phone number",
|
|
274
|
+
"invalidPhoneNumber": "Invalid phone number",
|
|
275
|
+
]
|
|
276
|
+
)
|
|
277
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MaxApi.swift
|
|
3
|
+
// MoMoUIKits
|
|
4
|
+
//
|
|
5
|
+
// Swift mirror of the host-app bridge exposed on Kotlin as `vn.momo.maxapi.IMaxApi`
|
|
6
|
+
// (`LocalMaxApi`). `IMaxApi` itself is an external compiled dependency with no
|
|
7
|
+
// source in this repo, so this protocol intentionally exposes only the methods
|
|
8
|
+
// this kit's Kotlin source actually calls (`track`, `dismiss`, `getLanguage`) —
|
|
9
|
+
// not a full guess at IMaxApi's real surface.
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
import Foundation
|
|
13
|
+
|
|
14
|
+
public protocol MaxApi {
|
|
15
|
+
func track(eventName: String, params: [String: Any?])
|
|
16
|
+
func dismiss(completion: (() -> Void)?)
|
|
17
|
+
func getLanguage(callback: @escaping ([String: Any?]?) -> Void)
|
|
18
|
+
}
|
|
@@ -14,9 +14,11 @@ import SwiftUI
|
|
|
14
14
|
public struct NavigationContainer<Initial: View>: View {
|
|
15
15
|
@StateObject private var navigator: Navigator
|
|
16
16
|
@StateObject private var applicationEnvironment: ApplicationEnvironment
|
|
17
|
+
@StateObject private var localize: Localize
|
|
17
18
|
|
|
18
19
|
private let setNavigator: ((Navigator) -> Void)?
|
|
19
20
|
private let composeApi: KitComposeApi?
|
|
21
|
+
private let maxApi: MaxApi?
|
|
20
22
|
|
|
21
23
|
public init(
|
|
22
24
|
initialScreenName: String = "",
|
|
@@ -25,6 +27,8 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
25
27
|
applicationContext: MiniAppContext? = nil,
|
|
26
28
|
composeApi: KitComposeApi? = nil,
|
|
27
29
|
config: KitConfig? = nil,
|
|
30
|
+
maxApi: MaxApi? = nil,
|
|
31
|
+
localize: Localize? = nil,
|
|
28
32
|
setNavigator: ((Navigator) -> Void)? = nil
|
|
29
33
|
) {
|
|
30
34
|
let nav = Navigator(
|
|
@@ -38,10 +42,13 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
38
42
|
wrappedValue: ApplicationEnvironment(
|
|
39
43
|
applicationContext: applicationContext,
|
|
40
44
|
composeApi: composeApi,
|
|
41
|
-
config: config
|
|
45
|
+
config: config,
|
|
46
|
+
maxApi: maxApi
|
|
42
47
|
)
|
|
43
48
|
)
|
|
49
|
+
_localize = StateObject(wrappedValue: localize ?? Localize())
|
|
44
50
|
self.composeApi = composeApi
|
|
51
|
+
self.maxApi = maxApi
|
|
45
52
|
self.setNavigator = setNavigator
|
|
46
53
|
}
|
|
47
54
|
|
|
@@ -55,11 +62,13 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
55
62
|
.environmentObject(navigator)
|
|
56
63
|
.environmentObject(applicationEnvironment)
|
|
57
64
|
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
65
|
+
.environmentObject(localize)
|
|
58
66
|
.fullScreenCover(item: $navigator.presented) { route in
|
|
59
67
|
screenView(forDialog: route)
|
|
60
68
|
.environmentObject(navigator)
|
|
61
69
|
.environmentObject(applicationEnvironment)
|
|
62
70
|
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
71
|
+
.environmentObject(localize)
|
|
63
72
|
}
|
|
64
73
|
.overlay {
|
|
65
74
|
if let item = navigator.overplay {
|
|
@@ -67,6 +76,7 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
67
76
|
.environmentObject(navigator)
|
|
68
77
|
.environmentObject(applicationEnvironment)
|
|
69
78
|
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
79
|
+
.environmentObject(localize)
|
|
70
80
|
}
|
|
71
81
|
}
|
|
72
82
|
.onAppear {
|
|
@@ -74,12 +84,19 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
74
84
|
navigator.composeApi = composeApi
|
|
75
85
|
}
|
|
76
86
|
setNavigator?(navigator)
|
|
87
|
+
// Mirrors Compose's LaunchedEffect(maxApi, resolvedLocalize): host-reported
|
|
88
|
+
// language wins over the default "vi" only when it resolves to English.
|
|
89
|
+
maxApi?.getLanguage { data in
|
|
90
|
+
if parseLanguage(data) == Localize.EN {
|
|
91
|
+
localize.changeLanguage(Localize.EN)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
@ViewBuilder
|
|
81
98
|
private func screenView(for route: DynamicScreenRoute) -> some View {
|
|
82
|
-
if let screen =
|
|
99
|
+
if let screen = navigator.registry.getScreen(id: route.id) {
|
|
83
100
|
ScreenHost(screen: screen, navigator: navigator)
|
|
84
101
|
.navigationBarBackButtonHidden(true)
|
|
85
102
|
} else {
|
|
@@ -89,7 +106,7 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
89
106
|
|
|
90
107
|
@ViewBuilder
|
|
91
108
|
private func screenView(forDialog route: DynamicDialogRoute) -> some View {
|
|
92
|
-
if let screen =
|
|
109
|
+
if let screen = navigator.registry.getScreen(id: route.id) {
|
|
93
110
|
ScreenHost(screen: screen, navigator: navigator)
|
|
94
111
|
} else {
|
|
95
112
|
EmptyView()
|
|
@@ -128,6 +145,7 @@ private struct ScreenHost: View {
|
|
|
128
145
|
layoutOffset: options.layoutOffset,
|
|
129
146
|
inputSearchProps: options.inputSearchProps,
|
|
130
147
|
fabProps: options.fabProps,
|
|
148
|
+
screenName: screen.name,
|
|
131
149
|
content: { screen.content() }
|
|
132
150
|
)
|
|
133
151
|
}
|
|
@@ -174,3 +192,9 @@ private func safeAreaBottomInset() -> CGFloat {
|
|
|
174
192
|
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
175
193
|
.first ?? 0
|
|
176
194
|
}
|
|
195
|
+
|
|
196
|
+
private func parseLanguage(_ raw: [String: Any?]?) -> String? {
|
|
197
|
+
guard let response = (raw?["response"] as? String)?.trimmingCharacters(in: .whitespaces).lowercased(),
|
|
198
|
+
!response.isEmpty else { return nil }
|
|
199
|
+
return response.hasPrefix(Localize.EN) ? Localize.EN : Localize.VI
|
|
200
|
+
}
|
|
@@ -30,12 +30,10 @@ public struct DynamicScreen {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
public final class DynamicScreenRegistry {
|
|
33
|
-
public static let shared = DynamicScreenRegistry()
|
|
34
|
-
|
|
35
33
|
private var screens: [Int: DynamicScreen] = [:]
|
|
36
34
|
private var idCounter: Int = 1
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
public init() {}
|
|
39
37
|
|
|
40
38
|
@discardableResult
|
|
41
39
|
public func register(
|
|
@@ -95,6 +93,11 @@ public final class Navigator: ObservableObject {
|
|
|
95
93
|
@Published public var presented: DynamicDialogRoute?
|
|
96
94
|
@Published public var overplay: OverplayItem?
|
|
97
95
|
|
|
96
|
+
/// Owned per-Navigator (mirrors Compose's `remember { DynamicScreenRegistry() }` +
|
|
97
|
+
/// disposal): screens registered by this navigator are released via ARC when the
|
|
98
|
+
/// navigator itself deallocates, instead of accumulating in a process-wide singleton.
|
|
99
|
+
public let registry = DynamicScreenRegistry()
|
|
100
|
+
|
|
98
101
|
/// Animated-close handler registered by the active overplay component
|
|
99
102
|
/// (mirrors Compose's `OverplayComponentRegistry.bindClose`). When set, a
|
|
100
103
|
/// dismiss request runs the component's exit animation before the item is
|
|
@@ -111,7 +114,7 @@ public final class Navigator: ObservableObject {
|
|
|
111
114
|
composeApi: KitComposeApi? = nil
|
|
112
115
|
) {
|
|
113
116
|
self.composeApi = composeApi
|
|
114
|
-
self.rootRoute =
|
|
117
|
+
self.rootRoute = registry.register(
|
|
115
118
|
screenName: initialScreenName,
|
|
116
119
|
content: initialContent,
|
|
117
120
|
options: options
|
|
@@ -121,7 +124,7 @@ public final class Navigator: ObservableObject {
|
|
|
121
124
|
// MARK: Stack
|
|
122
125
|
|
|
123
126
|
public func push<V: View>(@ViewBuilder _ content: @escaping () -> V, options: NavigationOptions? = nil) {
|
|
124
|
-
let route =
|
|
127
|
+
let route = registry.register(
|
|
125
128
|
screenName: options?.screenName ?? "",
|
|
126
129
|
content: { AnyView(content()) },
|
|
127
130
|
options: options
|
|
@@ -134,7 +137,7 @@ public final class Navigator: ObservableObject {
|
|
|
134
137
|
@ViewBuilder _ content: @escaping () -> V,
|
|
135
138
|
options: NavigationOptions? = nil
|
|
136
139
|
) {
|
|
137
|
-
let route =
|
|
140
|
+
let route = registry.register(
|
|
138
141
|
screenName: screenName,
|
|
139
142
|
content: { AnyView(content()) },
|
|
140
143
|
options: options
|
|
@@ -145,7 +148,7 @@ public final class Navigator: ObservableObject {
|
|
|
145
148
|
public func replace<V: View>(@ViewBuilder _ content: @escaping () -> V, options: NavigationOptions? = nil) {
|
|
146
149
|
guard !path.isEmpty else { return }
|
|
147
150
|
let removed = path.removeLast()
|
|
148
|
-
|
|
151
|
+
registry.unregister(id: removed.id)
|
|
149
152
|
push(content, options: options)
|
|
150
153
|
}
|
|
151
154
|
|
|
@@ -156,15 +159,15 @@ public final class Navigator: ObservableObject {
|
|
|
156
159
|
) {
|
|
157
160
|
guard !path.isEmpty else { return }
|
|
158
161
|
let removed = path.removeLast()
|
|
159
|
-
|
|
162
|
+
registry.unregister(id: removed.id)
|
|
160
163
|
push(screenName: screenName, content, options: options)
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
public func reset<V: View>(@ViewBuilder _ content: @escaping () -> V, options: NavigationOptions? = nil) {
|
|
164
|
-
for route in path {
|
|
165
|
-
|
|
167
|
+
for route in path { registry.unregister(id: route.id) }
|
|
168
|
+
registry.unregister(id: rootRoute.id)
|
|
166
169
|
path.removeAll()
|
|
167
|
-
let route =
|
|
170
|
+
let route = registry.register(
|
|
168
171
|
screenName: options?.screenName ?? "",
|
|
169
172
|
content: { AnyView(content()) },
|
|
170
173
|
options: options
|
|
@@ -177,10 +180,10 @@ public final class Navigator: ObservableObject {
|
|
|
177
180
|
@ViewBuilder _ content: @escaping () -> V,
|
|
178
181
|
options: NavigationOptions? = nil
|
|
179
182
|
) {
|
|
180
|
-
for route in path {
|
|
181
|
-
|
|
183
|
+
for route in path { registry.unregister(id: route.id) }
|
|
184
|
+
registry.unregister(id: rootRoute.id)
|
|
182
185
|
path.removeAll()
|
|
183
|
-
let route =
|
|
186
|
+
let route = registry.register(
|
|
184
187
|
screenName: screenName,
|
|
185
188
|
content: { AnyView(content()) },
|
|
186
189
|
options: options
|
|
@@ -191,17 +194,16 @@ public final class Navigator: ObservableObject {
|
|
|
191
194
|
public func pop(_ count: Int = 1, callback: (() -> Void)? = nil) {
|
|
192
195
|
var remaining = count
|
|
193
196
|
while remaining > 0 {
|
|
194
|
-
if overplay
|
|
197
|
+
if overplay?.type == .snackBar {
|
|
198
|
+
// Mirrors Kotlin: a snackbar doesn't block back-navigation, so popping
|
|
199
|
+
// while one is showing pops the screen underneath and clears the
|
|
200
|
+
// snackbar immediately, without playing its dismiss animation.
|
|
201
|
+
overplayDismissHandler = nil
|
|
202
|
+
overplay = nil
|
|
203
|
+
if !popScreen() { break }
|
|
204
|
+
} else if overplay != nil {
|
|
195
205
|
hideOverplay()
|
|
196
|
-
} else if
|
|
197
|
-
let dismissedId = presented?.id
|
|
198
|
-
presented = nil
|
|
199
|
-
if let id = dismissedId { DynamicScreenRegistry.shared.unregister(id: id) }
|
|
200
|
-
} else if !path.isEmpty {
|
|
201
|
-
let removed = path.removeLast()
|
|
202
|
-
DynamicScreenRegistry.shared.unregister(id: removed.id)
|
|
203
|
-
} else {
|
|
204
|
-
composeApi?.requestCallback(funcName: "dismiss", params: nil, onResponse: nil)
|
|
206
|
+
} else if !popScreen() {
|
|
205
207
|
break
|
|
206
208
|
}
|
|
207
209
|
remaining -= 1
|
|
@@ -209,13 +211,32 @@ public final class Navigator: ObservableObject {
|
|
|
209
211
|
callback?()
|
|
210
212
|
}
|
|
211
213
|
|
|
214
|
+
/// Pops the topmost presented screen or stack entry. Returns `false` (and requests
|
|
215
|
+
/// a host dismiss) when there is nothing left to pop.
|
|
216
|
+
@discardableResult
|
|
217
|
+
private func popScreen() -> Bool {
|
|
218
|
+
if presented != nil {
|
|
219
|
+
let dismissedId = presented?.id
|
|
220
|
+
presented = nil
|
|
221
|
+
if let id = dismissedId { registry.unregister(id: id) }
|
|
222
|
+
return true
|
|
223
|
+
} else if !path.isEmpty {
|
|
224
|
+
let removed = path.removeLast()
|
|
225
|
+
registry.unregister(id: removed.id)
|
|
226
|
+
return true
|
|
227
|
+
} else {
|
|
228
|
+
composeApi?.requestCallback(funcName: "dismiss", params: nil, onResponse: nil)
|
|
229
|
+
return false
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
212
233
|
public func popToRoot() {
|
|
213
|
-
for route in path {
|
|
234
|
+
for route in path { registry.unregister(id: route.id) }
|
|
214
235
|
path.removeAll()
|
|
215
236
|
}
|
|
216
237
|
|
|
217
238
|
public func onBackSafe(callback: (() -> Void)? = nil) {
|
|
218
|
-
let latest =
|
|
239
|
+
let latest = registry.latest()
|
|
219
240
|
if let onBack = latest?.options?.onBackHandler {
|
|
220
241
|
onBack()
|
|
221
242
|
return
|
|
@@ -256,7 +277,7 @@ public final class Navigator: ObservableObject {
|
|
|
256
277
|
// MARK: Modal-style screen (vertical slide)
|
|
257
278
|
|
|
258
279
|
public func present<V: View>(@ViewBuilder _ content: @escaping () -> V, options: NavigationOptions? = nil) {
|
|
259
|
-
let route =
|
|
280
|
+
let route = registry.register(
|
|
260
281
|
screenName: options?.screenName ?? "",
|
|
261
282
|
content: { AnyView(content()) },
|
|
262
283
|
options: options
|
|
@@ -269,7 +290,7 @@ public final class Navigator: ObservableObject {
|
|
|
269
290
|
@ViewBuilder _ content: @escaping () -> V,
|
|
270
291
|
options: NavigationOptions? = nil
|
|
271
292
|
) {
|
|
272
|
-
let route =
|
|
293
|
+
let route = registry.register(
|
|
273
294
|
screenName: screenName,
|
|
274
295
|
content: { AnyView(content()) },
|
|
275
296
|
options: options
|
|
@@ -279,7 +300,7 @@ public final class Navigator: ObservableObject {
|
|
|
279
300
|
|
|
280
301
|
public func dismiss() {
|
|
281
302
|
if let id = presented?.id {
|
|
282
|
-
|
|
303
|
+
registry.unregister(id: id)
|
|
283
304
|
}
|
|
284
305
|
presented = nil
|
|
285
306
|
}
|