@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
@@ -0,0 +1,48 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.runtime.DisposableEffect
5
+ import androidx.compose.runtime.mutableStateOf
6
+ import androidx.compose.runtime.remember
7
+ import kotlinx.cinterop.ExperimentalForeignApi
8
+ import kotlinx.cinterop.ObjCAction
9
+ import platform.Foundation.NSNotification
10
+ import platform.Foundation.NSNotificationCenter
11
+ import platform.Foundation.NSSelectorFromString
12
+ import platform.UIKit.UIAccessibilityIsReduceMotionEnabled
13
+ import platform.UIKit.UIAccessibilityReduceMotionStatusDidChangeNotification
14
+ import platform.darwin.NSObject
15
+
16
+ @OptIn(ExperimentalForeignApi::class)
17
+ @Composable
18
+ actual fun rememberReduceMotion(): Boolean {
19
+ val reduceMotion = remember { mutableStateOf(UIAccessibilityIsReduceMotionEnabled()) }
20
+
21
+ val listener = remember {
22
+ object : NSObject() {
23
+ @Suppress("unused")
24
+ @ObjCAction
25
+ fun reduceMotionChanged(arg: NSNotification) {
26
+ reduceMotion.value = UIAccessibilityIsReduceMotionEnabled()
27
+ }
28
+ }
29
+ }
30
+
31
+ DisposableEffect(Unit) {
32
+ NSNotificationCenter.defaultCenter.addObserver(
33
+ observer = listener,
34
+ selector = NSSelectorFromString(listener::reduceMotionChanged.name + ":"),
35
+ name = UIAccessibilityReduceMotionStatusDidChangeNotification,
36
+ `object` = null,
37
+ )
38
+ onDispose {
39
+ NSNotificationCenter.defaultCenter.removeObserver(
40
+ observer = listener,
41
+ name = UIAccessibilityReduceMotionStatusDidChangeNotification,
42
+ `object` = null,
43
+ )
44
+ }
45
+ }
46
+
47
+ return reduceMotion.value
48
+ }
@@ -57,9 +57,8 @@ private fun regionKind(name: String): Any? {
57
57
  private val msgSendRegionsOfKindOptions = dlsym(RTLD_DEFAULT, "objc_msgSend")
58
58
  ?.reinterpret<CFunction<(COpaquePointer?, COpaquePointer?, COpaquePointer?, ULong) -> COpaquePointer?>>()
59
59
 
60
- // Apple's foldable check: only a device with a hinge reports a `.division` region, inactive while
61
- // flat (UIViewReservedRegionQueryOptionsIncludeInactive) but still there. Screen size cannot tell it
62
- // apart from a large iPhone in landscape or a narrowed window.
60
+ // Apple's foldable check: only a hinge reports `.division`, inactive while flat (hence IncludeInactive).
61
+ // Screen size can't tell a foldable from a large iPhone in landscape or a narrowed window.
63
62
  @OptIn(ExperimentalForeignApi::class)
64
63
  private fun UIView.hasDivisionRegion(): Boolean {
65
64
  if (window == null || !respondsToSelector(regionsOfKindOptions)) return false
@@ -75,10 +74,11 @@ private fun UIView.hasDivisionRegion(): Boolean {
75
74
  return (regions?.count ?: 0uL) > 0uL
76
75
  }
77
76
 
77
+ // Active regions only: a division region is active while the device is half folded.
78
78
  @OptIn(ExperimentalForeignApi::class)
79
- private fun UIView.occlusionRegions(target: UIView): List<ReservedRegion> {
79
+ private fun UIView.activeRegions(kindName: String, target: UIView): List<ReservedRegion> {
80
80
  if (window == null || !respondsToSelector(regionsOfKind)) return emptyList()
81
- val kind = regionKind("occlusionRegionKind") ?: return emptyList()
81
+ val kind = regionKind(kindName) ?: return emptyList()
82
82
  val regions = when (val result = performSelector(regionsOfKind, withObject = kind)) {
83
83
  is List<*> -> result
84
84
  is NSArray -> List(result.count.toInt()) { result.objectAtIndex(it.toULong()) }
@@ -109,7 +109,12 @@ private class ReservedRegionsProbe(
109
109
  super.layoutSubviews()
110
110
  // re-read until found: the window may not report the hinge on the first pass
111
111
  if (!isKnownFoldable) isKnownFoldable = hasDivisionRegion()
112
- val regions = ReservedRegions(superview?.let { occlusionRegions(it) } ?: emptyList(), isKnownFoldable)
112
+ val host = superview
113
+ val regions = ReservedRegions(
114
+ occlusion = host?.let { activeRegions("occlusionRegionKind", it) } ?: emptyList(),
115
+ isFoldable = isKnownFoldable,
116
+ division = host?.takeIf { isKnownFoldable }?.let { activeRegions("divisionRegionKind", it).firstOrNull() },
117
+ )
113
118
  if (regions != last) {
114
119
  last = regions
115
120
  onChange(regions)
@@ -4,7 +4,7 @@ android-minSdk = "24"
4
4
  android-targetSdk = "36"
5
5
  ktor-version = "3.0.0-rc-1"
6
6
  coroutines = "1.9.0"
7
- kotlin = "2.3.10"
7
+ kotlin = "2.4.20"
8
8
  kSerialize = "1.7.1"
9
9
  compose = "1.10.3"
10
10
  navigation-multiplatform = "2.9.2"
@@ -19,7 +19,6 @@ androidx-appcompat = "1.7.0"
19
19
  material = "1.10.0"
20
20
  vanniktechMavenPublish = "0.34.0"
21
21
  kits = "0.167.1-duo.1"
22
- nativemaxapi = "0.3.17"
23
22
  gif-image = "0.1.2"
24
23
 
25
24
  [libraries]
@@ -45,7 +44,6 @@ airbnb-lottie = { group = "com.airbnb.android", name = "lottie-compose", version
45
44
  # shared.framework). compottie-core pulls only `keight-core` (which declares
46
45
  # keight.js.JsAny, so the earlier unlinked-symbol error stays fixed too).
47
46
  compottie = { module = "io.github.alexzhirkevich:compottie-core", version.ref = "compottie" }
48
- native-max-api = { group = "vn.momo.maxapi", name = "NativeMaxApi", version.ref = "nativemaxapi" }
49
47
  kits = { module = "vn.momo.kits:kits", version.ref = "kits" }
50
48
  androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
51
49
  androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
package/gradle.properties CHANGED
@@ -21,6 +21,4 @@ artifact.id=kits
21
21
  version=0.300.7
22
22
 
23
23
  repo=GitLab
24
- url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
25
- gitlab.user=
26
- gitlab.password=
24
+ url=https://artifacts.mservice.com.vn/repository/maven-momo-app/
@@ -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 {
@@ -1,10 +1,3 @@
1
- // File: ios/Application/LocalizeModifier.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: inject a language-observing Localize into any SwiftUI subtree
8
1
  import SwiftUI
9
2
 
10
3
  public extension View {
@@ -15,9 +8,8 @@ public extension View {
15
8
  }
16
9
  }
17
10
 
18
- /// `@ObservedObject` is load-bearing: `@Environment(\.localize)` only invalidates when the boxed
19
- /// value changes, which requires *this* body to re-run on every publish. A plain helper that just
20
- /// set `\.localize` would inject a snapshot that never updates.
11
+ /// `@ObservedObject` is load-bearing: `@Environment(\.localize)` invalidates only when *this* body re-runs on a
12
+ /// publish; a helper that just set `\.localize` would inject a snapshot that never updates.
21
13
  private struct MomoLocalizeModifier: ViewModifier {
22
14
  @ObservedObject var localize: Localize
23
15
 
@@ -27,4 +19,3 @@ private struct MomoLocalizeModifier: ViewModifier {
27
19
  .environment(\.localize, localize)
28
20
  }
29
21
  }
30
- // AI-GENERATED END: inject a language-observing Localize into any SwiftUI subtree
@@ -1,13 +1,5 @@
1
- //
2
- // MaxApi.swift
3
- // MoMoUIKits
4
- //
5
- // Swift mirror of the host-app bridge exposed on Kotlin as `vn.momo.maxapi.IMaxApi`
6
- // (`LocalMaxApi`). `IMaxApi` itself is an external compiled dependency with no
7
- // source in this repo, so this protocol intentionally exposes only the methods
8
- // this kit's Kotlin source actually calls — not a full guess at IMaxApi's real surface.
9
- // Callbacks carry IMaxApi's `["response": …]` payload.
10
- //
1
+ // Swift mirror of the host bridge `vn.momo.maxapi.IMaxApi` (`LocalMaxApi`). IMaxApi is an external
2
+ // binary, so only the methods the kit calls are declared; callbacks carry its `["response": …]` payload.
11
3
 
12
4
  import UIKit
13
5
 
@@ -32,7 +24,7 @@ public extension MaxApi {
32
24
  UIImpactFeedbackGenerator(style: .light).impactOccurred()
33
25
  }
34
26
 
35
- // Hosts that don't bridge the toolkit keep it inert, as before these joined the protocol.
27
+ // Hosts that don't bridge the toolkit keep it inert.
36
28
  func isFavoriteApp(_ params: [String: Any?], callback: @escaping ([String: Any?]?) -> Void) {}
37
29
  func onToolAction(_ params: [String: Any?], callback: @escaping ([String: Any?]?) -> Void) {}
38
30
  func showTools(_ params: [String: Any?], callback: @escaping ([String: Any?]?) -> Void) {}
@@ -65,7 +65,6 @@ public struct Avatar: View {
65
65
 
66
66
  public var body: some View {
67
67
  ZStack {
68
- // Inner content clipped by shape with border
69
68
  ZStack {
70
69
  content
71
70
  }
@@ -41,17 +41,14 @@ public struct Badge: View {
41
41
  }
42
42
 
43
43
  private var badgeColor: Color {
44
- // Default colors based on label type
45
- let defaultColor: Color = isNumber(label)
46
- ? theme.colors.error.primary
47
- : theme.colors.warning.primary
48
-
49
- // Mirror Compose: only apply backgroundColor when it is one of the
50
- // allowed primaryColors; otherwise fall back to the label-based default.
44
+ // Mirrors Compose: backgroundColor applies only when it is one of primaryColors.
51
45
  if let bgColor = backgroundColor, primaryColors.contains(bgColor) {
52
46
  return bgColor
53
47
  }
54
- return defaultColor
48
+ if isNumber(label) {
49
+ return theme.colors.error.primary
50
+ }
51
+ return theme.colors.warning.primary
55
52
  }
56
53
 
57
54
  public var body: some View {
@@ -198,10 +198,8 @@ public struct BadgeRibbon: View {
198
198
  }
199
199
  }
200
200
 
201
- /// Ported from Compose's `RoundedBadgeRibbon` (BadgeRibbon.kt:164-326): a canvas-drawn
202
- /// ribbon shape sized to its text, mirrored per corner via scaleX/scaleY (never an actual
203
- /// rotation) — the label gets the same scale applied a second time so it stays right-reading
204
- /// while only the ribbon shape flips.
201
+ /// Compose's `RoundedBadgeRibbon`: a ribbon sized to its text, mirrored per corner with
202
+ /// scaleX/scaleY (never rotated); the label is scaled again so only the shape flips.
205
203
  public struct RoundedBadgeRibbon: View {
206
204
  @Environment(\.appTheme) private var theme
207
205
  @Environment(\.momoFontScale) private var fontScale
@@ -312,7 +310,6 @@ extension String {
312
310
  struct BadgeRibbon_Previews: PreviewProvider {
313
311
  static var previews: some View {
314
312
  VStack(spacing: 30) {
315
- // Basic ribbon examples
316
313
  BadgeRibbon(position: .topRight, label: "New")
317
314
  BadgeRibbon(position: .topLeft, label: "Hot", isRound: true)
318
315
  BadgeRibbon(position: .bottomLeft, label: "Sale")
@@ -229,9 +229,8 @@ public struct Button: View {
229
229
  }
230
230
  }
231
231
 
232
- /// Mirrors Compose's press feedback: the background shrinks via an animated
233
- /// horizontal inset and the whole button (background included) fades to 0.5,
234
- /// matching `animatedPadding`/`alpha` in Button.kt.
232
+ /// Compose's press feedback (`animatedPadding` / `alpha` in Button.kt): the background shrinks by an animated
233
+ /// horizontal inset and the whole button fades to 0.5.
235
234
  private struct ButtonPressFeedbackStyle: ButtonStyle {
236
235
  let isEnabled: Bool
237
236
  let background: Color
@@ -264,11 +263,8 @@ private struct ButtonPressFeedbackStyle: ButtonStyle {
264
263
  }
265
264
  }
266
265
 
267
- /// `ButtonStyleConfiguration.Label` is greedy on iOS 16 and earlier — it accepts
268
- /// the full proposed width, so the background drawn in `makeBody` stretches past
269
- /// the content even when `isFull == false`. iOS 17 fixed the label to hug its
270
- /// content, so only legacy OSes need the `fixedSize` clamp (kept off on 17+ to
271
- /// preserve tail truncation of long titles).
266
+ /// The style label takes the full proposed width before iOS 17, stretching the background
267
+ /// past the content; `fixedSize` there only, as on 17+ it would stop long titles truncating.
272
268
  private struct HugContentOnLegacyOS: ViewModifier {
273
269
  let isFull: Bool
274
270
 
@@ -52,8 +52,8 @@ public struct CalculatorKeyboard: View {
52
52
  }
53
53
  }
54
54
 
55
- /// Integer `+ - * /` with the usual precedence, as NSExpression did, but nil instead of a
56
- /// crash when a number or result leaves `Int` range.
55
+ /// Integer `+ - * /` with the usual precedence. Not NSExpression: it crashes when a number or
56
+ /// result leaves `Int` range, where this returns nil.
57
57
  static func evaluate(_ expression: String) -> Int? {
58
58
  var numbers: [Int] = []
59
59
  var operators: [Character] = []
@@ -92,11 +92,9 @@ public struct CalculatorKeyboard: View {
92
92
 
93
93
  var result = terms[0]
94
94
  for (sign, term) in zip(signs, terms.dropFirst()) {
95
- let (next, overflow) = sign == "+"
96
- ? result.addingReportingOverflow(term)
97
- : result.subtractingReportingOverflow(term)
98
- if overflow { return nil }
99
- result = next
95
+ let step = sign == "+" ? result.addingReportingOverflow(term) : result.subtractingReportingOverflow(term)
96
+ if step.overflow { return nil }
97
+ result = step.partialValue
100
98
  }
101
99
  return result
102
100
  }
@@ -1,17 +1,7 @@
1
1
  import SwiftUI
2
2
 
3
- /// Native SwiftUI port of the Compose `Carousel` component.
4
- ///
5
- /// Mirrors the Compose API: a paging horizontal carousel driven by an
6
- /// `itemCount` and a `content` builder that receives the real (modulo) index.
7
- /// Supports infinite `loop`, `autoplay` with a configurable interval,
8
- /// inactive-slide `opacity`/`scale` effects, optional `contentPadding`,
9
- /// snap behavior, and scroll enable/disable. Snap / scroll-index callbacks
10
- /// report the real item index.
11
- ///
12
- /// Uses a custom drag-driven pager (not a ScrollView) so behavior is identical
13
- /// across versions and supports the loop virtualization + transform effects
14
- /// that `TabView(.page)` cannot express.
3
+ /// Compose `Carousel`; `content` and the snap / scroll-index callbacks get the real (modulo) index. A drag-driven
4
+ /// pager, as ScrollView and `TabView(.page)` can't express the loop virtualization or inactive-slide effects.
15
5
  public struct Carousel<Content: View>: View {
16
6
  // MARK: Lifecycle
17
7
 
@@ -93,11 +83,8 @@ public struct Carousel<Content: View>: View {
93
83
  // Offset so the current page is centered within the viewport padding.
94
84
  let baseOffset = -CGFloat(currentPage) * step + contentPadding
95
85
 
96
- // Windows the rendered range around `currentPage` instead of instantiating all
97
- // `virtualPageCount` slides up front — with `loop=true`, that's `itemCount * 1000`
98
- // eager views, a real memory/perf regression versus Compose's lazy `HorizontalPager`.
99
- // Clear spacers of the skipped width keep the HStack's total layout size (and thus
100
- // the existing `baseOffset` math) unchanged.
86
+ // Only a window around `currentPage` renders (`loop` means `itemCount * 1000` slides; Compose's
87
+ // pager is lazy); clear spacers of the skipped width keep the HStack size for `baseOffset`.
101
88
  let windowRadius = 3
102
89
  let windowStart = max(0, currentPage - windowRadius)
103
90
  let windowEnd = min(virtualPageCount - 1, currentPage + windowRadius)
@@ -29,7 +29,6 @@ public struct Checkbox: View{
29
29
 
30
30
  public var body: some View {
31
31
  HStack(spacing: Spacing.S) {
32
- // Checkbox
33
32
  SwiftUI.Button(action: onCheck) {
34
33
  ZStack {
35
34
  RoundedRectangle(cornerRadius: Radius.XS)
@@ -50,7 +49,6 @@ public struct Checkbox: View{
50
49
  .buttonStyle(ActiveOpacityButtonStyle(activeOpacity: 0.8))
51
50
  .disabled(disabled)
52
51
 
53
- // Title
54
52
  if !title.isEmpty {
55
53
  MomoText(title, typography: .descriptionDefaultRegular)
56
54
  }