@momo-kits/native-kits 0.169.13-beta.4-debug → 0.169.13-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 +1 -4
- package/compose/build.gradle.kts +1 -5
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +12 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +11 -3
- package/gradle/libs.versions.toml +0 -2
- package/gradle.properties +1 -1
- package/ios/Navigation/BottomTab/BottomTabBar.swift +14 -4
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +16 -3
- package/package.json +1 -1
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiActionsTest.kt +0 -647
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiExprTest.kt +0 -1411
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt +0 -130
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt +0 -524
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitNodesTest.kt +0 -559
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderPlanTest.kt +0 -741
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt +0 -221
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt +0 -270
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStylePlanTest.kt +0 -849
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt +0 -212
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt +0 -239
- package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiViewTest.kt +0 -252
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiActions.kt +0 -154
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiExpr.kt +0 -1038
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiKitNodes.kt +0 -848
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt +0 -47
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt +0 -463
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiRenderer.kt +0 -1146
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiStyle.kt +0 -667
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiTracking.kt +0 -240
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiValidate.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiView.kt +0 -200
- package/scripts/sdui-visual/README.md +0 -64
- package/scripts/sdui-visual/diff.py +0 -65
- package/scripts/sdui-visual/drive.py +0 -234
- package/scripts/sdui-visual/plan.json +0 -713
- package/scripts/sdui-visual/run.sh +0 -92
package/CLAUDE.md
CHANGED
|
@@ -22,18 +22,15 @@ Guidance for working in this repo. Keep it accurate — update it when structure
|
|
|
22
22
|
- `navigation/` — `NavigationContainer.kt` (**canonical entry point**), `Navigator.kt`, `Navigation.kt`, `StackScreen.kt`, `bottomtab/`, `component/`, `tracking/`.
|
|
23
23
|
- `const/` — design tokens: `Theme.kt`, `Colors.kt`, `Typography.kt`, `Spacing.kt`, `Radius.kt`.
|
|
24
24
|
- `layout/`, `modifier/`, `utils/`.
|
|
25
|
-
- `sdui/` — `SduiView(spec, modifier, onError, maxApi)`: embeddable server-driven-UI renderer (JSON spec -> kit components). No host seams: output goes only through the view's MaxApi (`maxApi`, else `LocalMaxApi`) - tracking events via `track` (Trackify), errors/warnings via `logFile` (spec-level identifiers only, deduped, capped). CornerStone / PlatformWidget are not supported: like any unknown type they draw nothing and report `sdui_node_error` (`unsupported_type`); any other child-node failure (`expr_failed`, `unknown_token`, `invalid_action`) is reported the same way, never capped. There is no click/action event: spec authors track clicks with their own `trackEvent` action. Actions use `maxApi` or `LocalMaxApi`; only typed actions exist (`type`: `startFeatureCode` | `trackEvent` | `setState`, required), an action without `type` (or with fields the runtime does not read, e.g. `code`) fails structure validation (SPEC_SHAPE); the runtime skip-and-warn guards are defence only. SduiView draws a section only: screen-level top-level keys (`header`, `footer`, `tabs`, `onMount`, `actions`, ...) fail validation. Device storage (`storage` get/set, MaxApi getItem/setItem) is not supported: such action fields fail structure validation. Expressions (`SduiExpr.kt`) follow JavaScript semantics for every supported construct, with one nullish value (null: `undefined`/missing names convert like JS null; a null optional argument counts as omitted); derived `spec.data` keys (`"{expr}"`) are re-evaluated on every read (memo only within one `evalExpr`), so they track state and repeat locals. Version: `SduiView.VERSION` (semver, set by hand, sent as `sduiVersion` on every tracking event) - bump PATCH for a renderer fix, MINOR for a new node / prop / action, MAJOR when a spec that used to work no longer does; `SduiView.RENDER_VERSION` is the feature level checked against `meta.minRenderVersion`. Tests: `compose/src/androidUnitTest/.../sdui/` (read the gallery/block specs from `sample/shared/.../composeResources/files/sdui/`).
|
|
26
25
|
- `platform/` — `Platform.kt` `expect` declarations, actualized in `androidMain` / `iosMain` (`Platform.android.kt`, `Platform.ios.kt`).
|
|
27
26
|
|
|
28
27
|
## Build & verify
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
No unit-test suite is configured. Validate changes by compiling the relevant target(s); use the sample app for visual checks.
|
|
31
30
|
|
|
32
31
|
```bash
|
|
33
32
|
./gradlew :compose:compileCommonMainKotlinMetadata # validate commonMain (fast, do this first)
|
|
34
33
|
./gradlew :compose:compileDebugKotlinAndroid # Android target
|
|
35
|
-
./gradlew :compose:testDebugUnitTest # SDUI unit tests (537)
|
|
36
|
-
scripts/sdui-visual/run.sh baseline|check # SDUI visual regression on the emulator (see scripts/sdui-visual/README.md)
|
|
37
34
|
./gradlew :compose:linkDebugFrameworkIosSimulatorArm64 # iOS framework (slow)
|
|
38
35
|
./gradlew :sample:androidApp:installDebug # run demo on device/emulator
|
|
39
36
|
```
|
package/compose/build.gradle.kts
CHANGED
|
@@ -40,7 +40,7 @@ kotlin {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
cocoapods {
|
|
43
|
-
version = "0.169.13-
|
|
43
|
+
version = "0.169.13-debug"
|
|
44
44
|
summary = "IOS Shared module"
|
|
45
45
|
homepage = "https://momo.vn"
|
|
46
46
|
ios.deploymentTarget = "15.0"
|
|
@@ -86,10 +86,6 @@ kotlin {
|
|
|
86
86
|
iosMain.dependencies {
|
|
87
87
|
implementation(libs.ktor.client.darwin)
|
|
88
88
|
}
|
|
89
|
-
androidUnitTest.dependencies {
|
|
90
|
-
implementation(kotlin("test"))
|
|
91
|
-
implementation(libs.junit)
|
|
92
|
-
}
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
91
|
|
package/compose/compose.podspec
CHANGED
|
@@ -246,7 +246,11 @@ internal fun ColumnScope.TabItemContent(
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
//
|
|
249
|
+
// text badges keep 5 characters, then "..." ("Khám phá" -> "Khám...")
|
|
250
|
+
private const val BADGE_MAX_CHARS = 5
|
|
251
|
+
|
|
252
|
+
// Badge value shown on a tab: null hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity),
|
|
253
|
+
// text keeps its first 5 characters.
|
|
250
254
|
internal fun tabBadgeLabel(item: BottomTabItem): String? {
|
|
251
255
|
val label = item.badgeLabel ?: return if (item.showDot) "" else null
|
|
252
256
|
if (label.isEmpty()) return ""
|
|
@@ -255,7 +259,7 @@ internal fun tabBadgeLabel(item: BottomTabItem): String? {
|
|
|
255
259
|
if (value == 0L) return if (item.showDot) "" else null
|
|
256
260
|
return if (value > 99) "99+" else label
|
|
257
261
|
}
|
|
258
|
-
return label
|
|
262
|
+
return if (label.length > BADGE_MAX_CHARS) label.take(BADGE_MAX_CHARS).trimEnd() + "..." else label
|
|
259
263
|
}
|
|
260
264
|
|
|
261
265
|
// 24 icon; badges hang off it unclipped: dot at 16/-2, label badge at 12/-7 growing right, or
|
|
@@ -287,6 +291,8 @@ internal fun TabIcon(item: BottomTabItem, tint: androidx.compose.ui.graphics.Col
|
|
|
287
291
|
}
|
|
288
292
|
}
|
|
289
293
|
|
|
294
|
+
private val BADGE_BORDER = 1.dp
|
|
295
|
+
|
|
290
296
|
// Numbers use the error color, text the warning color (Figma Badge round numeric / text); the text keeps
|
|
291
297
|
// its design size so it fits the 16 height on the Duo displays too.
|
|
292
298
|
@Composable
|
|
@@ -297,9 +303,11 @@ private fun TabBadge(label: String, modifier: Modifier) {
|
|
|
297
303
|
modifier = modifier
|
|
298
304
|
.height(16.dp)
|
|
299
305
|
.widthIn(min = 16.dp, max = TabBarMetrics.badgeMaxWidth)
|
|
306
|
+
// the 1 ring is drawn under the label: Modifier.border would paint over the text
|
|
307
|
+
.background(colors.background.surface, CircleShape)
|
|
308
|
+
.padding(BADGE_BORDER)
|
|
300
309
|
.background(if (isNumber) colors.error.primary else colors.warning.primary, CircleShape)
|
|
301
|
-
.
|
|
302
|
-
.padding(horizontal = Spacing.XS),
|
|
310
|
+
.padding(horizontal = Spacing.XS - BADGE_BORDER),
|
|
303
311
|
contentAlignment = Alignment.Center,
|
|
304
312
|
) {
|
|
305
313
|
ScaleSizeScope(1f) {
|
|
@@ -19,7 +19,9 @@ import androidx.compose.ui.unit.DpOffset
|
|
|
19
19
|
import androidx.compose.ui.unit.LayoutDirection
|
|
20
20
|
import androidx.compose.ui.unit.dp
|
|
21
21
|
import androidx.compose.foundation.background
|
|
22
|
-
import androidx.compose.
|
|
22
|
+
import androidx.compose.ui.graphics.drawOutline
|
|
23
|
+
import androidx.compose.ui.graphics.drawscope.Stroke
|
|
24
|
+
import androidx.compose.ui.draw.drawBehind
|
|
23
25
|
import androidx.compose.runtime.Composable
|
|
24
26
|
import vn.momo.kits.const.AppTheme
|
|
25
27
|
|
|
@@ -89,6 +91,7 @@ internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier {
|
|
|
89
91
|
// Floating shadow follows the shape (Figma Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16).
|
|
90
92
|
@Composable
|
|
91
93
|
internal fun Modifier.tabBarContainer(shape: Shape): Modifier {
|
|
94
|
+
val borderColor = AppTheme.current.colors.border.default
|
|
92
95
|
return dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
|
|
93
96
|
.spreadShadow(
|
|
94
97
|
shape,
|
|
@@ -98,6 +101,11 @@ internal fun Modifier.tabBarContainer(shape: Shape): Modifier {
|
|
|
98
101
|
AppTheme.current.colors.background.surface.copy(alpha = TabBarMetrics.backgroundOpacity),
|
|
99
102
|
shape,
|
|
100
103
|
)
|
|
101
|
-
// Figma .Nav/Background: 1px light-gray hairline defining the pill edge
|
|
102
|
-
.border
|
|
104
|
+
// Figma .Nav/Background: 1px light-gray hairline defining the pill edge, drawn under the items
|
|
105
|
+
// (Modifier.border paints over children, cutting a badge that reaches the rounded end)
|
|
106
|
+
.drawBehind {
|
|
107
|
+
val hairline = 1.dp.toPx()
|
|
108
|
+
val outline = InsetShape(shape, 0.5.dp).createOutline(size, layoutDirection, this)
|
|
109
|
+
drawOutline(outline, borderColor, style = Stroke(hairline))
|
|
110
|
+
}
|
|
103
111
|
}
|
|
@@ -5,7 +5,6 @@ android-targetSdk = "36"
|
|
|
5
5
|
ktor-version = "3.0.0-rc-1"
|
|
6
6
|
coroutines = "1.9.0"
|
|
7
7
|
kotlin = "2.3.10"
|
|
8
|
-
junit = "4.13.2"
|
|
9
8
|
kSerialize = "1.7.1"
|
|
10
9
|
compose = "1.10.3"
|
|
11
10
|
navigation-multiplatform = "2.9.2"
|
|
@@ -30,7 +29,6 @@ ktor-client-darwin = { group = "io.ktor", name = "ktor-client-darwin", version.r
|
|
|
30
29
|
ktor-client-okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.ref = "ktor-version" }
|
|
31
30
|
jetbrains-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" }
|
|
32
31
|
jetbrains-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
|
|
33
|
-
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
|
34
32
|
jetbrains-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
|
|
35
33
|
jetbrains-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization", version.ref = "kSerialize" }
|
|
36
34
|
jetbrains-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kSerialize" }
|
package/gradle.properties
CHANGED
|
@@ -250,7 +250,11 @@ struct TabItemContent: View {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
///
|
|
253
|
+
/// Text badges keep 5 characters, then "..." ("Khám phá" -> "Khám...").
|
|
254
|
+
private let badgeMaxChars = 5
|
|
255
|
+
|
|
256
|
+
/// Badge value shown on a tab: nil hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity),
|
|
257
|
+
/// text keeps its first 5 characters.
|
|
254
258
|
func tabBadgeLabel(_ item: BottomTabItem) -> String? {
|
|
255
259
|
guard let label = item.badgeLabel else { return item.showDot ? "" : nil }
|
|
256
260
|
if label.isEmpty { return "" }
|
|
@@ -259,7 +263,9 @@ func tabBadgeLabel(_ item: BottomTabItem) -> String? {
|
|
|
259
263
|
if value == 0 { return item.showDot ? "" : nil }
|
|
260
264
|
return value > 99 ? "99+" : label
|
|
261
265
|
}
|
|
262
|
-
return label
|
|
266
|
+
guard label.count > badgeMaxChars else { return label }
|
|
267
|
+
let head = String(label.prefix(badgeMaxChars))
|
|
268
|
+
return head.trimmingCharacters(in: .whitespaces) + "..."
|
|
263
269
|
}
|
|
264
270
|
|
|
265
271
|
/// 24 icon, active and inactive tints cross-faded; badges hang off it: dot at 16/-2, label badge at
|
|
@@ -314,8 +320,12 @@ private struct TabBadge: View {
|
|
|
314
320
|
.scaleSizeMaxRate(1)
|
|
315
321
|
.padding(.horizontal, Spacing.XS)
|
|
316
322
|
.frame(minWidth: 16, maxWidth: TabBarMetrics.badgeMaxWidth, minHeight: 16, maxHeight: 16)
|
|
317
|
-
|
|
318
|
-
.
|
|
323
|
+
// the ring sits under the label: an overlay stroke would paint over the text
|
|
324
|
+
.background(
|
|
325
|
+
Capsule()
|
|
326
|
+
.fill(isNumber ? theme.colors.error.primary : theme.colors.warning.primary)
|
|
327
|
+
.overlay(Capsule().strokeBorder(theme.colors.background.surface, lineWidth: 1))
|
|
328
|
+
)
|
|
319
329
|
}
|
|
320
330
|
}
|
|
321
331
|
|
package/ios/native-kits.podspec
CHANGED
|
@@ -89,7 +89,18 @@ private func ctaLottie(_ animation: LottieAnimation?, offset: CGFloat) -> some V
|
|
|
89
89
|
}
|
|
90
90
|
private let badges: [(String, String?)] = [
|
|
91
91
|
("Không", nil), ("Dot \"\"", ""), ("\"0\"", "0"), ("\"5\"", "5"),
|
|
92
|
-
("\"1999\"", "1999"), ("\"Mới\"", "Mới"),
|
|
92
|
+
("\"1999\"", "1999"), ("\"Mới\"", "Mới"),
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
/// "Chữ dài" picks one of these at random on every tap.
|
|
96
|
+
private let longBadges = [
|
|
97
|
+
"Khuyến mãi lớn",
|
|
98
|
+
"Khám phá ngay",
|
|
99
|
+
"Ưu đãi cực sốc",
|
|
100
|
+
"Quà tặng hấp dẫn",
|
|
101
|
+
"Hoàn tiền mỗi ngày",
|
|
102
|
+
"Siêu sale cuối tuần",
|
|
103
|
+
"Thanh toán hóa đơn",
|
|
93
104
|
]
|
|
94
105
|
|
|
95
106
|
struct BottomTabDemoContent: View {
|
|
@@ -175,10 +186,12 @@ private struct TabContent: View {
|
|
|
175
186
|
Section(title: "Tab đang mở · \(name)") {
|
|
176
187
|
IconOptions(title: "icon", icons: icons, value: tab.icon) { icon in updateTab { $0.icon = icon } }
|
|
177
188
|
Options(title: "badgeLabel",
|
|
178
|
-
hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ
|
|
189
|
+
hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ > 5 ký tự cắt thành 5 ký tự + \"...\"",
|
|
179
190
|
options: badges.map { title, value in
|
|
180
191
|
Option(title: title, selected: tab.badgeLabel == value) { updateTab { $0.badgeLabel = value } }
|
|
181
|
-
})
|
|
192
|
+
} + [Option(title: "Chữ dài", selected: longBadges.contains(tab.badgeLabel ?? "")) {
|
|
193
|
+
updateTab { $0.badgeLabel = longBadges.randomElement() }
|
|
194
|
+
}])
|
|
182
195
|
Options(title: "showDot",
|
|
183
196
|
hint: "Hiện dot khi không có badgeLabel hoặc badgeLabel là \"0\"",
|
|
184
197
|
options: yesNo(tab.showDot) { value in updateTab { $0.showDot = value } })
|