@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-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 (202) hide show
  1. package/CLAUDE.md +12 -8
  2. package/README.md +8 -7
  3. package/compose/build.gradle.kts +2 -4
  4. package/compose/build.gradle.kts.backup +1 -3
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
  84. package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
  85. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
  86. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
  87. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
  88. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
  89. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
  90. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
  91. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  92. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
  93. package/gradle/libs.versions.toml +1 -3
  94. package/gradle.properties +1 -3
  95. package/ios/Application/ApplicationEnvironment.swift +6 -4
  96. package/ios/Application/DesignSystemKits.swift +59 -13
  97. package/ios/Application/DesignSystemKitsPayload.swift +0 -8
  98. package/ios/Application/LanguageSource.swift +2 -11
  99. package/ios/Application/Localize.swift +8 -35
  100. package/ios/Application/LocalizeModifier.swift +2 -11
  101. package/ios/Application/MaxApi.swift +3 -11
  102. package/ios/Avatar/Avatar.swift +0 -1
  103. package/ios/Badge/Badge.swift +5 -8
  104. package/ios/Badge/BadgeRibbon.swift +2 -5
  105. package/ios/Button/Button.swift +4 -8
  106. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
  107. package/ios/Carousel/Carousel.swift +4 -17
  108. package/ios/Checkbox/Checkbox.swift +0 -2
  109. package/ios/Collapse/Collapse.swift +17 -11
  110. package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
  111. package/ios/DateTimePicker/DateTimePicker.swift +4 -10
  112. package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
  113. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
  114. package/ios/DateTimePicker/WheelPicker.swift +2 -4
  115. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  116. package/ios/Extensions/Color++.swift +2 -4
  117. package/ios/Extensions/SkeletonUICompat.swift +0 -8
  118. package/ios/Icon/Icon.swift +3 -6
  119. package/ios/IconButton/IconButton.swift +2 -5
  120. package/ios/Input/ErrorView.swift +0 -7
  121. package/ios/Input/Input.swift +9 -20
  122. package/ios/Input/InputPhoneNumber.swift +37 -20
  123. package/ios/Input/InputSearch.swift +23 -12
  124. package/ios/Input/InputTextArea.swift +4 -13
  125. package/ios/InputDropDown/InputDropDown.swift +1 -11
  126. package/ios/InputMoney/InputMoney.swift +9 -28
  127. package/ios/InputOTP/InputOTP.swift +2 -9
  128. package/ios/Layout/HeaderLayout.swift +72 -0
  129. package/ios/Layout/Item.swift +1 -2
  130. package/ios/Layout/ModalLayout.swift +144 -0
  131. package/ios/Layout/ScreenLayout.swift +48 -31
  132. package/ios/Layout/Section.swift +2 -3
  133. package/ios/Loader/Loader.swift +3 -12
  134. package/ios/Lottie/LottieView.swift +0 -11
  135. package/ios/Navigation/BottomSheet.swift +73 -94
  136. package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
  137. package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
  138. package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
  139. package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
  140. package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
  141. package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
  142. package/ios/Navigation/Component/FloatingButton.swift +4 -11
  143. package/ios/Navigation/Component/Header.swift +35 -54
  144. package/ios/Navigation/Component/HeaderBackground.swift +2 -8
  145. package/ios/Navigation/Component/HeaderJourney.swift +4 -8
  146. package/ios/Navigation/Component/HeaderLocation.swift +4 -8
  147. package/ios/Navigation/Component/HeaderRight.swift +20 -22
  148. package/ios/Navigation/Component/HeaderTitle.swift +1 -6
  149. package/ios/Navigation/Component/HeaderUser.swift +4 -10
  150. package/ios/Navigation/Component/SideBar.swift +6 -21
  151. package/ios/Navigation/Component/SnackBar.swift +9 -13
  152. package/ios/Navigation/HostBackGestureBridge.swift +2 -9
  153. package/ios/Navigation/ModalScreen.swift +24 -13
  154. package/ios/Navigation/Navigation.swift +35 -19
  155. package/ios/Navigation/NavigationContainer.swift +4 -15
  156. package/ios/Navigation/Navigator.swift +21 -39
  157. package/ios/Navigation/StackScreen.swift +64 -51
  158. package/ios/Navigation/StackTransition.swift +7 -14
  159. package/ios/Navigation/SwipeBackHaptic.swift +2 -7
  160. package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
  161. package/ios/Pagination/PaginationDot.swift +0 -9
  162. package/ios/Pagination/PaginationNumber.swift +1 -9
  163. package/ios/Pagination/PaginationScroll.swift +2 -14
  164. package/ios/Pagination/PaginationWhiteDot.swift +1 -10
  165. package/ios/Popup/PopupDisplay.swift +7 -5
  166. package/ios/Popup/PopupInput.swift +6 -4
  167. package/ios/Popup/PopupLayout.swift +17 -9
  168. package/ios/Popup/PopupNotify.swift +32 -25
  169. package/ios/PopupView/FullscreenPopup.swift +3 -4
  170. package/ios/PopupView/PopupView.swift +2 -2
  171. package/ios/PopupView/Utils++.swift +1 -2
  172. package/ios/ProgressInfo/ProgressInfo.swift +2 -13
  173. package/ios/Skeleton/Skeleton.swift +5 -16
  174. package/ios/Slider/Slider.swift +5 -12
  175. package/ios/StatusBarTap/StatusBarTap.h +2 -3
  176. package/ios/StatusBarTap/StatusBarTap.m +3 -16
  177. package/ios/Stepper/Stepper.swift +8 -27
  178. package/ios/Steps/Steps.swift +29 -26
  179. package/ios/Swipeable/SwipeCell.swift +2 -2
  180. package/ios/Swipeable/SwipeCellModel.swift +3 -6
  181. package/ios/TabView/TabView.swift +14 -28
  182. package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
  183. package/ios/Title/Title.swift +1 -3
  184. package/ios/Tooltip/Tooltip.swift +4 -9
  185. package/ios/Typography/FontScale.swift +79 -24
  186. package/ios/Typography/Text.swift +6 -12
  187. package/ios/Typography/Typography.swift +8 -11
  188. package/ios/Uploader/Uploader.swift +2 -17
  189. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  190. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  191. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
  192. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
  193. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
  194. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
  195. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
  196. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  197. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
  198. package/package.json +1 -1
  199. package/publish.sh +8 -2
  200. package/scripts/ci/build-swiftui.sh +22 -0
  201. package/scripts/ci/resolve-version.mjs +144 -0
  202. package/settings.gradle.kts +0 -1
package/CLAUDE.md CHANGED
@@ -42,19 +42,19 @@ xcodebuild -project sample/iosApp/Pods/Pods.xcodeproj -scheme MoMoUIKits -sdk ip
42
42
  -destination 'generic/platform=iOS Simulator' build
43
43
  ```
44
44
 
45
- 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).
45
+ Publishing is automated (`.gitlab-ci.yml` → `publish.sh`; see `PUBLISH_GUIDE.md`): `main` → npm latest + 1 patch (tag `latest`; a manual run with `RELEASE_VERSION` sets the sprint version), other branches on `[ci build]` → `<npm latest + 1 patch>-beta.N`. The version is never stored in the repo — `scripts/ci/resolve-version.mjs` bases it on npm and only takes a number free on **both** npm (incl. `-debug`) and GitLab Maven. Locally, `bash publish.sh local` publishes a beta of the working tree as is (uncommitted changes too, any branch; same beta numbering); `release` is CI-only. Do not publish unless asked; `bash publish.sh local --dry-run` shows the version and packs the tarballs without uploading.
46
46
 
47
47
  ## Architecture essentials
48
48
 
49
49
  - **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. The legacy `Screen` / `ApplicationContainer` / `ComposeApi` stack has been removed on both sides — don't reintroduce it.
50
- - **Configuration flows via CompositionLocals**, not params. Public ones: `AppTheme`, `AppStatusBar`, `AppNavigationBar` (`const/Theme.kt`); `ApplicationContext`, `AppConfig`, `AppLanguage`, `LocalLocalize` (`application/`); `LocalNavigator`, `LocalMaxApi` (`navigation/`). Read with `X.current`.
50
+ - **Configuration flows via CompositionLocals**, not params. Public ones: `AppTheme`, `AppStatusBar`, `AppNavigationBar` (`const/Theme.kt`); `ApplicationContext`, `AppConfig`, `AppLanguage`, `LocalLocalize` (`application/`); `LocalNavigator`, `LocalKitsBinding` (`navigation/`). Read with `X.current`.
51
51
  - **`DesignSystemKits`** (`application/DesignSystemKits.kt`) is the single app-wide holder for the host-owned design-system inputs: font scale (`userScaleRate` / `useOSScaleRate`), whitelist (`isWhiteList`) and the remote `DesignSystemConfig`, bundled as `DesignSystemKitsConfigs`. The host calls `DesignSystemKits.init(source)` once at startup with its `DesignSystemKitsSource` (sync `getConfigs()` seed + `configsFlow`); `init` is idempotent. Without a source, call `setConfigs(...)` directly. Read with `getConfigs()` (snapshot state, recomposes); non-Compose observers use `configsFlow`.
52
52
  - **SwiftUI twin:** `ios/Application/DesignSystemKits.swift` mirrors it field for field (`DesignSystemKitsConfigs` with `designSystemConfig: KitConfig?`, `setConfigs` / `getConfigs`), plus the OS Dynamic Type factor (`osFontScale`). There is no `init(source:)` (Swift reserves `init`): the host observes its own bridge and pushes. A host that can't share Swift types (the KMP bridge) calls `DesignSystemKits.shared.setConfigs(json:)` (`ios/Application/DesignSystemKitsPayload.swift`); the JSON field names are a contract with momo-app's serializer (`HostDesignSystemKits.observeConfigsJson`, payload classes in `DesignSystemData.kt`) — change both together. Invalid JSON is ignored. The SwiftUI kit can't link the Kotlin `kits` framework (a second Kotlin/Native runtime would hold a second, never-initialized singleton), so the render-time logic — `FontScale` formula, Dynamic Type observation — is intentionally duplicated in Swift; only values flow across.
53
53
  - **Design-system config** (`trustBanner`, `headerBar`, `headerGradient`): `NavigationContainer` provides it as `LocalDesignSystemConfig` (param `designSystemConfig` → parent → `DesignSystemKits`) and applies `headerBar` as the header image when the theme has none.
54
54
  - **Platform code** goes through `expect`/`actual` in `platform/` — never reference Android/iOS APIs from `commonMain` directly.
55
- - **Native bridge:** typed `IMaxApi` from NativeMaxApi `0.3.1` (`vn.momo.maxapi`, exposed as `LocalMaxApi`) is the host-app bridge. Toolkit uses `ToolkitOptions` to preserve custom groups and system-tool policy; pending callbacks are cancelled when their composition is disposed. Containers borrow the host client and must not close it.
55
+ - **Host bridge:** `KitsBinding` (`application/KitsBinding.kt`, exposed as `LocalKitsBinding`) lists the only host services the kit calls; the host adapts its MaxApi to it. The kit must not depend on NativeMaxApi, common-model or foundation-model — add a binding method with kit-owned types instead. Callbacks fire on success only; pending `KitsRequest`s are cancelled when their composition is disposed. Containers borrow the binding and must not close it.
56
56
  - Navigation uses a runtime `DynamicScreenRegistry`; overlays (modal/bottom-sheet/snackbar) go through `Navigator` + `OverplayComponentRegistry`.
57
- - **iOS swipe-back:** the host owns the only edge-pan recogniser and replays it through `HostBackGestureBridge` (`navigation/HostBackGestureBridge.kt`; the kit framework is never exported, so the host reaches it through its own Koin-provided facade): `checkCanPop` / `canPopInner` / `pop` route the back into the kit stack, `started` / `progressed` / `completed` / `cancelled` seek the NavHost transition, `shouldUseFloatingArrowBack` is set by bottom tabs. `NavigationContainer` attaches itself automatically (`AttachHostBackGesture`, iOS only, detached by identity on dispose) — hosts need no wrapper and no `setNavigator`. `maxApi` is a required parameter of `NavigationContainer` — every container, nested or root, is handed its host bridge explicitly.
57
+ - **iOS swipe-back:** the host owns the only edge-pan recogniser and replays it through `HostBackGestureBridge` (`navigation/HostBackGestureBridge.kt`; the kit framework is never exported, so the host reaches it through its own Koin-provided facade): `checkCanPop` / `canPopInner` / `pop` route the back into the kit stack, `started` / `progressed` / `completed` / `cancelled` seek the NavHost transition, `shouldUseFloatingArrowBack` is set by bottom tabs. `NavigationContainer` attaches itself automatically (`AttachHostBackGesture`, iOS only, detached by identity on dispose) — hosts need no wrapper and no `setNavigator`. `binding` is optional: a container uses the one passed in, then the enclosing container's, then `KitsHost.binding` — the host installs it once with `KitsHost.install`, and packages that only render kit screens pass none (before an install it does nothing).
58
58
 
59
59
  ## SwiftUI kit (`ios/`)
60
60
 
@@ -71,17 +71,20 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
71
71
  ## Screen layout / iPhone Duo (port of RN `useScreenLayout`, momo-kits !664)
72
72
 
73
73
  - `layout/ScreenLayout.kt`: `getScreenLayout()` returns window size, raw top/bottom + side insets, `contentWidth`, header geometry, the iPhone Duo `sideBar` and `duoTopInset`. `NavigationContainer` computes it once and provides `LocalScreenLayout`; reactive to fold/unfold and rotation (window size + `WindowInsets`). Metrics (`DuoMetrics`, 72pt iPhone header floor, 20pt status-bar threshold) mirror RN `Layout/utils.ts` — change both together.
74
- - iPhone-only: everything gates on `isPhoneIdiom()` (`platform/`), never on "iOS", so iPad windows keep the regular layout. Two detectors, as in RN: `isIPhoneDuo` (window aspect < 1.6 or asymmetric side insets) drives layout; `isIPhoneDuoDevice` (Apple's foldable check: a `.division` reserved region, queried with include-inactive; Swift also latches on `UIHingeInteraction`) drives popups, modal and bottom sheet.
74
+ - iPhone-only: everything gates on `isPhoneIdiom()` (`platform/`), never on "iOS", so iPad windows keep the regular layout. Two detectors, as in RN: `isIPhoneDuo` (window aspect < 1.6 or asymmetric side insets) drives layout; `isIPhoneDuoDevice` (Apple's foldable check: a `.division` reserved region, queried with include-inactive; Swift also latches on `UIHingeInteraction`; or asymmetric side insets, since the outer display reports no hinge) drives popups, modal and bottom sheet.
75
75
  - Header height is `headerHeight` (not `AppStatusBar + HEADER_HEIGHT`); the bar row is `headerBarHeight` and starts `headerStatusBarHeight` below the window top. When the status bar is off the top edge (iPhone landscape, iPhone Duo) `headerStatusBarHeight` is 0 so the title stays centered — except on the Duo outer display: in portrait the header is 76pt and the row starts at 14pt so the title centers on the camera punchout; in landscape the row centers on the camera when it sits at the top end of the strip (else on the back button) and the header reaches 8pt below the back button.
76
76
  - iPhone Duo inner display in portrait (status bar on top): the header row shares the status bar band — `headerHeight` 94pt (2 × the clock digits' y 47), `headerStatusBarHeight` 0 — and `ScreenLayout.statusBarClearance` keeps it between the clock / battery clusters (from reserved regions, else 128pt on the right). Back and toolkit use the 48pt side bar controls laid out horizontally (`ToolkitLayout.SideBarRow`); the collapsed search and a centered title stay clear of the clusters. Port of momo-kits `90af33ba2`.
77
77
  - iPhone Duo with a side strip ≥ 60pt: back + toolkit leave the bar for `HeaderSideBar` (`navigation/component/SideBar.kt`, 48pt glass controls); custom header-right stays in the bar. `sideBar.top` is 170pt in portrait, 120pt on the inner display in landscape (height ≥ 600), 24pt on the outer display in landscape, or below the header when the status bar is on top; UIKit's `statusBarFrame` is useless on Duo. Unlike RN the column is clamped above footer (24pt gap) / rail (12pt gap).
78
78
  - Reserved regions (iOS 27.1 `reservedRegionsOfKind:`, reached through the ObjC runtime so older SDKs still build): a probe `UIView` (`platform/ReservedRegions.ios.kt` on the Compose root view; `ReservedRegionsProbe` inside SwiftUI `momoScreenLayout()`) re-reads them in `layoutSubviews`, which UIKit re-runs when they change. They push `sideBar.top` below the status cluster as it grows for calls / Live Activities, and `sideBar.bottom` (≥ 24pt) above a camera at the bottom end of the strip.
79
79
  - Tab bar on Duo is `bottomtab/DuoTabBar.kt`: a rail in the side strip (`sideBar.bottom` above the window bottom, QR below it) or, without a side bar, a floating bar spanning 6/8 grid columns. Both overlay the content; `duoFloatingTabBarInset` pads tab content, footer and FAB.
80
+ - Duo tab selection motion (`bottomtab/DuoLiquidSelection.kt` / `ios/Navigation/BottomTab/DuoLiquidSelection.swift`, port of RN `useLiquidSelection.ts`, momo-kits !682): press lifts the lens, a drag past 10pt takes over (Compose: the bar's `pointerInput` consumes and so cancels the tab's clickable; SwiftUI: one `DragGesture` over the bar, tabs are not `Button`s), long press calls `BottomTab(onTabLongPress)` and release still selects, Reduce Motion (`platform/ReduceMotion`) falls back to a plain slide. SwiftUI integrates the lens spring on a display link because the stretch and the tabs' active tint read it every frame. Constants mirror RN — change both together.
80
81
  - Bar compression (`bottomtab/DuoBarCompression.kt`, HIG "Vertical controls"): when toolbar + rail don't fit in the strip, one is compressed — the toolkit into a `navigation_menu` button, the rail into one button showing the current tab — and tapping it swaps them; `BottomTab(compressionBehavior)` picks which starts compressed. If neither fits beside the other compressed, both rest compressed and a tap opens one for a moment. Side bar columns report their full height (0 when the screen puts nothing there) so the decision follows each screen's toolkit.
81
82
  - Glass header: on Duo with a side bar, Default/Extended headers without search and with a `ScrollState` let content scroll under the bar (`usesDuoGlassHeader`); the bar fades in a translucent surface + hairline over 16pt (Compose has no backdrop blur — RN's fallback look), the gradient leaves with the content.
82
83
  - Quick return header: glass headers and Animated headers (with a `ScrollState`) on the Duo side bar layout slide out with the content and back in on a reverse scroll; a half-shown header settles in or out once the scroll stops. The side bar is drawn apart from the header, so it stays put.
83
- - Overlays on Duo: popups cap at 440pt wide and the room between `duoTopInset` and the bottom inset (body scrolls, actions stay); modal centers inside that room; bottom sheet uses the window height, centers at width ≥ 600 and pads by side insets in landscape.
84
+ - Overlays on foldables (`layout/ModalLayout.kt` / `ios/Layout/ModalLayout.swift`, Figma "Modal - Foldable Guideline", constants shared with RN): foldable = `isIPhoneDuoDevice` or a window short side ≥ 600, so phones (landscape too) keep their look. The resolver returns the placement (safe area, so left of the Duo control column; right of an active vertical division when a Duo is half folded — Swift also needs `UIHingeInteraction` `.partiallyOpen`; Android half fold stays flat), popup geometry (width clamp(placement − 2·margin, 280, 450), margin 24 or 12 on the Duo outer display / half fold, max height min(600, placement − 48), radius 24; only the PopupNotify description scrolls) and sheet geometry (width min(placement − 24, 653) ≥ 296, bottom anchored, max height window − top inset − 12, min height 230, radius 24 top). Scrim is black 20% over the whole window on foldables (0.6 on phones). Snackbars keep clear of the strip. On every device (RN parity) popup close and sheet header back / close are `ModalIconButton`: 32pt circle on `background.surface` with a 1pt `border.default` stroke, 20pt `text.default` icon; the popup close sits inside the card 12pt from the top right (`PopupPromotion` keeps its close under the image), the default sheet header is 56 tall, 12 padding, 8 gap.
85
+ - Bottom sheet on Duo: stays in the placement, never on or under the side strip; back / close stay in the header row (no side column). `BottomHeader.Title(onBack)` / `.title(onBack:)` closes the sheet, then runs (RN `leftOptions.onPressIconLeft`).
84
86
  - Font scale deliberately uses the short side (`min(w, h)`), unlike RN which reads the window width — landscape must not inflate every font.
87
+ - Font scale measures the **window**, never `UIScreen.main`: on iPhone Duo the main screen stays on one display while the window follows the one in use. Compose iOS `getScreenDimensions()` reads `LocalWindowInfo.containerSize` (recomposes on fold/unfold); SwiftUI `DesignSystemKits` KVO-observes each `UIWindowScene.effectiveGeometry` and republishes `windowShortSide`.
85
88
  - `StackScreen` pads content/footer/search/FAB by the side insets and provides an inset-consumed layout to its content; a bottom-tab root stays full width (tab bar + each tab's StackScreen handle insets). Grid columns use `contentWidth`.
86
89
 
87
90
  ## i18n / Localize (port of RN `Localize`)
@@ -104,12 +107,13 @@ The SwiftUI port differs from Compose in one important way: **it follows the hos
104
107
 
105
108
  ## Font scale (`scaleSize`)
106
109
 
107
- One formula, both platforms: the device-width scale (`width / 375`, capped at `+5pt`) and the OS Dynamic Type scale (capped at `1.5×`) are computed independently and the **larger wins**. When `useOSScaleRate` is false neither applies — the size is just multiplied by `userScaleRate`. Max font scale is fixed at 1.5; the old per-call/per-scope override is deprecated and ignored on both sides.
110
+ One formula, both platforms: the device-width scale (`width / 375`, capped at `+5pt`) and the OS Dynamic Type scale (capped at `1.5×`) are computed independently and the **larger wins**. When `useOSScaleRate` is false neither applies — the size is just multiplied by `userScaleRate`. The OS scale is capped at 1.5 by default; `MiniAppContext.scaleSizeMaxRate` (both sides) or `ScaleSizeScope(rate)` (Compose; SwiftUI also `.scaleSizeMaxRate(_:)`) caps a subtree at size × rate on both paths, nearest scope wins, null/nil lifts it (RN `ScaleSizeProvider`). The `ScaleSizeMaxRate` CompositionLocal is deprecated and not read.
108
111
 
109
112
  - **Compose** — `const/Typography.kt` (`scaleSize` overloads for `Float`/`Dp`/`TextUnit`/`TextStyle`). The `TextUnit` overload divides by `density.fontScale` so Compose's own `sp` scaling isn't applied twice. Inputs: `LocalContext.current` (`MiniAppContext.userScaleRate` / `useOSScaleRate`, per-field) falling back to `DesignSystemKits.getConfigs()`. On iOS, `platform/OsFontScale.ios.kt` observes `UIContentSizeCategoryDidChangeNotification` and overrides `LocalDensity` — Compose MP otherwise reads `fontScale` once at `ComposeUIViewController` creation. Wired at `NavigationContainer`.
110
113
  - **SwiftUI** — `ios/Typography/FontScale.swift`. `FontScale` is an immutable snapshot with `callAsFunction`, so a view reads `@Environment(\.momoFontScale) private var fontScale` and calls `fontScale(16)`. `DesignSystemKits.shared` is the `ObservableObject` holding the host inputs and the OS factor (it observes `UIContentSizeCategory.didChangeNotification`); the host pushes them with `setConfigs(_:)`.
111
114
  - **Never set `\.momoFontScale` directly** — same trap as `\.localize`. Inject via `.momoFontScale(_:context:)`, which holds `DesignSystemKits` as `@ObservedObject`; that is what re-publishes the snapshot. It also injects `\.designSystemKitsConfigs`, which `MomoText` (whitelist font) and `TrustBanner` (fallback after `ApplicationEnvironment.config`) read so a host push re-renders them. `NavigationContainer` does it (passing `MiniAppContext` so the per-mini-app override applies); a bare `UIHostingController` root must too. The environment default reads the live store, so an un-injected subtree still gets correct values — just not live ones.
112
115
  - The global `scaleSize(_:)` and `Font.appFont(size:)` remain for call sites that can't read the environment (UIKit bridges, free functions). They are **not** reactive. `Font.header_default_bold` & friends are computed `static var`s for the same reason — as stored `static let`s they froze the scale at first access. `UIViewRepresentable`s should read `context.environment.momoFontScale` instead, and re-apply the font in `updateUIView`, not only in `makeUIView`.
116
+ - **Bottom tab bar** — `BottomTab` caps the whole bar once at its root at `TabBarMetrics.LABEL_MAX_SCALE` / `labelMaxScale` (1.2, RN wraps `renderTabBar` in `ScaleSizeProvider`), so labels fit the fixed-height slots and the notch; the tab badge nests a scope of 1 to keep its design size. Consumer `iconContent` / `labelContent` sit under the same cap.
113
117
 
114
118
  ## Code conventions
115
119
 
@@ -132,7 +136,7 @@ Prefer one tight line at the surprising spot over a paragraph. Match the (low) c
132
136
  ## Gotchas
133
137
 
134
138
  - **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.
135
- - `LiteScreen` keeps its own `application.HeaderType` enum (`DEFAULT`/`EXTENDED`/`NONE`), unrelated to the sealed `navigation.component.HeaderType`; its toolkit is the navigation `Toolkit` (through `LocalMaxApi`).
139
+ - `LiteScreen` keeps its own `application.HeaderType` enum (`DEFAULT`/`EXTENDED`/`NONE`), unrelated to the sealed `navigation.component.HeaderType`; its toolkit is the navigation `Toolkit` (through `LocalKitsBinding`).
136
140
  - iOS strings/maps must survive Kotlin/Native framework packaging — keep them compiled-in, not loaded from resource bundles.
137
141
 
138
142
  ## Code comments
package/README.md CHANGED
@@ -114,7 +114,6 @@ NavigationContainer(
114
114
  options = NavigationOptions(headerTitle = HeaderTitle.Default("Home")),
115
115
  applicationContext = miniAppContext,
116
116
  config = KitConfig(trustBanner = defaultBanner),
117
- maxApi = maxApi, // IMaxApi implementation từ host
118
117
  setNavigator = { navigator = it }
119
118
  )
120
119
  ```
@@ -175,11 +174,13 @@ fun SuccessState() {
175
174
 
176
175
  - `shared/build.gradle.kts` đã bật `coreLibraryDesugaringEnabled` để tương thích `compottie-dot`/`compottie-network` với `minSdk = 24`.
177
176
  - Nếu animation dùng asset/font nội bộ, kết hợp `compottie-resources` (`rememberResourcesAssetsManager`, `rememberResourcesFontManager`) để trỏ về `composeResources`.
178
- ### NativeMaxApi 0.3.1
179
-
180
- Compose dùng typed `vn.momo.maxapi.IMaxApi` do host truyền vào `NavigationContainer`.
181
- Toolkit dùng overload `showToolkit(ToolkitOptions, callback)` để giữ nhóm tool tùy chỉnh,
182
- nhãn đa ngôn ngữ, icon, badge và `useSystemTools`. Callback trả `actionKey`; request đang chờ
183
- được hủy khi composition bị gỡ. Kits không đóng client do host sở hữu.
177
+ ### KitsBinding (host bridge)
178
+
179
+ Kits không phụ thuộc NativeMaxApi hay model của host. Host cài `KitsBinding` một lần bằng
180
+ `KitsHost.install(binding)` (`vn.momo.kits.application`); `NavigationContainer` / `WidgetContainer`
181
+ dùng binding truyền vào, rồi của container bao ngoài, rồi `KitsHost.binding` (chưa cài thì không làm gì),
182
+ nên package chỉ dùng kits không cần binding riêng. Host tự chuyển sang bridge của mình (MaxApi): dismiss, trackEvent, getLanguage, haptic, toolkit (favorite,
183
+ `showToolkit(tools, useSystemTools)` trả `actionKey`), Help Center và log lỗi. Callback chỉ gọi khi
184
+ thành công; request đang chờ (`KitsRequest`) được hủy khi composition bị gỡ. Kits không đóng binding.
184
185
 
185
186
  Chạy `./gradlew :compose:testAndroidHostTest` để kiểm tra hủy request và callback đến muộn.
@@ -48,7 +48,7 @@ kotlin {
48
48
  }
49
49
 
50
50
  cocoapods {
51
- version = "0.300.7-debug"
51
+ version = "0.300.8-beta.1-debug"
52
52
  summary = "IOS Shared module"
53
53
  homepage = "https://momo.vn"
54
54
  ios.deploymentTarget = "15.0"
@@ -81,9 +81,8 @@ kotlin {
81
81
  implementation(libs.coil.multiplatform.compose)
82
82
  implementation(libs.coil.multiplatform.core)
83
83
  implementation(libs.coil.multiplatform.network.ktor)
84
- implementation(libs.jetbrains.serialization.json)
84
+ api(libs.jetbrains.serialization.json)
85
85
  implementation(libs.kotlinx.datetime)
86
- api(libs.native.max.api)
87
86
  implementation(libs.compottie)
88
87
  implementation(libs.gif.image)
89
88
  }
@@ -111,7 +110,6 @@ repositories {
111
110
  }
112
111
  }
113
112
  mavenCentral()
114
- maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
115
113
  maven {
116
114
  url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
117
115
  credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
@@ -81,9 +81,8 @@ kotlin {
81
81
  implementation(libs.coil.multiplatform.compose)
82
82
  implementation(libs.coil.multiplatform.core)
83
83
  implementation(libs.coil.multiplatform.network.ktor)
84
- implementation(libs.jetbrains.serialization.json)
84
+ api(libs.jetbrains.serialization.json)
85
85
  implementation(libs.kotlinx.datetime)
86
- api(libs.native.max.api)
87
86
  implementation(libs.compottie)
88
87
  implementation(libs.gif.image)
89
88
  }
@@ -111,7 +110,6 @@ repositories {
111
110
  }
112
111
  }
113
112
  mavenCentral()
114
- maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
115
113
  maven {
116
114
  url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
117
115
  credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
@@ -12,8 +12,7 @@ internal actual fun hostFontFamily(fileName: String, weight: FontWeight): FontFa
12
12
  val assets = LocalContext.current.applicationContext.assets
13
13
  return remember(fileName, weight) {
14
14
  val path = "fonts/$fileName"
15
- // AssetManager.open ném IOException nếu thiếu file; Font(path, assetManager) thì lỗi
16
- // muộn lúc render nên phải kiểm tra tồn tại trước.
15
+ // Font(path, assetManager) only fails later at render time, so check the asset exists first.
17
16
  val exists = runCatching { assets.open(path).close() }.isSuccess
18
17
  if (exists) FontFamily(Font(path = path, assetManager = assets, weight = weight)) else null
19
18
  }
@@ -88,10 +88,11 @@ actual fun LottieAnimation(
88
88
  isPlaying: Boolean,
89
89
  onEvent: ((String) -> Unit)?,
90
90
  modifier: Modifier,
91
- useCompose: Boolean
91
+ useCompose: Boolean,
92
+ progress: (() -> Float)?,
92
93
  ) {
93
94
  if (useCompose) {
94
- ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
95
+ ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier, progress)
95
96
  return
96
97
  }
97
98
 
@@ -0,0 +1,17 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import android.provider.Settings
4
+ import androidx.compose.runtime.Composable
5
+ import androidx.compose.runtime.remember
6
+ import androidx.compose.ui.platform.LocalConfiguration
7
+ import androidx.compose.ui.platform.LocalContext
8
+
9
+ @Composable
10
+ actual fun rememberReduceMotion(): Boolean {
11
+ val context = LocalContext.current
12
+ // re-read on configuration changes; the setting has no observer of its own
13
+ val configuration = LocalConfiguration.current
14
+ return remember(context, configuration) {
15
+ Settings.Global.getFloat(context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) == 0f
16
+ }
17
+ }
@@ -106,5 +106,5 @@ val LocalDesignSystemConfig = staticCompositionLocalOf<DesignSystemConfig?> {
106
106
  null
107
107
  }
108
108
 
109
- @Deprecated("Max font scale is fixed at MAX_FONT_SCALE (1.5); this CompositionLocal is no longer read.")
109
+ @Deprecated("No longer read; wrap content in ScaleSizeScope(scaleSizeMaxRate) to cap the font scale.")
110
110
  val ScaleSizeMaxRate = staticCompositionLocalOf<Float?> { null }
@@ -36,9 +36,8 @@ object DesignSystemKits {
36
36
  private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
37
37
  private var observeJob: Job? = null
38
38
 
39
- // Snapshot state so Compose readers recompose (including non-composable getters like defaultTheme);
40
- // the StateFlow is for non-Compose observers, e.g. the host's SwiftUI bridge, where Compose's
41
- // global snapshot apply loop may never have started.
39
+ // Snapshot state recomposes Compose readers; the StateFlow serves non-Compose observers (the host
40
+ // SwiftUI bridge), where Compose's global snapshot apply loop may never have started.
42
41
  private var currentConfigs by mutableStateOf(DesignSystemKitsConfigs())
43
42
  private val mutableConfigsFlow = MutableStateFlow(currentConfigs)
44
43
  val configsFlow: StateFlow<DesignSystemKitsConfigs> = mutableConfigsFlow.asStateFlow()
@@ -0,0 +1,60 @@
1
+ package vn.momo.kits.application
2
+
3
+ import kotlinx.serialization.json.JsonElement
4
+ import kotlinx.serialization.json.JsonObject
5
+ import vn.momo.kits.navigation.component.ToolGroup
6
+
7
+ /**
8
+ * Host services the kit calls. The host adapts its own bridge (MaxApi) to this, so the kit ships no host SDK.
9
+ * Callbacks fire only on success; the kit drops late ones after cancelling their [KitsRequest].
10
+ * Containers borrow the binding and never close it.
11
+ */
12
+ interface KitsBinding {
13
+ fun dismiss(target: KitsDismissTarget)
14
+
15
+ fun trackEvent(eventName: String, attributes: JsonObject)
16
+
17
+ fun getLanguage(callback: (String) -> Unit): KitsRequest
18
+
19
+ fun vibrateLight() {}
20
+
21
+ fun checkFavorite(appCode: String?, callback: (Boolean) -> Unit): KitsRequest = KitsRequest.None
22
+
23
+ /** [callback] gets whether the app is a favorite afterwards. */
24
+ fun toggleFavorite(appCode: String?, callback: (Boolean) -> Unit): KitsRequest = KitsRequest.None
25
+
26
+ fun showToolkit(
27
+ tools: List<ToolGroup>,
28
+ useSystemTools: Boolean,
29
+ onAction: (actionKey: String) -> Unit,
30
+ ): KitsRequest = KitsRequest.None
31
+
32
+ /** The request stays open while the sheet may still emit events; cancel releases it. */
33
+ fun showHelpCenter(request: KitsHelpCenterRequest): KitsRequest = KitsRequest.None
34
+
35
+ fun logError(message: String) {}
36
+ }
37
+
38
+ enum class KitsDismissTarget {
39
+ /** Only the current mini app. */
40
+ Current,
41
+
42
+ /** Back to the host home, closing every mini app. */
43
+ All,
44
+ }
45
+
46
+ fun interface KitsRequest {
47
+ fun cancel()
48
+
49
+ companion object {
50
+ val None = KitsRequest {}
51
+ }
52
+ }
53
+
54
+ data class KitsHelpCenterRequest(
55
+ val appId: String?,
56
+ val code: String?,
57
+ val name: JsonElement?,
58
+ val icon: String?,
59
+ val description: JsonElement?,
60
+ )
@@ -0,0 +1,32 @@
1
+ package vn.momo.kits.application
2
+
3
+ import kotlin.concurrent.Volatile
4
+
5
+ /**
6
+ * The host installs its [KitsBinding] here once; containers use it unless a caller passes or provides another.
7
+ * Packages that only render kit screens never need a binding of their own.
8
+ */
9
+ object KitsHost {
10
+ @Volatile
11
+ private var installed: KitsBinding? = null
12
+
13
+ /** The installed binding, or one that does nothing while the host has not installed it yet. */
14
+ val binding: KitsBinding get() = installed ?: NoOpKitsBinding
15
+
16
+ /** The last install wins. The kit borrows the binding and never closes it. */
17
+ fun install(binding: KitsBinding) {
18
+ installed = binding
19
+ }
20
+
21
+ fun uninstall() {
22
+ installed = null
23
+ }
24
+ }
25
+
26
+ internal object NoOpKitsBinding : KitsBinding {
27
+ override fun dismiss(target: KitsDismissTarget) = Unit
28
+
29
+ override fun trackEvent(eventName: String, attributes: kotlinx.serialization.json.JsonObject) = Unit
30
+
31
+ override fun getLanguage(callback: (String) -> Unit): KitsRequest = KitsRequest.None
32
+ }
@@ -150,7 +150,6 @@ fun LiteScreen(
150
150
  verticalArrangement: Arrangement.Vertical = Arrangement.Top,
151
151
  horizontalAlignment: Alignment.Horizontal = Alignment.Start,
152
152
  backgroundColor: Color = AppTheme.current.colors.background.default,
153
- /* Begin of header props */
154
153
  title: String? = null,
155
154
  inputSearchProps: LiteInputSearchProps? = null,
156
155
  goBack: (() -> Unit)? = null,
@@ -161,7 +160,6 @@ fun LiteScreen(
161
160
  headerTintColor: Color? = null,
162
161
  headerBackgroundColor: Color? = null,
163
162
  headerSpaceBetween: Dp? = null,
164
- /* End of header props */
165
163
 
166
164
  screenContent: @Composable () -> Unit,
167
165
  ) {
@@ -514,11 +512,13 @@ private class StandardPhoneLiteScreenGeometry : LiteScreenGeometry {
514
512
  insetRight: Int,
515
513
  ) = (width - insetLeft - insetRight).coerceAtLeast(0)
516
514
 
517
- override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int) =
518
- insetLeft + spacing
515
+ override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int): Int {
516
+ return insetLeft + spacing
517
+ }
519
518
 
520
- override fun MeasureScope.headerHeight(screenLayout: ScreenLayout, statusBar: Int, rowHeight: Int) =
521
- statusBar + rowHeight
519
+ override fun MeasureScope.headerHeight(screenLayout: ScreenLayout, statusBar: Int, rowHeight: Int): Int {
520
+ return statusBar + rowHeight
521
+ }
522
522
  override fun MeasureScope.collapsedHeaderHeight(
523
523
  screenLayout: ScreenLayout,
524
524
  statusBar: Int,
@@ -555,8 +555,9 @@ private class IPhoneDuoLiteScreenGeometry : LiteScreenGeometry {
555
555
  ).coerceAtLeast(0)
556
556
  }
557
557
 
558
- override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int) =
559
- insetLeft + (screenLayout.statusBarClearance?.left?.roundToPx() ?: 0) + spacing
558
+ override fun MeasureScope.searchStartX(screenLayout: ScreenLayout, insetLeft: Int, spacing: Int): Int {
559
+ return insetLeft + (screenLayout.statusBarClearance?.left?.roundToPx() ?: 0) + spacing
560
+ }
560
561
 
561
562
  override fun MeasureScope.headerHeight(screenLayout: ScreenLayout, statusBar: Int, rowHeight: Int): Int {
562
563
  val rowTop = screenLayout.headerStatusBarHeight +
@@ -644,19 +645,17 @@ private class LiteScreenLayoutPolicy(
644
645
  minHeight = 0,
645
646
  maxWidth = (safeLayoutWidth - spacing12 * 2).coerceAtLeast(0),
646
647
  )
647
- val backIconPlaceable =
648
- measurables.find { it.layoutId == HeaderId.BACK_ID }?.measure(realConstraints)
649
- val headerRightPlaceable =
650
- measurables.find { it.layoutId == HeaderId.HEADER_RIGHT_ID }?.measure(
651
- realConstraints.copy(
652
- maxWidth = realConstraints.maxWidth / 2,
653
- )
654
- )
648
+ val backIconPlaceable = measurables.find { it.layoutId == HeaderId.BACK_ID }?.measure(realConstraints)
649
+ val headerRightPlaceable = measurables.find { it.layoutId == HeaderId.HEADER_RIGHT_ID }?.measure(
650
+ realConstraints.copy(maxWidth = realConstraints.maxWidth / 2)
651
+ )
655
652
  val headerBackWidth = if (screenLayout.sideBar == null) backIconPlaceable.safeWidth else 0
656
653
  val baseInputSearchConstraints = if (isHeaderExtend) {
657
- val minWidth =
658
- if (useAnimationSearch) realConstraints.maxWidth - headerBackWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
659
- else realConstraints.maxWidth
654
+ val minWidth = if (useAnimationSearch) {
655
+ realConstraints.maxWidth - headerBackWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
656
+ } else {
657
+ realConstraints.maxWidth
658
+ }
660
659
  realConstraints.copy(
661
660
  maxWidth = (realConstraints.maxWidth * (1 - scrollPercent)).toInt()
662
661
  .coerceAtLeast(minWidth)
@@ -678,9 +677,7 @@ private class LiteScreenLayoutPolicy(
678
677
  )
679
678
  )
680
679
 
681
- /**
682
- * replicate logic from [vn.momo.kits.navigation.component.HeaderBackground]
683
- * */
680
+ // Same height rule as navigation.component.HeaderBackground.
684
681
  var defaultHeight = with(geometry) { headerHeight(screenLayout, statusBarPx, headerRowDefault) }
685
682
  if (isHeaderExtend) {
686
683
  defaultHeight = if (screenLayout.isIPhoneDuo) {
@@ -945,8 +942,7 @@ private fun LiteInputSearch(
945
942
  val interactionSource = remember { MutableInteractionSource() }
946
943
  val textState by remember { inputSearchProps.textFieldState }
947
944
 
948
- val isShowBtnText = inputSearchProps.isShowBtnText &&
949
- !inputSearchProps.btnText.isNullOrEmpty()
945
+ val isShowBtnText = inputSearchProps.isShowBtnText && !inputSearchProps.btnText.isNullOrEmpty()
950
946
  val inputFieldFontFamily = getFontFamily(theme.font, Typography.bodyDefaultRegular.fontWeight)
951
947
  val inputFieldStyle = remember(theme, inputFieldFontFamily) {
952
948
  Typography.bodyDefaultRegular.copy(
@@ -15,10 +15,8 @@ data class LocalizationObject(
15
15
  )
16
16
 
17
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].
18
+ * Port of RN `Application/Localize.ts`: kit defaults merged with host overrides. The language is
19
+ * snapshot state, so [changeLanguage] recomposes readers of [translate]/[translateData].
22
20
  */
23
21
  @Stable
24
22
  class Localize(translations: LocalizationObject = LocalizationObject()) {
@@ -38,10 +36,11 @@ class Localize(translations: LocalizationObject = LocalizationObject()) {
38
36
  return dictionary[key]?.takeIf { it.isNotEmpty() } ?: key
39
37
  }
40
38
 
41
- fun translateData(data: Map<String, String>): String =
42
- data[language] ?: data.entries.joinToString(prefix = "{", postfix = "}") {
39
+ fun translateData(data: Map<String, String>): String {
40
+ return data[language] ?: data.entries.joinToString(prefix = "{", postfix = "}") {
43
41
  "\"${it.key}\":\"${it.value}\""
44
42
  }
43
+ }
45
44
 
46
45
  fun translateData(vi: String, en: String): String = if (language == EN) en else vi
47
46
 
@@ -2,25 +2,19 @@ package vn.momo.kits.application
2
2
 
3
3
  import androidx.compose.runtime.Composable
4
4
  import androidx.compose.runtime.CompositionLocalProvider
5
- // AI-GENERATED START: own the typed language request
6
5
  import androidx.compose.runtime.DisposableEffect
7
- // AI-GENERATED END: own the typed language request
8
6
  import androidx.compose.runtime.remember
9
7
  import vn.momo.kits.const.AppTheme
10
8
  import vn.momo.kits.const.Theme
11
- import vn.momo.kits.navigation.LocalMaxApi
9
+ import vn.momo.kits.navigation.LocalKitsBinding
12
10
  import vn.momo.kits.platform.ProvideOsFontScale
13
- // AI-GENERATED START: consume typed NativeMaxApi results
14
- import vn.momo.maxapi.IMaxApi
15
- import vn.momo.maxapi.runtime.ApiResult
16
- // AI-GENERATED END: consume typed NativeMaxApi results
17
11
 
18
12
 
19
13
  @Composable
20
14
  fun WidgetContainer(
21
15
  theme: Theme? = null,
22
16
  miniAppContext: MiniAppContext? = null,
23
- maxApi: IMaxApi? = null,
17
+ binding: KitsBinding? = null,
24
18
  localize: Localize? = null,
25
19
  content: @Composable () -> Unit,
26
20
  ) {
@@ -30,17 +24,14 @@ fun WidgetContainer(
30
24
  }
31
25
  val resolvedTheme = theme ?: AppTheme.current
32
26
  val resolvedLocalize = localize ?: LocalLocalize.current
33
- val resolvedMaxApi = maxApi ?: LocalMaxApi.current
27
+ val resolvedBinding = binding ?: LocalKitsBinding.current ?: KitsHost.binding
34
28
 
35
- // AI-GENERATED START: cancel language delivery when its composition owner changes
36
- DisposableEffect(resolvedMaxApi, localize) {
37
- val api = resolvedMaxApi
29
+ DisposableEffect(resolvedBinding, localize) {
38
30
  val target = localize
39
31
  var active = true
40
32
  val handle = runCatching {
41
- api?.getLanguage { result ->
42
- if (active && target != null && result is ApiResult.Success &&
43
- result.value.trim().lowercase().startsWith(Localize.EN)) {
33
+ resolvedBinding.getLanguage { language ->
34
+ if (active && target != null && language.trim().lowercase().startsWith(Localize.EN)) {
44
35
  target.changeLanguage(Localize.EN)
45
36
  }
46
37
  }
@@ -50,14 +41,13 @@ fun WidgetContainer(
50
41
  handle?.cancel()
51
42
  }
52
43
  }
53
- // AI-GENERATED END: cancel language delivery when its composition owner changes
54
44
 
55
45
  ProvideOsFontScale {
56
46
  CompositionLocalProvider(
57
47
  AppTheme provides resolvedTheme,
58
48
  LocalContext provides mergedContext,
59
49
  LocalLocalize provides resolvedLocalize,
60
- LocalMaxApi provides resolvedMaxApi,
50
+ LocalKitsBinding provides resolvedBinding,
61
51
  ) {
62
52
  content()
63
53
  }
@@ -17,19 +17,20 @@ import vn.momo.kits.application.IsShowBaseLineDebug
17
17
  import vn.momo.kits.const.*
18
18
  import vn.momo.kits.modifier.conditional
19
19
 
20
+ // RN accepts only the `_03` palette as a custom badge color.
20
21
  private val badgePrimaryColors = listOf(
21
- Color(0xFFF0F0F0),
22
- Color(0xFFEB2F96),
23
- Color(0xFF962AF0),
24
- Color(0xFF4E4BFF),
25
- Color(0xFF007AFF),
26
- Color(0xFF13C2C2),
27
- Color(0xFF34C759),
28
- Color(0xFFA0D911),
29
- Color(0xFFFFCC00),
30
- Color(0xFFFA8C16),
31
- Color(0xFFFA541C),
32
- Color(0xFFF5222D)
22
+ Colors.black_03,
23
+ Colors.pink_03,
24
+ Colors.violet_03,
25
+ Colors.indigo_03,
26
+ Colors.blue_03,
27
+ Colors.mint_03,
28
+ Colors.green_03,
29
+ Colors.lime_03,
30
+ Colors.yellow_03,
31
+ Colors.gold_03,
32
+ Colors.orange_03,
33
+ Colors.red_03
33
34
  )
34
35
 
35
36
  private val badgeNumberRegex = "^\\d+$".toRegex()
@@ -46,12 +47,11 @@ fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Mod
46
47
  return label
47
48
  }
48
49
 
49
- var badgeColor =
50
- if (isNumber(label)) {
51
- AppTheme.current.colors.error.primary
52
- } else {
53
- AppTheme.current.colors.warning.primary
54
- }
50
+ var badgeColor = if (isNumber(label)) {
51
+ AppTheme.current.colors.error.primary
52
+ } else {
53
+ AppTheme.current.colors.warning.primary
54
+ }
55
55
 
56
56
  if (backgroundColor != null && badgePrimaryColors.contains(backgroundColor)) {
57
57
  badgeColor = backgroundColor
@@ -218,8 +218,8 @@ fun RoundedBadgeRibbon(
218
218
  val ribbonHeight = height - padding.toPx()
219
219
  val cornerRadius = roundedRect.toPx()
220
220
 
221
- val mainColor = Color(0xFFFA541C)
222
- val tailColor = Color(0xFFC41B24)
221
+ val mainColor = Colors.orange_03
222
+ val tailColor = Colors.red_01
223
223
 
224
224
  val headWidth = 4.dp.toPx()
225
225
  val leftSectionWidth = width * (9f / 28f)