@momo-kits/native-kits 0.169.13-beta.2 → 0.169.13-beta.3-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.
Files changed (173) hide show
  1. package/CLAUDE.md +4 -1
  2. package/build.gradle.kts +11 -0
  3. package/compose/build.gradle.kts +202 -0
  4. package/compose/compose.podspec +47 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  12. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiActionsTest.kt +647 -0
  13. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiExprTest.kt +1411 -0
  14. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt +130 -0
  15. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt +524 -0
  16. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitNodesTest.kt +559 -0
  17. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderPlanTest.kt +741 -0
  18. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt +221 -0
  19. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt +270 -0
  20. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStylePlanTest.kt +849 -0
  21. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt +212 -0
  22. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt +239 -0
  23. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiViewTest.kt +252 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +315 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +206 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +421 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +750 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +242 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +400 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiActions.kt +154 -0
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiExpr.kt +1038 -0
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiKitNodes.kt +848 -0
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt +47 -0
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt +39 -0
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt +463 -0
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiRenderer.kt +1146 -0
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiStyle.kt +667 -0
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiTracking.kt +240 -0
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiValidate.kt +185 -0
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiView.kt +200 -0
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
  148. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  149. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  150. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  151. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  152. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
  153. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  154. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  155. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +143 -0
  156. package/gradle/libs.versions.toml +69 -0
  157. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  158. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  159. package/gradle.properties +24 -0
  160. package/gradlew +252 -0
  161. package/gradlew.bat +94 -0
  162. package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -14
  163. package/ios/native-kits.podspec +1 -1
  164. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  165. package/ios-demo/README.md +120 -0
  166. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +3 -16
  167. package/package.json +1 -1
  168. package/scripts/sdui-visual/README.md +64 -0
  169. package/scripts/sdui-visual/diff.py +65 -0
  170. package/scripts/sdui-visual/drive.py +234 -0
  171. package/scripts/sdui-visual/plan.json +713 -0
  172. package/scripts/sdui-visual/run.sh +92 -0
  173. package/settings.gradle.kts +64 -0
@@ -0,0 +1,120 @@
1
+ # MoMoUIKitsDemo
2
+
3
+ SwiftUI demo browser for `MoMoUIKits`.
4
+
5
+ The package can optionally host a Compose UIKits screen by receiving a
6
+ `UIViewController` factory from the host app. It does not import the KMP
7
+ `shared` module directly.
8
+
9
+ SwiftUI mode reuses the full demo screen set from
10
+ `sample/iosApp/iosApp/Demo`, including the sample `HomeView` registry and demo
11
+ screens for all currently available components.
12
+
13
+ ## CocoaPods
14
+
15
+ In the host app `Podfile`, include both local pods:
16
+
17
+ ```ruby
18
+ pod 'MoMoUIKits', :path => '../momo-native-kits/ios/native-kits.podspec'
19
+ pod 'MoMoUIKitsDemo', :path => '../momo-native-kits/ios-demo'
20
+ ```
21
+
22
+ Adjust the relative paths to match the host app checkout.
23
+
24
+ ## Host App Usage
25
+
26
+ ```swift
27
+ import MoMoUIKitsDemo
28
+ import shared
29
+
30
+ class UIKitsViewController: BaseComposeAppViewController {
31
+ override func getViewController() -> UIViewController? {
32
+ let params = self.application.data as? [String: Any]
33
+
34
+ return MoMoUIKitsDemoViewControllerFactory.make(
35
+ context: MoMoUIKitsDemoContext(
36
+ appId: params?["appId"] as? String ?? "",
37
+ appCode: params?["code"] as? String ?? "",
38
+ appName: params?["name"] as? String,
39
+ appIcon: params?["icon"] as? String ?? ""
40
+ ),
41
+ composeViewController: {
42
+ UIKitsScreenComposeViewControllerKt.UIKitsScreenComposeViewController(
43
+ params: params
44
+ )
45
+ }
46
+ )
47
+ }
48
+
49
+ override func viewDidDisappear(_ animated: Bool) {
50
+ super.viewDidDisappear(animated)
51
+ composeViewController = nil
52
+ }
53
+ }
54
+ ```
55
+
56
+ If the host does not pass `composeViewController`, the demo opens directly in
57
+ SwiftUI mode.
58
+
59
+ ## Included SwiftUI Demos
60
+
61
+ The pod includes the sample demo screens for:
62
+
63
+ - Animated Header
64
+ - Avatar
65
+ - Badge
66
+ - Baseline View
67
+ - Bottom Tab
68
+ - Button
69
+ - Carousel
70
+ - Checkbox
71
+ - Chip
72
+ - Collapse
73
+ - DateTimePicker
74
+ - Divider
75
+ - Header User
76
+ - Icon Button
77
+ - Image
78
+ - Information
79
+ - Input
80
+ - Input DropDown
81
+ - Input Money
82
+ - Input OTP
83
+ - Input Phone Number
84
+ - Input Search
85
+ - Input TextArea
86
+ - Loader
87
+ - Navigation
88
+ - Pagination
89
+ - Popup Display
90
+ - Popup Notify
91
+ - Popup Promotion
92
+ - Progress Info
93
+ - Radio
94
+ - Rating
95
+ - Skeleton
96
+ - Slider
97
+ - SnackBar
98
+ - Stepper
99
+ - Steps
100
+ - Suggest Action
101
+ - Swipe
102
+ - Switch
103
+ - TabView
104
+ - Tag
105
+ - Theme
106
+ - Title
107
+ - Tooltip
108
+ - Typography
109
+ - Uploader
110
+
111
+ ## Validation Notes
112
+
113
+ Validated locally with:
114
+
115
+ ```sh
116
+ pod ipc spec ios/MoMoUIKits.podspec
117
+ pod ipc spec ios-demo/MoMoUIKitsDemo.podspec
118
+ pod lib lint ios/MoMoUIKits.podspec --allow-warnings --skip-import-validation
119
+ pod lib lint ios-demo/MoMoUIKitsDemo.podspec --allow-warnings --skip-import-validation --include-podspecs=ios/MoMoUIKits.podspec
120
+ ```
@@ -89,18 +89,7 @@ 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"),
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",
92
+ ("\"1999\"", "1999"), ("\"Mới\"", "Mới"), ("Chữ dài", "Khuyến mãi lớn"),
104
93
  ]
105
94
 
106
95
  struct BottomTabDemoContent: View {
@@ -186,12 +175,10 @@ private struct TabContent: View {
186
175
  Section(title: "Tab đang mở · \(name)") {
187
176
  IconOptions(title: "icon", icons: icons, value: tab.icon) { icon in updateTab { $0.icon = icon } }
188
177
  Options(title: "badgeLabel",
189
- hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ > 5 ký tự cắt thành 5 ký tự + \"...\"",
178
+ hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ dài bị cắt ở 58",
190
179
  options: badges.map { title, value in
191
180
  Option(title: title, selected: tab.badgeLabel == value) { updateTab { $0.badgeLabel = value } }
192
- } + [Option(title: "Chữ dài", selected: longBadges.contains(tab.badgeLabel ?? "")) {
193
- updateTab { $0.badgeLabel = longBadges.randomElement() }
194
- }])
181
+ })
195
182
  Options(title: "showDot",
196
183
  hint: "Hiện dot khi không có badgeLabel hoặc badgeLabel là \"0\"",
197
184
  options: yesNo(tab.showDot) { value in updateTab { $0.showDot = value } })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.169.13-beta.2",
3
+ "version": "0.169.13-beta.3-debug",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "publish:local": "bash publish.sh local"
@@ -0,0 +1,64 @@
1
+ # SDUI visual regression
2
+
3
+ Checks that a change to the SDUI renderer (`compose/src/commonMain/kotlin/vn/momo/kits/sdui/`) does not change how anything looks.
4
+
5
+ The script opens every SDUI spec of the sample app on an Android emulator. It screenshots every page and the state after each recorded tap or swipe, then compares each image pixel by pixel with a baseline taken before the change.
6
+
7
+ Unit tests (`./gradlew :compose:testDebugUnitTest`) check the renderer's decisions. This script checks what actually ends up on screen.
8
+
9
+ ## Usage
10
+
11
+ ```bash
12
+ # 1. BEFORE changing code: capture the baseline
13
+ # (--twice captures it twice to learn noise such as the keyboard suggestion strip; about 2x longer)
14
+ scripts/sdui-visual/run.sh baseline --twice
15
+
16
+ # 2. change the code
17
+
18
+ # 3. capture again and compare
19
+ scripts/sdui-visual/run.sh check
20
+ ```
21
+
22
+ `check` exits with:
23
+ - **0** when every image matches the baseline;
24
+ - **1** otherwise, with the differing pixels marked red under `build/sdui-visual/diff/`.
25
+
26
+ All output goes to `build/sdui-visual/`, which git ignores. Screenshots are never committed.
27
+
28
+ ## Requirements
29
+
30
+ - `adb`, the Android emulator, and [uv](https://docs.astral.sh/uv/). Pillow is pulled in by `uv run`.
31
+ - AVD `momo_api36`, or another one set with `SDUI_AVD=<name>`.
32
+ - If a device is already attached, the script uses it. Otherwise it boots the AVD headless and shuts it down at the end.
33
+
34
+ The script prepares the device so that only app changes show up in the images:
35
+ - it turns animations off;
36
+ - it freezes the status bar (clock, battery, network) with demo mode;
37
+ - the diff also ignores the top 110 px.
38
+
39
+ A run covers about 55 specs and 151 images and takes 30–40 minutes. Run it before committing a renderer change or before a release, not on every edit.
40
+
41
+ ## Files
42
+
43
+ | File | What it does |
44
+ |---|---|
45
+ | `run.sh` | the whole flow: boot, prepare, install the sample, capture, diff, shut down |
46
+ | `drive.py` | drives the app with adb and `uiautomator dump`. The spec list is read from `sample/shared/src/commonMain/kotlin/screens/SduiUsage.kt`, so new specs are picked up automatically |
47
+ | `plan.json` | recorded page counts and tap/swipe coordinates for each spec, replayed exactly on every run |
48
+ | `diff.py` | pixel diff with the status bar ignored. `--noise <dir>` masks pixels that already differed between two baseline runs |
49
+
50
+ ## When to re-record `plan.json`
51
+
52
+ ```bash
53
+ scripts/sdui-visual/run.sh record
54
+ ```
55
+
56
+ Re-record in these cases:
57
+ - **You use a different AVD.** Tap coordinates depend on screen size and density.
58
+ - **A spec's layout moved its tappable elements.**
59
+ - **You want a new spec to get tap states.**
60
+ - A spec missing from the plan is discovered on the fly: its pages are captured, and for specs in `TAPPABLE` (`drive.py`) so are its tap states.
61
+ - That discovery is not saved, so the taps can differ between runs until you re-record.
62
+ - Input specs are skipped because they need typing.
63
+
64
+ `record` also writes a fresh baseline. Run it on code you trust, before making the change.
@@ -0,0 +1,65 @@
1
+ # File: scripts/sdui-visual/diff.py
2
+ # Created At: 2026-11-10 15:30:00 +07:00
3
+ # Created By: AI
4
+ # AI Agent: Claude Code
5
+ # Model: claude-opus-5-5
6
+ """Pixel-diff two capture folders. usage: diff.py <a> <b> <diffdir> [--noise <baseline2 dir>]
7
+ Status bar (top 110 px, demo-mode clock is fixed but kept out anyway) is excluded. With --noise, pixels that differed
8
+ between the two baseline runs of the same image are masked (inherent noise: animations, image loading)."""
9
+ import json, os, sys
10
+ from PIL import Image, ImageChops
11
+
12
+ STATUS = 110
13
+
14
+
15
+ def load(p):
16
+ return Image.open(p).convert("RGB")
17
+
18
+
19
+ def mask_of(a, b):
20
+ d = ImageChops.difference(a, b).convert("L").point(lambda v: 255 if v else 0)
21
+ return d
22
+
23
+
24
+ def main():
25
+ a, b, out = sys.argv[1:4]
26
+ noise_dir = sys.argv[sys.argv.index("--noise") + 1] if "--noise" in sys.argv else None
27
+ os.makedirs(out, exist_ok=True)
28
+ rows = []
29
+ names = sorted(set(os.listdir(a)) | set(os.listdir(b)))
30
+ for n in names:
31
+ if not n.endswith(".png"):
32
+ continue
33
+ if n not in os.listdir(a) or n not in os.listdir(b):
34
+ rows.append((n, "MISSING", -1, -1, -1)); continue
35
+ ia, ib = load(f"{a}/{n}"), load(f"{b}/{n}")
36
+ if ia.size != ib.size:
37
+ rows.append((n, "SIZE", -1, -1, -1)); continue
38
+ w, h = ia.size
39
+ d = mask_of(ia, ib)
40
+ d.paste(0, (0, 0, w, STATUS))
41
+ raw = d.width * d.height - d.histogram()[0]
42
+ masked = raw
43
+ if noise_dir and os.path.exists(f"{noise_dir}/{n}"):
44
+ nz = mask_of(ia, load(f"{noise_dir}/{n}"))
45
+ keep = ImageChops.subtract(d, nz)
46
+ masked = keep.width * keep.height - keep.histogram()[0]
47
+ else:
48
+ keep = d
49
+ total = w * (h - STATUS)
50
+ if raw:
51
+ vis = ib.copy()
52
+ red = Image.new("RGB", ib.size, (255, 0, 0))
53
+ vis.paste(red, (0, 0), keep if masked else d)
54
+ vis.save(f"{out}/{n}")
55
+ rows.append((n, "OK", raw, masked, 100.0 * masked / total))
56
+ zero = sum(1 for r in rows if r[1] == "OK" and r[3] == 0)
57
+ for r in rows:
58
+ if r[1] != "OK" or r[2]:
59
+ print(f"{r[0]:40s} {r[1]:7s} raw={r[2]} beyond_noise={r[3]} ({r[4]:.4f}%)")
60
+ print(f"images={len(rows)} zero_beyond_noise={zero} raw_zero={sum(1 for r in rows if r[1]=='OK' and r[2]==0)}")
61
+ json.dump(rows, open(f"{out}/summary.json", "w"), indent=0)
62
+ sys.exit(0 if zero == len(rows) else 1)
63
+
64
+
65
+ main()
@@ -0,0 +1,234 @@
1
+ # File: scripts/sdui-visual/drive.py
2
+ # Created At: 2026-11-10 15:30:00 +07:00
3
+ # Created By: AI
4
+ # AI Agent: Claude Code
5
+ # Model: claude-opus-5-5
6
+ """Drive the sample app: open every bundled SDUI spec, capture pages + interaction states.
7
+
8
+ usage: drive.py <outdir> [--plan plan.json] [--record plan.json] [--only a,b]
9
+ --record: discover page counts + tap coordinates and save them (baseline run)
10
+ --plan: replay exactly the page counts + taps from a recorded plan
11
+ (a spec missing from the plan is discovered on the fly, not saved)
12
+ """
13
+ import io, json, re, subprocess, sys, time, os
14
+ from PIL import Image, ImageChops
15
+
16
+ PKG = "com.myapplication.MyApplication"
17
+ ACT = "com.myapplication.MainActivity"
18
+ USAGE_KT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..",
19
+ "sample/shared/src/commonMain/kotlin/screens/SduiUsage.kt")
20
+
21
+
22
+ def spec_list(name):
23
+ """A spec list (GALLERY / BLOCKS / SHOWCASE) exactly as the sample app shows it, read from SduiUsage.kt."""
24
+ src = open(USAGE_KT, encoding="utf-8").read()
25
+ m = re.search(r"val " + name + r" = listOf\(([^)]*)\)", src)
26
+ if not m:
27
+ raise SystemExit(f"{name} list not found in {USAGE_KT}")
28
+ return re.findall(r'"([^"]+)"', m.group(1))
29
+
30
+
31
+ # same order as the app's list screen
32
+ ALL = spec_list("SHOWCASE") + spec_list("BLOCKS") + spec_list("GALLERY")
33
+ # specs with state-changing actions (setState) that can be driven by taps (inputs need typing: skipped)
34
+ TAPPABLE = ["button", "carousel", "check-box", "chip", "collapse", "icon-button", "information", "popup-notify", "popup-promotion",
35
+ "radio", "rating", "slider", "stepper", "steps", "suggest-action", "swipe", "switch", "tab-view", "title",
36
+ "touchable-opacity", "uploader", "community", "paylater_benefits", "paylater_history"]
37
+ MAX_TAPS = 4
38
+ SETTLE = 3.0
39
+
40
+
41
+ def sh(*a, capture=True):
42
+ return subprocess.run(["adb", *a], capture_output=capture, check=False).stdout
43
+
44
+
45
+ def shot():
46
+ return Image.open(io.BytesIO(sh("exec-out", "screencap", "-p"))).convert("RGB")
47
+
48
+
49
+ def dump():
50
+ for _ in range(3):
51
+ sh("shell", "uiautomator", "dump", "/sdcard/ui.xml")
52
+ x = sh("shell", "cat", "/sdcard/ui.xml").decode("utf-8", "replace")
53
+ if "<hierarchy" in x:
54
+ return x
55
+ time.sleep(0.5)
56
+ return ""
57
+
58
+
59
+ NODE = re.compile(r'<node [^>]*>')
60
+ def nodes(xml):
61
+ out = []
62
+ for m in NODE.finditer(xml):
63
+ s = m.group(0)
64
+ g = lambda k: (re.search(k + r'="([^"]*)"', s) or [None, ""])[1]
65
+ b = re.match(r'\[(\d+),(\d+)\]\[(\d+),(\d+)\]', g("bounds"))
66
+ if not b:
67
+ continue
68
+ x1, y1, x2, y2 = map(int, b.groups())
69
+ out.append(dict(text=g("text"), desc=g("content-desc"), clickable=g("clickable") == "true", b=(x1, y1, x2, y2)))
70
+ return out
71
+
72
+
73
+ def tap(x, y):
74
+ sh("shell", "input", "tap", str(x), str(y))
75
+
76
+
77
+ def swipe_up(dist=1000, dur=1200):
78
+ sh("shell", "input", "swipe", "540", "1900", "540", str(1900 - dist), str(dur))
79
+
80
+
81
+ def swipe_down(dist=1000, dur=300):
82
+ sh("shell", "input", "swipe", "540", "700", "540", str(700 + dist), str(dur))
83
+
84
+
85
+ def find_text(name, tries=14, up=True):
86
+ for _ in range(tries):
87
+ for n in nodes(dump()):
88
+ if n["text"] == name and 250 < (n["b"][1] + n["b"][3]) // 2 < 2250:
89
+ return n
90
+ if up:
91
+ swipe_up(700, 600)
92
+ else:
93
+ swipe_down(1500, 300)
94
+ time.sleep(0.6)
95
+ return None
96
+
97
+
98
+ def launch_to_list():
99
+ sh("shell", "am", "force-stop", PKG)
100
+ sh("shell", "am", "start", "-n", f"{PKG}/{ACT}")
101
+ time.sleep(4)
102
+ n = find_text("SDUI", tries=25)
103
+ if not n:
104
+ raise SystemExit("SDUI entry not found")
105
+ x1, y1, x2, y2 = n["b"]
106
+ tap((x1 + x2) // 2, (y1 + y2) // 2)
107
+ time.sleep(2)
108
+
109
+
110
+ def to_top():
111
+ for _ in range(6):
112
+ swipe_down(1600, 200)
113
+ time.sleep(0.8)
114
+
115
+
116
+ def open_spec(name):
117
+ to_top()
118
+ n = find_text(name, tries=14)
119
+ if not n:
120
+ raise RuntimeError(f"spec {name} not found in list")
121
+ x1, y1, x2, y2 = n["b"]
122
+ tap((x1 + x2) // 2, (y1 + y2) // 2)
123
+ time.sleep(SETTLE)
124
+
125
+
126
+ def back():
127
+ sh("shell", "input", "keyevent", "4")
128
+ time.sleep(1.2)
129
+
130
+
131
+ EXTRA = {
132
+ "carousel": [["hswipe", 900, 543, 150, 400], ["hswipe", 900, 543, 150, 400]],
133
+ "slider": [["hswipe", 257, 463, 500, 800]],
134
+ "swipe": [["hswipe", 900, 520, 300, 800], ["hswipe", 200, 770, 800, 800]],
135
+ }
136
+
137
+
138
+ def act(a):
139
+ if a[0] == "tap":
140
+ tap(a[1], a[2])
141
+ elif a[0] == "scroll":
142
+ swipe_up(); time.sleep(0.3)
143
+ elif a[0] == "hswipe":
144
+ sh("shell", "input", "swipe", str(a[1]), str(a[2]), str(a[3]), str(a[2]), str(a[4]))
145
+
146
+
147
+ def same(a, b):
148
+ return ImageChops.difference(a, b).getbbox() is None
149
+
150
+
151
+ def run(outdir, plan, record_path, only):
152
+ os.makedirs(outdir, exist_ok=True)
153
+ launch_to_list()
154
+ new_plan = {}
155
+ for name in ALL:
156
+ if only and name not in only:
157
+ continue
158
+ entry = (plan or {}).get(name)
159
+ t0 = time.time()
160
+ # ---- pages
161
+ open_spec(name)
162
+ pages = []
163
+ img = shot(); img.save(f"{outdir}/{name}-p0.png"); pages.append(img)
164
+ if entry is not None:
165
+ for p in range(1, entry["pages"]):
166
+ swipe_up(); time.sleep(1.5)
167
+ img = shot(); img.save(f"{outdir}/{name}-p{p}.png")
168
+ else:
169
+ for p in range(1, 10):
170
+ swipe_up(); time.sleep(1.5)
171
+ img = shot()
172
+ if same(img, pages[-1]):
173
+ break
174
+ img.save(f"{outdir}/{name}-p{p}.png"); pages.append(img)
175
+ npages = entry["pages"] if entry is not None else len(pages)
176
+ back()
177
+ # ---- interaction states
178
+ taps = []
179
+ if name in TAPPABLE:
180
+ open_spec(name)
181
+ if entry is not None:
182
+ taps = entry["taps"]
183
+ for k, a in enumerate(taps):
184
+ act(a)
185
+ if a[0] == "scroll":
186
+ if k + 1 < len(taps) and taps[k + 1][0] != "scroll":
187
+ time.sleep(1.5)
188
+ continue
189
+ time.sleep(1.8)
190
+ shot().save(f"{outdir}/{name}-tap{k}.png")
191
+ else:
192
+ k = 0
193
+ for pg in range(npages if npages > 1 else 1):
194
+ if pg > 0 and pg != npages - 1:
195
+ continue
196
+ if pg > 0:
197
+ for _ in range(npages - 1):
198
+ a = ["scroll"]; act(a); taps.append(a)
199
+ time.sleep(1.5)
200
+ seen = set(); n_here = 0
201
+ for n in [n for n in nodes(dump()) if n["clickable"] and n["b"][1] > 300 and n["b"][3] < 2250]:
202
+ c = ((n["b"][0] + n["b"][2]) // 2, (n["b"][1] + n["b"][3]) // 2)
203
+ if c in seen:
204
+ continue
205
+ seen.add(c)
206
+ a = ["tap", c[0], c[1]]; act(a); taps.append(a); time.sleep(1.8)
207
+ shot().save(f"{outdir}/{name}-tap{len(taps) - 1}.png")
208
+ n_here += 1
209
+ if n_here >= MAX_TAPS:
210
+ break
211
+ for a in EXTRA.get(name, []):
212
+ act(a); taps.append(a); time.sleep(1.8)
213
+ shot().save(f"{outdir}/{name}-tap{len(taps) - 1}.png")
214
+ back()
215
+ # a tap may have opened a popup / modal: make sure we are back on the list
216
+ if not find_text(name, tries=1):
217
+ back()
218
+ new_plan[name] = {"pages": npages, "taps": taps}
219
+ print(f"{name}: pages={npages} taps={len(taps)} ({time.time() - t0:.1f}s)", flush=True)
220
+ if record_path:
221
+ json.dump(new_plan, open(record_path, "w"), indent=1)
222
+
223
+
224
+ if __name__ == "__main__":
225
+ args = sys.argv[1:]
226
+ out = args[0]
227
+ plan = rec = None; only = None
228
+ if "--plan" in args:
229
+ plan = json.load(open(args[args.index("--plan") + 1]))
230
+ if "--record" in args:
231
+ rec = args[args.index("--record") + 1]
232
+ if "--only" in args:
233
+ only = set(args[args.index("--only") + 1].split(","))
234
+ run(out, plan, rec, only)