@momo-kits/native-kits 0.162.6-debug → 0.162.7-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 +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +2 -10
- 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 +3 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +2 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +5 -7
- 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/NavigationContainer.kt +10 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +3 -3
- package/gradle.properties +1 -1
- package/package.json +1 -1
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
Guidance for working in this repo. Keep it accurate — update it when structure or commands change.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`momo-native-kits` — MoMo's design-system / UI-kit as a **Kotlin Multiplatform + Compose Multiplatform** library, published for Android (AAR/Maven) and iOS (static framework + CocoaPods). It is the Compose port of the React Native `momo-kits`. Consumed by mini-apps embedded in the host MoMo app.
|
|
8
|
+
|
|
9
|
+
- Artifact: `vn.momo.kits:kits` (version in `gradle.properties`). NPM mirror: `@momo-kits/native-kits`.
|
|
10
|
+
- Targets: `androidTarget` (JVM 17, compile/min/target SDK 36/24/36), `iosArm64`, `iosSimulatorArm64` (framework `baseName = "kits"`, `isStatic = true`).
|
|
11
|
+
- Kotlin 2.3.10, Compose MP 1.10.3.
|
|
12
|
+
|
|
13
|
+
## Modules
|
|
14
|
+
|
|
15
|
+
- `:compose` — the published library. All real code lives here.
|
|
16
|
+
- `:sample:shared` + `:sample:androidApp` — demo app (`UIKitHome` lists all components). iOS demo in `sample/iosApp` (Xcode).
|
|
17
|
+
|
|
18
|
+
## Source layout (`compose/src/commonMain/kotlin/vn/momo/kits/`)
|
|
19
|
+
|
|
20
|
+
- `components/` — ~50 UI components, **one file per component** (`Button.kt`, `Input*.kt`, `PopupNotify.kt`, …).
|
|
21
|
+
- `application/` — app-level context & config: `Context.kt` (CompositionLocals, `MiniAppContext`, `DesignSystemConfig`), `Localize.kt` (i18n: `LocalizationObject`, `Localize`, default dictionary), `Screen.kt`, header pieces. Also holds the **deprecated** `ApplicationContainer`.
|
|
22
|
+
- `navigation/` — `NavigationContainer.kt` (**canonical entry point**), `Navigator.kt`, `Navigation.kt`, `StackScreen.kt`, `bottomtab/`, `component/`, `tracking/`.
|
|
23
|
+
- `const/` — design tokens: `Theme.kt`, `Colors.kt`, `Typography.kt`, `Spacing.kt`, `Radius.kt`.
|
|
24
|
+
- `layout/`, `modifier/`, `utils/`.
|
|
25
|
+
- `platform/` — `Platform.kt` `expect` declarations, actualized in `androidMain` / `iosMain` (`Platform.android.kt`, `Platform.ios.kt`).
|
|
26
|
+
|
|
27
|
+
## Build & verify
|
|
28
|
+
|
|
29
|
+
No unit-test suite is configured. Validate changes by compiling the relevant target(s); use the sample app for visual checks.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
./gradlew :compose:compileCommonMainKotlinMetadata # validate commonMain (fast, do this first)
|
|
33
|
+
./gradlew :compose:compileDebugKotlinAndroid # Android target
|
|
34
|
+
./gradlew :compose:linkDebugFrameworkIosSimulatorArm64 # iOS framework (slow)
|
|
35
|
+
./gradlew :sample:androidApp:installDebug # run demo on device/emulator
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do not publish manually unless asked: `sh publish.sh beta` / `sh publish.sh release` (Maven→GitLab + NPM).
|
|
39
|
+
|
|
40
|
+
## Architecture essentials
|
|
41
|
+
|
|
42
|
+
- **Entry point:** wrap content in `NavigationContainer(...)` from `navigation/`. It builds the `Navigator`, takes a host-supplied `Localize` (falls back to an empty one), and provides the CompositionLocals below. **Do not use** `ApplicationContainer` (`application/NavigationContainer.kt`) — deprecated and does **not** wire `LocalLocalize` / `LocalNavigator` / `LocalMaxApi`.
|
|
43
|
+
- **Configuration flows via CompositionLocals**, not params. Public ones: `AppTheme`, `AppStatusBar`, `AppNavigationBar` (`const/Theme.kt`); `ApplicationContext`, `AppConfig`, `AppLanguage`, `LocalLocalize`, `ScaleSizeMaxRate` (`application/`); `LocalNavigator`, `LocalMaxApi` (`navigation/`). Read with `X.current`.
|
|
44
|
+
- **Platform code** goes through `expect`/`actual` in `platform/` — never reference Android/iOS APIs from `commonMain` directly.
|
|
45
|
+
- **Native bridge:** `IMaxApi` (`vn.momo.maxapi`, exposed as `LocalMaxApi`) is the host-app bridge (dismiss, tracking, device info, language).
|
|
46
|
+
- Navigation uses a runtime `DynamicScreenRegistry`; overlays (modal/bottom-sheet/snackbar) go through `Navigator` + `OverplayComponentRegistry`.
|
|
47
|
+
|
|
48
|
+
## i18n / Localize (port of RN `Localize`)
|
|
49
|
+
|
|
50
|
+
- `application/Localize.kt`: everything i18n. `LocalizationObject` is a data class with required `vi` / `en` maps (`LocalizationObject(vi = mapOf(…), en = mapOf(…))`). `Localize` constructors take a `LocalizationObject` or a `(vi, en)` map pair; the constructor **merges** the kit defaults with the host data (host wins on key clash). Methods: `translate(key)` (missing/empty → returns the key), `translateData(map)` / `translateData(vi, en)`, `addTranslations` (existing keys win), `changeLanguage(lang)`. Default language `"vi"`, `"en"` only on exact match; language is snapshot state so a switch recomposes consumers.
|
|
51
|
+
- The default dictionary lives **inside `Localize`** (companion `defaultLanguage`), **generated 1:1 from `momo-kits` RN `Assets/language.json`** — do not hand-edit that block; edit the RN source and regenerate.
|
|
52
|
+
- The host creates one `Localize` and passes it in: `NavigationContainer(localize = myLocalize, …)`. There is **no** `language` param and `DesignSystemConfig` carries no translations — overrides go through the `Localize` constructor / `addTranslations`. Switch language at runtime with `myLocalize.changeLanguage("en")`.
|
|
53
|
+
- Access in a `@Composable`: `LocalLocalize.current.translate("errorCode")`. Language is host-controlled, never read from the OS locale. `AppLanguage` is still provided (derived from `Localize.currentLanguage`) for older components that read it.
|
|
54
|
+
- Some older components still do ad-hoc `AppLanguage.current` + `Map` lookups; new/changed code should use `LocalLocalize`.
|
|
55
|
+
|
|
56
|
+
## Code conventions
|
|
57
|
+
|
|
58
|
+
- **Tokens, not literals:** use `Colors`, `Typography`, `Spacing`, `Radius` objects and `AppTheme.current` for colors/styles. Per-component sizing is bundled in enums (e.g. `Button.Size(val value: ButtonSpecs)`).
|
|
59
|
+
- **Composable signatures:** required params first, slot lambdas next, `modifier: Modifier = Modifier` **last**; give optional params sensible defaults.
|
|
60
|
+
- **Stability:** annotate token/config data classes `@Stable`/`@Immutable`; memoize derived colors/styles/handlers with `remember(keys) { … }`.
|
|
61
|
+
- **Custom modifiers** are preferred: `conditional(...)`, `setAutomationId(...)`, the `clickable` variants in `modifier/`.
|
|
62
|
+
- Match the surrounding file's style when adding code.
|
|
63
|
+
|
|
64
|
+
## Writing docs in code (follow this)
|
|
65
|
+
|
|
66
|
+
Comments are **sparse and in English**. Document only what is **not obvious from the code** — non-obvious behavior, platform quirks, RN-parity semantics, memoization intent, or important gotchas worth flagging. Do **not**:
|
|
67
|
+
|
|
68
|
+
- write KDoc walls or restate what the signature/code already says;
|
|
69
|
+
- narrate obvious steps or add section-banner noise;
|
|
70
|
+
- use a language other than English in code comments.
|
|
71
|
+
|
|
72
|
+
Prefer one tight line at the surprising spot over a paragraph. Match the (low) comment density already in the codebase.
|
|
73
|
+
|
|
74
|
+
## Gotchas
|
|
75
|
+
|
|
76
|
+
- **Resource qualifier drift:** the generated Compose `Res` namespace is `vn.momo.uikits.resources`, but `utils/Resources.kt` and `platform/Platform.ios.kt` reference `vn.momo.compose.resources`. Keep bundled strings/dictionaries as plain Kotlin (the `defaultLanguage` map in `Localize.kt`), not `composeResources/values`, to avoid iOS framework resource-loading issues.
|
|
77
|
+
- Prefer `NavigationContainer` over the deprecated `ApplicationContainer`; prefer `IMaxApi`/`LocalMaxApi` over the deprecated `PlatformApi`.
|
|
78
|
+
- iOS strings/maps must survive Kotlin/Native framework packaging — keep them compiled-in, not loaded from resource bundles.
|
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -10,7 +10,7 @@ data class FeatureFlags(
|
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
@Immutable
|
|
13
|
-
data class
|
|
13
|
+
data class DesignSystemConfig(
|
|
14
14
|
val trustBanner: TrustBannerData? = null,
|
|
15
15
|
val headerBar: String? = null,
|
|
16
16
|
val headerGradient: String? = null,
|
|
@@ -90,15 +90,7 @@ data class ComponentInformation(
|
|
|
90
90
|
|
|
91
91
|
var IsShowBaseLineDebug = false
|
|
92
92
|
|
|
93
|
-
val
|
|
94
|
-
null
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
val AppConfig = staticCompositionLocalOf<KitConfig?> {
|
|
98
|
-
null
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
val AppLanguage = staticCompositionLocalOf<String?> {
|
|
93
|
+
val LocalContext = staticCompositionLocalOf<MiniAppContext?> {
|
|
102
94
|
null
|
|
103
95
|
}
|
|
104
96
|
|
|
@@ -117,7 +117,7 @@ private fun ToolkitHeaderRight(
|
|
|
117
117
|
var isFavorite by remember { mutableStateOf(false) }
|
|
118
118
|
val isLoading by remember { mutableStateOf(false) }
|
|
119
119
|
val api = PlatformApi.current as? ComposeApi
|
|
120
|
-
val context =
|
|
120
|
+
val context = LocalContext.current
|
|
121
121
|
|
|
122
122
|
fun onPressShortcut() {
|
|
123
123
|
api?.request("onToolAction", mapOf("item" to mapOf("key" to "onFavorite"))) {
|
|
@@ -262,7 +262,7 @@ fun NavigationButton(
|
|
|
262
262
|
modifier = Modifier
|
|
263
263
|
.size(28.dp)
|
|
264
264
|
.clickable(enabled = !disabled, onClick = onClick)
|
|
265
|
-
|
|
265
|
+
|
|
266
266
|
) {
|
|
267
267
|
Box(
|
|
268
268
|
modifier = Modifier
|
|
@@ -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() }
|
|
@@ -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
102
|
Box(Modifier.wrapContentSize().then(DeprecatedModifier())) {
|
|
105
103
|
content()
|
|
106
104
|
}
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
}
|
|
107
|
+
}
|
|
@@ -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,
|
|
@@ -18,8 +18,7 @@ import androidx.compose.ui.draw.clip
|
|
|
18
18
|
import androidx.compose.ui.graphics.Color
|
|
19
19
|
import androidx.compose.ui.layout.ContentScale
|
|
20
20
|
import androidx.compose.ui.unit.dp
|
|
21
|
-
import vn.momo.kits.application.
|
|
22
|
-
import vn.momo.kits.application.AppLanguage
|
|
21
|
+
import vn.momo.kits.application.LocalLocalize
|
|
23
22
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
24
23
|
import vn.momo.kits.const.Colors
|
|
25
24
|
import vn.momo.kits.const.Typography
|
|
@@ -68,9 +67,8 @@ fun TrustBanner(
|
|
|
68
67
|
onPress: ((Map<String, String>) -> Unit)? = null,
|
|
69
68
|
trackEvent: ((String, Map<String, String>) -> Unit)? = null
|
|
70
69
|
) {
|
|
71
|
-
val
|
|
72
|
-
val
|
|
73
|
-
val trustBanner = appConfig?.trustBanner ?: defaultBanner
|
|
70
|
+
val localize = LocalLocalize.current
|
|
71
|
+
val trustBanner = defaultBanner
|
|
74
72
|
val trackParams = mapOf(
|
|
75
73
|
"service_name" to serviceName,
|
|
76
74
|
"screen_name" to screenName,
|
|
@@ -124,7 +122,7 @@ fun TrustBanner(
|
|
|
124
122
|
.padding(start = 10.dp)
|
|
125
123
|
) {
|
|
126
124
|
Text(
|
|
127
|
-
text = trustBanner.content
|
|
125
|
+
text = localize.translateData(trustBanner.content),
|
|
128
126
|
modifier = Modifier.padding(bottom = 8.dp),
|
|
129
127
|
color = Color(contentColor),
|
|
130
128
|
style = Typography.descriptionDefaultRegular,
|
|
@@ -138,7 +136,7 @@ fun TrustBanner(
|
|
|
138
136
|
verticalAlignment = Alignment.CenterVertically,
|
|
139
137
|
) {
|
|
140
138
|
Text(
|
|
141
|
-
text = trustBanner.subContent
|
|
139
|
+
text = localize.translateData(trustBanner.subContent),
|
|
142
140
|
color = Color(subContentColor),
|
|
143
141
|
style = Typography.actionXsBold,
|
|
144
142
|
maxLines = 2
|
|
@@ -41,7 +41,7 @@ import vn.momo.kits.const.AppTheme
|
|
|
41
41
|
import vn.momo.kits.const.Colors
|
|
42
42
|
import vn.momo.kits.const.Radius
|
|
43
43
|
import vn.momo.kits.const.Spacing
|
|
44
|
-
import vn.momo.kits.application.
|
|
44
|
+
import vn.momo.kits.application.LocalContext
|
|
45
45
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
46
46
|
import vn.momo.kits.const.Typography
|
|
47
47
|
import vn.momo.kits.navigation.tracking.ScreenTracker
|
|
@@ -73,7 +73,7 @@ internal fun BottomSheet(
|
|
|
73
73
|
val coroutineScope = rememberCoroutineScope()
|
|
74
74
|
|
|
75
75
|
val maxApi = LocalMaxApi.current
|
|
76
|
-
val context =
|
|
76
|
+
val context = LocalContext.current
|
|
77
77
|
|
|
78
78
|
DisposableEffect(Unit) {
|
|
79
79
|
ScreenTracker.trackPopupDisplayed(
|
|
@@ -18,7 +18,7 @@ import androidx.compose.ui.draw.scale
|
|
|
18
18
|
import androidx.compose.ui.graphics.Color
|
|
19
19
|
import androidx.compose.ui.unit.dp
|
|
20
20
|
import kotlinx.coroutines.launch
|
|
21
|
-
import vn.momo.kits.application.
|
|
21
|
+
import vn.momo.kits.application.LocalContext
|
|
22
22
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
23
23
|
import vn.momo.kits.const.Colors
|
|
24
24
|
import vn.momo.kits.modifier.conditional
|
|
@@ -40,7 +40,7 @@ internal fun ModalScreen(
|
|
|
40
40
|
val coroutineScope = rememberCoroutineScope()
|
|
41
41
|
|
|
42
42
|
val maxApi = LocalMaxApi.current
|
|
43
|
-
val context =
|
|
43
|
+
val context = LocalContext.current
|
|
44
44
|
|
|
45
45
|
DisposableEffect(Unit) {
|
|
46
46
|
ScreenTracker.trackPopupDisplayed(
|
|
@@ -9,7 +9,6 @@ import androidx.navigation.compose.NavHost
|
|
|
9
9
|
import androidx.navigation.compose.composable
|
|
10
10
|
import androidx.navigation.compose.rememberNavController
|
|
11
11
|
import androidx.navigation.toRoute
|
|
12
|
-
import kotlinx.coroutines.flow.collect
|
|
13
12
|
import vn.momo.kits.application.*
|
|
14
13
|
import vn.momo.kits.const.*
|
|
15
14
|
import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
|
|
@@ -23,12 +22,11 @@ fun NavigationContainer(
|
|
|
23
22
|
initialScreen: @Composable () -> Unit,
|
|
24
23
|
options: NavigationOptions? = null,
|
|
25
24
|
initialTheme: Theme = defaultTheme,
|
|
26
|
-
|
|
27
|
-
maxApi: IMaxApi
|
|
25
|
+
miniappContext: MiniAppContext? = null,
|
|
26
|
+
maxApi: IMaxApi?,
|
|
28
27
|
setNavigator: ((Navigator) -> Unit)? = null,
|
|
29
28
|
statusBarHeight: Dp? = null,
|
|
30
|
-
|
|
31
|
-
language: String? = null
|
|
29
|
+
localize: Localize? = null,
|
|
32
30
|
){
|
|
33
31
|
val navController = rememberNavController()
|
|
34
32
|
val registry = remember { DynamicScreenRegistry() }
|
|
@@ -36,8 +34,8 @@ fun NavigationContainer(
|
|
|
36
34
|
val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
|
|
37
35
|
val navigationBarHeight = getNavigationBarHeight()
|
|
38
36
|
|
|
39
|
-
val parentContext =
|
|
40
|
-
val mergedContext = MiniAppContext.merge(parentContext,
|
|
37
|
+
val parentContext = LocalContext.current
|
|
38
|
+
val mergedContext = MiniAppContext.merge(parentContext, miniappContext)
|
|
41
39
|
|
|
42
40
|
var observerFontScaleConfig by remember { mutableStateOf(mergedContext?.fontScaleConfig) }
|
|
43
41
|
LaunchedEffect(maxApi) {
|
|
@@ -51,16 +49,8 @@ fun NavigationContainer(
|
|
|
51
49
|
|
|
52
50
|
val theme = remember { mutableStateOf(initialTheme) }
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (headerBar != null && theme.value.assets.headerBackground == null) {
|
|
57
|
-
theme.value = theme.value.copy(
|
|
58
|
-
assets = ThemeAssets(
|
|
59
|
-
headerBackground = headerBar
|
|
60
|
-
)
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
52
|
+
val fallbackLocalize = remember { Localize() }
|
|
53
|
+
val resolvedLocalize = localize ?: fallbackLocalize
|
|
64
54
|
|
|
65
55
|
val screenId = rememberSaveable { registry.nextId() }
|
|
66
56
|
registry.bind(screenId, initialScreenName, initialScreen, options)
|
|
@@ -74,11 +64,10 @@ fun NavigationContainer(
|
|
|
74
64
|
AppTheme provides theme.value,
|
|
75
65
|
AppStatusBar provides statusBarHeight,
|
|
76
66
|
AppNavigationBar provides navigationBarHeight,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
AppLanguage provides language,
|
|
67
|
+
LocalContext provides mergedContext,
|
|
68
|
+
LocalLocalize provides resolvedLocalize,
|
|
80
69
|
LocalFontScaleConfig provides (observerFontScaleConfig ?: LocalFontScaleConfig.current),
|
|
81
|
-
|
|
70
|
+
) {
|
|
82
71
|
LaunchedEffect(Unit) {
|
|
83
72
|
setNavigator?.invoke(navigator)
|
|
84
73
|
}
|
|
@@ -69,7 +69,7 @@ import vn.momo.kits.platform.supportsImePadding
|
|
|
69
69
|
import vn.momo.kits.navigation.tracking.ScreenTracker
|
|
70
70
|
import vn.momo.kits.navigation.tracking.ScreenTrackingState
|
|
71
71
|
import kotlinx.coroutines.delay
|
|
72
|
-
import vn.momo.kits.application.
|
|
72
|
+
import vn.momo.kits.application.LocalContext
|
|
73
73
|
import kotlin.time.Clock
|
|
74
74
|
import kotlin.time.Duration.Companion.milliseconds
|
|
75
75
|
import kotlin.time.ExperimentalTime
|
|
@@ -89,7 +89,7 @@ internal fun StackScreen(
|
|
|
89
89
|
) {
|
|
90
90
|
val navigator = LocalNavigator.current
|
|
91
91
|
val maxApi = LocalMaxApi.current
|
|
92
|
-
val context =
|
|
92
|
+
val context = LocalContext.current
|
|
93
93
|
val statusBar = AppStatusBar.current
|
|
94
94
|
val density = LocalDensity.current
|
|
95
95
|
val screenRegistry = LocalDynamicScreenRegistry.current
|
|
@@ -26,7 +26,7 @@ import androidx.compose.ui.Modifier
|
|
|
26
26
|
import androidx.compose.ui.draw.clip
|
|
27
27
|
import androidx.compose.ui.graphics.Color
|
|
28
28
|
import androidx.compose.ui.unit.dp
|
|
29
|
-
import vn.momo.kits.application.
|
|
29
|
+
import vn.momo.kits.application.LocalContext
|
|
30
30
|
import vn.momo.kits.application.MiniAppContext
|
|
31
31
|
import vn.momo.kits.components.BadgeDot
|
|
32
32
|
import vn.momo.kits.components.DotSize
|
|
@@ -66,7 +66,7 @@ internal fun Toolkit(
|
|
|
66
66
|
headerColor: HeaderColor
|
|
67
67
|
) {
|
|
68
68
|
val api = LocalMaxApi.current
|
|
69
|
-
val context =
|
|
69
|
+
val context = LocalContext.current
|
|
70
70
|
|
|
71
71
|
var isFavorite by remember { mutableStateOf(false) }
|
|
72
72
|
val isLoading by remember { mutableStateOf(false) }
|
|
@@ -306,4 +306,4 @@ data class Tool(
|
|
|
306
306
|
private data class NavigationButtonConfig(
|
|
307
307
|
val icon: String,
|
|
308
308
|
val onPress: () -> Unit
|
|
309
|
-
)
|
|
309
|
+
)
|
package/gradle.properties
CHANGED