@momo-kits/native-kits 0.300.7 → 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 (256) hide show
  1. package/CLAUDE.md +12 -8
  2. package/README.md +8 -7
  3. package/build.gradle.kts +13 -0
  4. package/compose/build.gradle.kts +195 -0
  5. package/compose/build.gradle.kts.backup +195 -0
  6. package/compose/compose.podspec +47 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +55 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +315 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +212 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +750 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +244 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +387 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +33 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +38 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +135 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
  131. package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
  132. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +39 -0
  133. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +53 -0
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +31 -0
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +143 -0
  142. package/gradle/libs.versions.toml +66 -0
  143. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  144. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  145. package/gradle.properties +24 -0
  146. package/gradlew +252 -0
  147. package/gradlew.bat +94 -0
  148. package/ios/Application/ApplicationEnvironment.swift +6 -4
  149. package/ios/Application/DesignSystemKits.swift +59 -13
  150. package/ios/Application/DesignSystemKitsPayload.swift +0 -8
  151. package/ios/Application/LanguageSource.swift +2 -11
  152. package/ios/Application/Localize.swift +8 -35
  153. package/ios/Application/LocalizeModifier.swift +2 -11
  154. package/ios/Application/MaxApi.swift +3 -11
  155. package/ios/Avatar/Avatar.swift +0 -1
  156. package/ios/Badge/Badge.swift +5 -8
  157. package/ios/Badge/BadgeRibbon.swift +2 -5
  158. package/ios/Button/Button.swift +4 -8
  159. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
  160. package/ios/Carousel/Carousel.swift +4 -17
  161. package/ios/Checkbox/Checkbox.swift +0 -2
  162. package/ios/Collapse/Collapse.swift +17 -11
  163. package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
  164. package/ios/DateTimePicker/DateTimePicker.swift +4 -10
  165. package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
  166. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
  167. package/ios/DateTimePicker/WheelPicker.swift +2 -4
  168. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  169. package/ios/Extensions/Color++.swift +2 -4
  170. package/ios/Extensions/SkeletonUICompat.swift +0 -8
  171. package/ios/Icon/Icon.swift +3 -6
  172. package/ios/IconButton/IconButton.swift +2 -5
  173. package/ios/Input/ErrorView.swift +0 -7
  174. package/ios/Input/Input.swift +9 -20
  175. package/ios/Input/InputPhoneNumber.swift +37 -20
  176. package/ios/Input/InputSearch.swift +23 -12
  177. package/ios/Input/InputTextArea.swift +4 -13
  178. package/ios/InputDropDown/InputDropDown.swift +1 -11
  179. package/ios/InputMoney/InputMoney.swift +9 -28
  180. package/ios/InputOTP/InputOTP.swift +2 -9
  181. package/ios/Layout/HeaderLayout.swift +72 -0
  182. package/ios/Layout/Item.swift +1 -2
  183. package/ios/Layout/ModalLayout.swift +144 -0
  184. package/ios/Layout/ScreenLayout.swift +48 -31
  185. package/ios/Layout/Section.swift +2 -3
  186. package/ios/Loader/Loader.swift +3 -12
  187. package/ios/Lottie/LottieView.swift +0 -11
  188. package/ios/Navigation/BottomSheet.swift +73 -94
  189. package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
  190. package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
  191. package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
  192. package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
  193. package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
  194. package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
  195. package/ios/Navigation/Component/FloatingButton.swift +4 -11
  196. package/ios/Navigation/Component/Header.swift +35 -54
  197. package/ios/Navigation/Component/HeaderBackground.swift +2 -8
  198. package/ios/Navigation/Component/HeaderJourney.swift +4 -8
  199. package/ios/Navigation/Component/HeaderLocation.swift +4 -8
  200. package/ios/Navigation/Component/HeaderRight.swift +20 -22
  201. package/ios/Navigation/Component/HeaderTitle.swift +1 -6
  202. package/ios/Navigation/Component/HeaderUser.swift +4 -10
  203. package/ios/Navigation/Component/SideBar.swift +6 -21
  204. package/ios/Navigation/Component/SnackBar.swift +9 -13
  205. package/ios/Navigation/HostBackGestureBridge.swift +2 -9
  206. package/ios/Navigation/ModalScreen.swift +24 -13
  207. package/ios/Navigation/Navigation.swift +35 -19
  208. package/ios/Navigation/NavigationContainer.swift +4 -15
  209. package/ios/Navigation/Navigator.swift +21 -39
  210. package/ios/Navigation/StackScreen.swift +64 -51
  211. package/ios/Navigation/StackTransition.swift +7 -14
  212. package/ios/Navigation/SwipeBackHaptic.swift +2 -7
  213. package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
  214. package/ios/Pagination/PaginationDot.swift +0 -9
  215. package/ios/Pagination/PaginationNumber.swift +1 -9
  216. package/ios/Pagination/PaginationScroll.swift +2 -14
  217. package/ios/Pagination/PaginationWhiteDot.swift +1 -10
  218. package/ios/Popup/PopupDisplay.swift +7 -5
  219. package/ios/Popup/PopupInput.swift +6 -4
  220. package/ios/Popup/PopupLayout.swift +17 -9
  221. package/ios/Popup/PopupNotify.swift +32 -25
  222. package/ios/PopupView/FullscreenPopup.swift +3 -4
  223. package/ios/PopupView/PopupView.swift +2 -2
  224. package/ios/PopupView/Utils++.swift +1 -2
  225. package/ios/ProgressInfo/ProgressInfo.swift +2 -13
  226. package/ios/Skeleton/Skeleton.swift +5 -16
  227. package/ios/Slider/Slider.swift +5 -12
  228. package/ios/StatusBarTap/StatusBarTap.h +2 -3
  229. package/ios/StatusBarTap/StatusBarTap.m +3 -16
  230. package/ios/Stepper/Stepper.swift +8 -27
  231. package/ios/Steps/Steps.swift +29 -26
  232. package/ios/Swipeable/SwipeCell.swift +2 -2
  233. package/ios/Swipeable/SwipeCellModel.swift +3 -6
  234. package/ios/TabView/TabView.swift +14 -28
  235. package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
  236. package/ios/Title/Title.swift +1 -3
  237. package/ios/Tooltip/Tooltip.swift +4 -9
  238. package/ios/Typography/FontScale.swift +79 -24
  239. package/ios/Typography/Text.swift +6 -12
  240. package/ios/Typography/Typography.swift +8 -11
  241. package/ios/Uploader/Uploader.swift +2 -17
  242. package/ios-demo/README.md +120 -0
  243. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  244. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  245. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
  246. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
  247. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
  248. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
  249. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
  250. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  251. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
  252. package/package.json +1 -1
  253. package/publish.sh +8 -2
  254. package/scripts/ci/build-swiftui.sh +22 -0
  255. package/scripts/ci/resolve-version.mjs +144 -0
  256. package/settings.gradle.kts +63 -0
package/gradlew ADDED
@@ -0,0 +1,252 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015-2021 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
20
+
21
+ ##############################################################################
22
+ #
23
+ # Gradle start up script for POSIX generated by Gradle.
24
+ #
25
+ # Important for running:
26
+ #
27
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28
+ # noncompliant, but you have some other compliant shell such as ksh or
29
+ # bash, then to run this script, type that shell name before the whole
30
+ # command line, like:
31
+ #
32
+ # ksh Gradle
33
+ #
34
+ # Busybox and similar reduced shells will NOT work, because this script
35
+ # requires all of these POSIX shell features:
36
+ # * functions;
37
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39
+ # * compound commands having a testable exit status, especially «case»;
40
+ # * various built-in commands including «command», «set», and «ulimit».
41
+ #
42
+ # Important for patching:
43
+ #
44
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
45
+ # by Bash, Ksh, etc; in particular arrays are avoided.
46
+ #
47
+ # The "traditional" practice of packing multiple parameters into a
48
+ # space-separated string is a well documented source of bugs and security
49
+ # problems, so this is (mostly) avoided, by progressively accumulating
50
+ # options in "$@", and eventually passing that to Java.
51
+ #
52
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54
+ # see the in-line comments for details.
55
+ #
56
+ # There are tweaks for specific operating systems such as AIX, CygWin,
57
+ # Darwin, MinGW, and NonStop.
58
+ #
59
+ # (3) This script is generated from the Groovy template
60
+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61
+ # within the Gradle project.
62
+ #
63
+ # You can find Gradle at https://github.com/gradle/gradle/.
64
+ #
65
+ ##############################################################################
66
+
67
+ # Attempt to set APP_HOME
68
+
69
+ # Resolve links: $0 may be a link
70
+ app_path=$0
71
+
72
+ # Need this for daisy-chained symlinks.
73
+ while
74
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75
+ [ -h "$app_path" ]
76
+ do
77
+ ls=$( ls -ld "$app_path" )
78
+ link=${ls#*' -> '}
79
+ case $link in #(
80
+ /*) app_path=$link ;; #(
81
+ *) app_path=$APP_HOME$link ;;
82
+ esac
83
+ done
84
+
85
+ # This is normally unused
86
+ # shellcheck disable=SC2034
87
+ APP_BASE_NAME=${0##*/}
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90
+ ' "$PWD" ) || exit
91
+
92
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
93
+ MAX_FD=maximum
94
+
95
+ warn () {
96
+ echo "$*"
97
+ } >&2
98
+
99
+ die () {
100
+ echo
101
+ echo "$*"
102
+ echo
103
+ exit 1
104
+ } >&2
105
+
106
+ # OS specific support (must be 'true' or 'false').
107
+ cygwin=false
108
+ msys=false
109
+ darwin=false
110
+ nonstop=false
111
+ case "$( uname )" in #(
112
+ CYGWIN* ) cygwin=true ;; #(
113
+ Darwin* ) darwin=true ;; #(
114
+ MSYS* | MINGW* ) msys=true ;; #(
115
+ NONSTOP* ) nonstop=true ;;
116
+ esac
117
+
118
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
119
+
120
+
121
+ # Determine the Java command to use to start the JVM.
122
+ if [ -n "$JAVA_HOME" ] ; then
123
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
124
+ # IBM's JDK on AIX uses strange locations for the executables
125
+ JAVACMD=$JAVA_HOME/jre/sh/java
126
+ else
127
+ JAVACMD=$JAVA_HOME/bin/java
128
+ fi
129
+ if [ ! -x "$JAVACMD" ] ; then
130
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
131
+
132
+ Please set the JAVA_HOME variable in your environment to match the
133
+ location of your Java installation."
134
+ fi
135
+ else
136
+ JAVACMD=java
137
+ if ! command -v java >/dev/null 2>&1
138
+ then
139
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
140
+
141
+ Please set the JAVA_HOME variable in your environment to match the
142
+ location of your Java installation."
143
+ fi
144
+ fi
145
+
146
+ # Increase the maximum file descriptors if we can.
147
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
148
+ case $MAX_FD in #(
149
+ max*)
150
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151
+ # shellcheck disable=SC2039,SC3045
152
+ MAX_FD=$( ulimit -H -n ) ||
153
+ warn "Could not query maximum file descriptor limit"
154
+ esac
155
+ case $MAX_FD in #(
156
+ '' | soft) :;; #(
157
+ *)
158
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159
+ # shellcheck disable=SC2039,SC3045
160
+ ulimit -n "$MAX_FD" ||
161
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
162
+ esac
163
+ fi
164
+
165
+ # Collect all arguments for the java command, stacking in reverse order:
166
+ # * args from the command line
167
+ # * the main class name
168
+ # * -classpath
169
+ # * -D...appname settings
170
+ # * --module-path (only if needed)
171
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
172
+
173
+ # For Cygwin or MSYS, switch paths to Windows format before running java
174
+ if "$cygwin" || "$msys" ; then
175
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
176
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
177
+
178
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
179
+
180
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
181
+ for arg do
182
+ if
183
+ case $arg in #(
184
+ -*) false ;; # don't mess with options #(
185
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
186
+ [ -e "$t" ] ;; #(
187
+ *) false ;;
188
+ esac
189
+ then
190
+ arg=$( cygpath --path --ignore --mixed "$arg" )
191
+ fi
192
+ # Roll the args list around exactly as many times as the number of
193
+ # args, so each arg winds up back in the position where it started, but
194
+ # possibly modified.
195
+ #
196
+ # NB: a `for` loop captures its iteration list before it begins, so
197
+ # changing the positional parameters here affects neither the number of
198
+ # iterations, nor the values presented in `arg`.
199
+ shift # remove old arg
200
+ set -- "$@" "$arg" # push replacement arg
201
+ done
202
+ fi
203
+
204
+
205
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207
+
208
+ # Collect all arguments for the java command:
209
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210
+ # and any embedded shellness will be escaped.
211
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212
+ # treated as '${Hostname}' itself on the command line.
213
+
214
+ set -- \
215
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
216
+ -classpath "$CLASSPATH" \
217
+ org.gradle.wrapper.GradleWrapperMain \
218
+ "$@"
219
+
220
+ # Stop when "xargs" is not available.
221
+ if ! command -v xargs >/dev/null 2>&1
222
+ then
223
+ die "xargs is not available"
224
+ fi
225
+
226
+ # Use "xargs" to parse quoted args.
227
+ #
228
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
229
+ #
230
+ # In Bash we could simply go:
231
+ #
232
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
233
+ # set -- "${ARGS[@]}" "$@"
234
+ #
235
+ # but POSIX shell has neither arrays nor command substitution, so instead we
236
+ # post-process each arg (as a line of input to sed) to backslash-escape any
237
+ # character that might be a shell metacharacter, then use eval to reverse
238
+ # that process (while maintaining the separation between arguments), and wrap
239
+ # the whole thing up as a single "set" statement.
240
+ #
241
+ # This will of course break if any of these variables contains a newline or
242
+ # an unmatched quote.
243
+ #
244
+
245
+ eval "set -- $(
246
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
247
+ xargs -n1 |
248
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
249
+ tr '\n' ' '
250
+ )" '"$@"'
251
+
252
+ exec "$JAVACMD" "$@"
package/gradlew.bat ADDED
@@ -0,0 +1,94 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+ @rem SPDX-License-Identifier: Apache-2.0
17
+ @rem
18
+
19
+ @if "%DEBUG%"=="" @echo off
20
+ @rem ##########################################################################
21
+ @rem
22
+ @rem Gradle startup script for Windows
23
+ @rem
24
+ @rem ##########################################################################
25
+
26
+ @rem Set local scope for the variables with windows NT shell
27
+ if "%OS%"=="Windows_NT" setlocal
28
+
29
+ set DIRNAME=%~dp0
30
+ if "%DIRNAME%"=="" set DIRNAME=.
31
+ @rem This is normally unused
32
+ set APP_BASE_NAME=%~n0
33
+ set APP_HOME=%DIRNAME%
34
+
35
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37
+
38
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40
+
41
+ @rem Find java.exe
42
+ if defined JAVA_HOME goto findJavaFromJavaHome
43
+
44
+ set JAVA_EXE=java.exe
45
+ %JAVA_EXE% -version >NUL 2>&1
46
+ if %ERRORLEVEL% equ 0 goto execute
47
+
48
+ echo. 1>&2
49
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
+ echo. 1>&2
51
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
+ echo location of your Java installation. 1>&2
53
+
54
+ goto fail
55
+
56
+ :findJavaFromJavaHome
57
+ set JAVA_HOME=%JAVA_HOME:"=%
58
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59
+
60
+ if exist "%JAVA_EXE%" goto execute
61
+
62
+ echo. 1>&2
63
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
+ echo. 1>&2
65
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
+ echo location of your Java installation. 1>&2
67
+
68
+ goto fail
69
+
70
+ :execute
71
+ @rem Setup the command line
72
+
73
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74
+
75
+
76
+ @rem Execute Gradle
77
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78
+
79
+ :end
80
+ @rem End local scope for the variables with windows NT shell
81
+ if %ERRORLEVEL% equ 0 goto mainEnd
82
+
83
+ :fail
84
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85
+ rem the _cmd.exe /c_ return code!
86
+ set EXIT_CODE=%ERRORLEVEL%
87
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
88
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89
+ exit /b %EXIT_CODE%
90
+
91
+ :mainEnd
92
+ if "%OS%"=="Windows_NT" endlocal
93
+
94
+ :omega
@@ -21,8 +21,10 @@ public class MiniAppContext {
21
21
  // MiniAppContext.userScaleRate / useOSScaleRate, which win per field over DesignSystemKits.
22
22
  public var userScaleRate: CGFloat? = nil
23
23
  public var useOSScaleRate: Bool? = nil
24
+ // Caps the font scale at size × rate, nil means no cap (Compose MiniAppContext.scaleSizeMaxRate).
25
+ public var scaleSizeMaxRate: CGFloat? = nil
24
26
 
25
- public init(appId: String, appCode: String, appName: Any? = nil, appIcon: String, description: Any? = nil, support: [String: Any] = [:], toolkitConfig: [String: Any] = [:], providerId: String = "momo", permissions: [[String: Any]] = [], userScaleRate: CGFloat? = nil, useOSScaleRate: Bool? = nil) {
27
+ public init(appId: String, appCode: String, appName: Any? = nil, appIcon: String, description: Any? = nil, support: [String: Any] = [:], toolkitConfig: [String: Any] = [:], providerId: String = "momo", permissions: [[String: Any]] = [], userScaleRate: CGFloat? = nil, useOSScaleRate: Bool? = nil, scaleSizeMaxRate: CGFloat? = nil) {
26
28
  self.appId = appId
27
29
  self.appCode = appCode
28
30
  self.appName = appName
@@ -34,6 +36,7 @@ public class MiniAppContext {
34
36
  self.permissions = permissions
35
37
  self.userScaleRate = userScaleRate
36
38
  self.useOSScaleRate = useOSScaleRate
39
+ self.scaleSizeMaxRate = scaleSizeMaxRate
37
40
  }
38
41
  }
39
42
 
@@ -51,12 +54,11 @@ public struct KitConfig: Equatable {
51
54
  }
52
55
 
53
56
  public class ApplicationEnvironment: ObservableObject {
54
- // AI-GENERATED START: expose the host bridge to modules outside MoMoUIKits (e.g. the demo pod)
57
+ // Public so modules outside MoMoUIKits (e.g. the demo pod) can reach the host bridge.
55
58
  public let applicationContext: MiniAppContext?
56
59
  public let composeApi: KitComposeApi?
57
60
  public let config: KitConfig?
58
61
  public let maxApi: MaxApi?
59
- // AI-GENERATED END: expose the host bridge to modules outside MoMoUIKits (e.g. the demo pod)
60
62
 
61
63
  public init(applicationContext: MiniAppContext? = nil, composeApi: KitComposeApi? = nil, config: KitConfig? = nil, maxApi: MaxApi? = nil) {
62
64
  self.applicationContext = applicationContext
@@ -67,7 +69,7 @@ public class ApplicationEnvironment: ObservableObject {
67
69
  }
68
70
 
69
71
  extension ApplicationEnvironment {
70
- /// Closes the mini app: through `composeApi` as before, else `maxApi` (Compose `maxApi.dismiss`).
72
+ /// Closes the mini app through `composeApi`, else `maxApi` (Compose `maxApi.dismiss`).
71
73
  func requestDismiss() {
72
74
  if let composeApi {
73
75
  composeApi.requestCallback(funcName: "dismiss", params: nil, onResponse: nil)
@@ -1,10 +1,3 @@
1
- // File: ios/Application/DesignSystemKits.swift
2
- // Created At: 2026-10-02 14:17:29 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-opus-5-5
6
-
7
- // AI-GENERATED START: app-wide design-system holder mirroring Compose's DesignSystemKits
8
1
  import SwiftUI
9
2
 
10
3
  /// Host-owned design-system inputs; mirrors Compose's `DesignSystemKitsConfigs` field for field.
@@ -27,15 +20,16 @@ public struct DesignSystemKitsConfigs: Equatable {
27
20
  }
28
21
  }
29
22
 
30
- /// App-wide holder for the SwiftUI kit, mirroring Compose's `DesignSystemKits`. The kit is sandboxed from the
31
- /// host, so the host pushes `setConfigs(_:)` at startup and on every change; the OS Dynamic Type factor is
32
- /// tracked here. Views re-render on change as long as the subtree got `.momoFontScale()` (`NavigationContainer`
33
- /// applies it). Swift reserves `init`, so there is no `init(source:)` twin: the host observes and pushes.
23
+ /// Compose's `DesignSystemKits` without `init(source:)` (Swift reserves `init`): the host pushes `setConfigs(_:)` at
24
+ /// startup and on every change. Also tracks Dynamic Type; views re-render only under `.momoFontScale()`.
34
25
  public final class DesignSystemKits: ObservableObject {
35
26
  public static let shared = DesignSystemKits()
36
27
 
37
28
  @Published private var configs = DesignSystemKitsConfigs()
38
29
  @Published public private(set) var osFontScale: CGFloat = DesignSystemKits.currentOsFontScale()
30
+ /// Republished when the window scene resizes (iPhone Duo fold/unfold) so the font scale follows.
31
+ @Published public private(set) var windowShortSide: CGFloat = DesignSystemKits.currentWindowShortSide()
32
+ private var geometryObservations: [ObjectIdentifier: NSKeyValueObservation] = [:]
39
33
 
40
34
  private init() {
41
35
  NotificationCenter.default.addObserver(
@@ -44,6 +38,17 @@ public final class DesignSystemKits: ObservableObject {
44
38
  name: UIContentSizeCategory.didChangeNotification,
45
39
  object: nil
46
40
  )
41
+ NotificationCenter.default.addObserver(
42
+ self,
43
+ selector: #selector(sceneDidActivate(_:)),
44
+ name: UIScene.didActivateNotification,
45
+ object: nil
46
+ )
47
+ onMain {
48
+ UIApplication.shared.connectedScenes
49
+ .compactMap { $0 as? UIWindowScene }
50
+ .forEach(self.observeGeometry(of:))
51
+ }
47
52
  }
48
53
 
49
54
  public func setConfigs(_ configs: DesignSystemKitsConfigs) {
@@ -62,7 +67,8 @@ public final class DesignSystemKits: ObservableObject {
62
67
  FontScale(
63
68
  userScaleRate: configs.userScaleRate,
64
69
  useOSScaleRate: configs.useOSScaleRate,
65
- osFontScale: osFontScale
70
+ osFontScale: osFontScale,
71
+ windowShortSide: windowShortSide
66
72
  )
67
73
  }
68
74
 
@@ -72,6 +78,47 @@ public final class DesignSystemKits: ObservableObject {
72
78
  osFontScale = next
73
79
  }
74
80
 
81
+ @objc private func sceneDidActivate(_ notification: Notification) {
82
+ guard let scene = notification.object as? UIWindowScene else { return }
83
+ observeGeometry(of: scene)
84
+ refreshWindowShortSide()
85
+ }
86
+
87
+ private func observeGeometry(of scene: UIWindowScene) {
88
+ guard #available(iOS 16.0, *) else { return }
89
+ let key = ObjectIdentifier(scene)
90
+ guard geometryObservations[key] == nil else { return }
91
+ geometryObservations[key] = scene.observe(\.effectiveGeometry, options: [.new]) { [weak self] _, _ in
92
+ // The window is resized after the scene geometry, so read it on the next turn.
93
+ DispatchQueue.main.async { self?.refreshWindowShortSide() }
94
+ }
95
+ }
96
+
97
+ private func refreshWindowShortSide() {
98
+ let next = Self.currentWindowShortSide()
99
+ guard next > 0, next != windowShortSide else { return }
100
+ windowShortSide = next
101
+ }
102
+
103
+ /// UIScreen.main stays on one display on iPhone Duo, so measure the foreground window instead.
104
+ static func currentWindowShortSide() -> CGFloat {
105
+ guard Thread.isMainThread else {
106
+ return min(UIScreen.main.bounds.width, UIScreen.main.bounds.height)
107
+ }
108
+ let scenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
109
+ let scene = scenes.first { $0.activationState == .foregroundActive } ?? scenes.first
110
+ let window = scene?.windows.first { $0.isKeyWindow } ?? scene?.windows.first
111
+ let size: CGSize
112
+ if let window, window.bounds.width > 0 {
113
+ size = window.bounds.size
114
+ } else if let scene {
115
+ size = scene.coordinateSpace.bounds.size
116
+ } else {
117
+ size = UIScreen.main.bounds.size
118
+ }
119
+ return min(size.width, size.height)
120
+ }
121
+
75
122
  /// Same factor Compose's iOS `ProvideOsFontScale` derives from
76
123
  /// `UIFont.preferredFont(forTextStyle: .body).pointSize / 17`, so both iOS surfaces scale alike.
77
124
  static func currentOsFontScale() -> CGFloat {
@@ -97,4 +144,3 @@ public extension EnvironmentValues {
97
144
  set { self[DesignSystemKitsConfigsKey.self] = newValue }
98
145
  }
99
146
  }
100
- // AI-GENERATED END: app-wide design-system holder mirroring Compose's DesignSystemKits
@@ -1,10 +1,3 @@
1
- // File: ios/Application/DesignSystemKitsPayload.swift
2
- // Created At: 2026-10-02 15:40:00 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-opus-5-5
6
-
7
- // AI-GENERATED START: JSON entry point for hosts that can't share Swift types with the kit
8
1
  import Foundation
9
2
 
10
3
  public extension DesignSystemKits {
@@ -65,4 +58,3 @@ private struct TrustBannerPayload: Decodable {
65
58
  )
66
59
  }
67
60
  }
68
- // AI-GENERATED END: JSON entry point for hosts that can't share Swift types with the kit
@@ -1,10 +1,3 @@
1
- // File: ios/Application/LanguageSource.swift
2
- // Created At: 2026-07-29 10:00:00 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-opus-5[1m]
6
-
7
- // AI-GENERATED START: observe the host app's active language so Localize can follow it
8
1
  import Foundation
9
2
 
10
3
  /// Read-only view of the host app's active language, plus change delivery.
@@ -16,9 +9,8 @@ public protocol LanguageSource: AnyObject {
16
9
  func stopObserving()
17
10
  }
18
11
 
19
- /// Reads the language the MoMo host app persists in `UserDefaults`. All three host writers
20
- /// (the `RNResource` RN bridge, `JSONLocalization`, and the KMP `LocalizationProvider`) write the
21
- /// same key on `UserDefaults.standard` in-process, so KVO on it sees every one of them.
12
+ /// All three host writers (RN bridge `RNResource`, `JSONLocalization`, KMP `LocalizationProvider`) write the same
13
+ /// `UserDefaults.standard` key in-process, so KVO on it sees every language change.
22
14
  public final class UserDefaultsLanguageSource: NSObject, LanguageSource {
23
15
  public static let defaultKey = "language"
24
16
 
@@ -90,4 +82,3 @@ public final class UserDefaultsLanguageSource: NSObject, LanguageSource {
90
82
  onChange?(currentLanguage)
91
83
  }
92
84
  }
93
- // AI-GENERATED END: observe the host app's active language so Localize can follow it
@@ -1,14 +1,5 @@
1
- //
2
- // Localize.swift
3
- // MoMoUIKits
4
- //
5
- // SwiftUI mirror of Compose's `application/Localize.kt`, itself a port of
6
- // momo-kits React Native's `Application/Localize.ts`. Holds the merged
7
- // dictionary (kit defaults + host overrides) and the active language,
8
- // switched at runtime via `changeLanguage`. `Localize` is an `ObservableObject`
9
- // so a language switch republishes to consumers of `translate`/`translateData`,
10
- // mirroring Compose's snapshot-state-backed `language`.
11
- //
1
+ // SwiftUI mirror of Compose's `application/Localize.kt` (port of RN `Application/Localize.ts`):
2
+ // kit defaults + host overrides and the active language, published like Compose's snapshot state.
12
3
 
13
4
  import Foundation
14
5
  import SwiftUI
@@ -28,16 +19,13 @@ public final class Localize: ObservableObject {
28
19
  public static let VI = "vi"
29
20
  public static let EN = "en"
30
21
 
31
- // AI-GENERATED START: follow the host app language and publish dictionary changes
32
22
  /// App-wide instance bound to the host language; the environment default uses it too,
33
23
  /// so every screen agrees on one language.
34
24
  public static let shared = Localize()
35
- // AI-GENERATED END: follow the host app language and publish dictionary changes
36
25
 
37
26
  private var assets: LocalizationObject
38
27
  @Published public private(set) var currentLanguage: String = Localize.VI
39
28
 
40
- // AI-GENERATED START: follow the host app language and publish dictionary changes
41
29
  /// Bumped by `addTranslations` — `assets` is not published, so without this the dictionary
42
30
  /// can change without any consumer re-rendering.
43
31
  @Published public private(set) var revision: Int = 0
@@ -47,7 +35,7 @@ public final class Localize: ObservableObject {
47
35
  /// `NavigationContainer` uses this to skip its legacy one-shot `MaxApi` pull.
48
36
  var observesAppLanguage: Bool { languageSource != nil }
49
37
 
50
- /// Pass `languageSource: nil` to opt out and keep the old "starts at vi" behavior.
38
+ /// `languageSource: nil` opts out: the language starts at `vi` and moves only on `changeLanguage`.
51
39
  public init(
52
40
  _ translations: LocalizationObject = LocalizationObject(),
53
41
  languageSource: LanguageSource? = UserDefaultsLanguageSource()
@@ -90,7 +78,6 @@ public final class Localize: ObservableObject {
90
78
  public func changeLanguage(_ language: String?) {
91
79
  apply(Localize.normalize(language))
92
80
  }
93
- // AI-GENERATED END: follow the host app language and publish dictionary changes
94
81
 
95
82
  public func translate(_ key: String) -> String {
96
83
  let dictionary = currentLanguage == Localize.EN ? assets.en : assets.vi
@@ -111,9 +98,7 @@ public final class Localize: ObservableObject {
111
98
  /// Existing keys win (mirrors Compose: `merge(translations, assets)`).
112
99
  public func addTranslations(_ translations: LocalizationObject) {
113
100
  assets = Localize.merge(base: translations, override: assets)
114
- // AI-GENERATED START: publish dictionary changes so consumers re-render
115
101
  onMain { self.revision &+= 1 }
116
- // AI-GENERATED END: publish dictionary changes so consumers re-render
117
102
  }
118
103
 
119
104
  private static func merge(base: LocalizationObject, override: LocalizationObject) -> LocalizationObject {
@@ -333,41 +318,29 @@ public final class Localize: ObservableObject {
333
318
  )
334
319
  }
335
320
 
336
- /// Snapshots `currentLanguage` alongside the instance so SwiftUI sees an environment
337
- /// *change* on `changeLanguage`: the `Localize` reference alone never changes, and
338
- /// `@Environment` does not subscribe to `@Published` the way `@EnvironmentObject` does.
321
+ /// Snapshots `currentLanguage` so `changeLanguage` is an environment *change*: the reference never changes, and
322
+ /// `@Environment` doesn't subscribe to `@Published` the way `@EnvironmentObject` does.
339
323
  private struct LocalizeBox: Equatable {
340
324
  let localize: Localize
341
325
  let language: String
342
- // AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
326
+ // Invalidates consumers on dictionary changes too, not just language switches.
343
327
  let revision: Int
344
- // AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
345
328
 
346
329
  init(_ localize: Localize) {
347
330
  self.localize = localize
348
331
  self.language = localize.currentLanguage
349
- // AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
350
332
  self.revision = localize.revision
351
- // AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
352
333
  }
353
334
 
354
335
  static func == (lhs: LocalizeBox, rhs: LocalizeBox) -> Bool {
355
- // AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
356
336
  lhs.localize === rhs.localize && lhs.language == rhs.language && lhs.revision == rhs.revision
357
- // AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
358
337
  }
359
338
  }
360
339
 
361
340
  private struct LocalizeKey: EnvironmentKey {
362
- /// A default-constructed `Localize` already carries the full kit dictionary, so a
363
- /// consumer that never injects one renders untranslated-but-correct text instead of
364
- /// trapping the way `@EnvironmentObject` does.
365
- // AI-GENERATED START: default to the app-language-observing shared instance
366
- /// `defaultValue` is a `static let`, so this box is never rebuilt: without a provider the
367
- /// language is right on first render but does not live-update. Wrap the root in
368
- /// `.momoLocalize()` (or use `NavigationContainer`) to get updates.
341
+ /// Never traps like `@EnvironmentObject`, but as a `static let` it is never rebuilt: without `.momoLocalize()`
342
+ /// (or `NavigationContainer`) the language is right on first render but does not live-update.
369
343
  static let defaultValue = LocalizeBox(Localize.shared)
370
- // AI-GENERATED END: default to the app-language-observing shared instance
371
344
  }
372
345
 
373
346
  public extension EnvironmentValues {