@momo-kits/native-kits 0.168.1-beta.4 → 0.168.1-beta.40-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 (185) hide show
  1. package/CLAUDE.md +15 -10
  2. package/README.md +2 -10
  3. package/build.gradle.kts +11 -0
  4. package/compose/build.gradle.kts +198 -0
  5. package/compose/build.gradle.kts.backup +198 -0
  6. package/compose/compose.podspec +47 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +20 -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 +62 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1071 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +195 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +363 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +17 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +287 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +316 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +393 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +113 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +739 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +239 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +389 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +94 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +203 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +92 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +22 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +219 -0
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +144 -0
  134. package/gradle/libs.versions.toml +69 -0
  135. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  136. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  137. package/gradle.properties +26 -0
  138. package/gradlew +252 -0
  139. package/gradlew.bat +94 -0
  140. package/ios/Application/ApplicationEnvironment.swift +7 -6
  141. package/ios/Application/DesignSystemKits.swift +163 -0
  142. package/ios/Application/DesignSystemKitsPayload.swift +68 -0
  143. package/ios/Badge/BadgeRibbon.swift +8 -1
  144. package/ios/Extensions/Color++.swift +2 -4
  145. package/ios/Input/Input.swift +16 -4
  146. package/ios/Input/InputPhoneNumber.swift +1 -3
  147. package/ios/Input/InputSearch.swift +1 -2
  148. package/ios/Input/InputTextArea.swift +8 -4
  149. package/ios/InputMoney/InputMoney.swift +6 -7
  150. package/ios/Layout/ModalLayout.swift +152 -0
  151. package/ios/Layout/ScreenLayout.swift +77 -18
  152. package/ios/Navigation/BottomSheet.swift +56 -53
  153. package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
  154. package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
  155. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  156. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  157. package/ios/Navigation/BottomTab/DuoTabBar.swift +64 -172
  158. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  159. package/ios/Navigation/Component/HeaderBackground.swift +22 -1
  160. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  161. package/ios/Navigation/Component/SnackBar.swift +4 -0
  162. package/ios/Navigation/ModalScreen.swift +20 -5
  163. package/ios/Navigation/StackScreen.swift +6 -8
  164. package/ios/Popup/PopupDisplay.swift +6 -4
  165. package/ios/Popup/PopupInput.swift +6 -4
  166. package/ios/Popup/PopupLayout.swift +17 -11
  167. package/ios/Popup/PopupNotify.swift +32 -25
  168. package/ios/Stepper/Stepper.swift +1 -2
  169. package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
  170. package/ios/Typography/FontScale.swift +29 -15
  171. package/ios/Typography/Text.swift +88 -14
  172. package/ios/Typography/Typography.swift +2 -2
  173. package/ios/native-kits.podspec +1 -1
  174. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  175. package/ios-demo/README.md +120 -0
  176. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  177. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  178. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  179. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
  180. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  181. package/package.json +1 -1
  182. package/publish.sh +2 -33
  183. package/settings.gradle.kts +64 -0
  184. package/ios/Typography/FontScaleStore.swift +0 -58
  185. package/ios/Typography/KitDesignSystem.swift +0 -17
@@ -0,0 +1,163 @@
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
+ import SwiftUI
9
+
10
+ /// Host-owned design-system inputs; mirrors Compose's `DesignSystemKitsConfigs` field for field.
11
+ public struct DesignSystemKitsConfigs: Equatable {
12
+ public var userScaleRate: CGFloat
13
+ public var useOSScaleRate: Bool
14
+ public var isWhiteList: Bool
15
+ public var designSystemConfig: KitConfig?
16
+
17
+ public init(
18
+ userScaleRate: CGFloat = 1,
19
+ useOSScaleRate: Bool = true,
20
+ isWhiteList: Bool = false,
21
+ designSystemConfig: KitConfig? = nil
22
+ ) {
23
+ self.userScaleRate = userScaleRate
24
+ self.useOSScaleRate = useOSScaleRate
25
+ self.isWhiteList = isWhiteList
26
+ self.designSystemConfig = designSystemConfig
27
+ }
28
+ }
29
+
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.
34
+ public final class DesignSystemKits: ObservableObject {
35
+ public static let shared = DesignSystemKits()
36
+
37
+ @Published private var configs = DesignSystemKitsConfigs()
38
+ @Published public private(set) var osFontScale: CGFloat = DesignSystemKits.currentOsFontScale()
39
+ // AI-GENERATED START: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
40
+ @Published public private(set) var windowShortSide: CGFloat = DesignSystemKits.currentWindowShortSide()
41
+ private var geometryObservations: [ObjectIdentifier: NSKeyValueObservation] = [:]
42
+ // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
43
+
44
+ private init() {
45
+ NotificationCenter.default.addObserver(
46
+ self,
47
+ selector: #selector(contentSizeCategoryDidChange),
48
+ name: UIContentSizeCategory.didChangeNotification,
49
+ object: nil
50
+ )
51
+ // AI-GENERATED START: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
52
+ NotificationCenter.default.addObserver(
53
+ self,
54
+ selector: #selector(sceneDidActivate(_:)),
55
+ name: UIScene.didActivateNotification,
56
+ object: nil
57
+ )
58
+ onMain {
59
+ UIApplication.shared.connectedScenes
60
+ .compactMap { $0 as? UIWindowScene }
61
+ .forEach(self.observeGeometry(of:))
62
+ }
63
+ // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
64
+ }
65
+
66
+ public func setConfigs(_ configs: DesignSystemKitsConfigs) {
67
+ onMain {
68
+ // Re-assigning an unchanged value would still publish and invalidate every kit subtree.
69
+ guard self.configs != configs else { return }
70
+ self.configs = configs
71
+ }
72
+ }
73
+
74
+ public func getConfigs() -> DesignSystemKitsConfigs {
75
+ configs
76
+ }
77
+
78
+ public var fontScale: FontScale {
79
+ FontScale(
80
+ userScaleRate: configs.userScaleRate,
81
+ useOSScaleRate: configs.useOSScaleRate,
82
+ osFontScale: osFontScale,
83
+ // AI-GENERATED START: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
84
+ windowShortSide: windowShortSide
85
+ // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
86
+ )
87
+ }
88
+
89
+ @objc private func contentSizeCategoryDidChange() {
90
+ let next = Self.currentOsFontScale()
91
+ guard next != osFontScale else { return }
92
+ osFontScale = next
93
+ }
94
+
95
+ // AI-GENERATED START: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
96
+ @objc private func sceneDidActivate(_ notification: Notification) {
97
+ guard let scene = notification.object as? UIWindowScene else { return }
98
+ observeGeometry(of: scene)
99
+ refreshWindowShortSide()
100
+ }
101
+
102
+ private func observeGeometry(of scene: UIWindowScene) {
103
+ guard #available(iOS 16.0, *) else { return }
104
+ let key = ObjectIdentifier(scene)
105
+ guard geometryObservations[key] == nil else { return }
106
+ geometryObservations[key] = scene.observe(\.effectiveGeometry, options: [.new]) { [weak self] _, _ in
107
+ // The window is resized after the scene geometry, so read it on the next turn.
108
+ DispatchQueue.main.async { self?.refreshWindowShortSide() }
109
+ }
110
+ }
111
+
112
+ private func refreshWindowShortSide() {
113
+ let next = Self.currentWindowShortSide()
114
+ guard next > 0, next != windowShortSide else { return }
115
+ windowShortSide = next
116
+ }
117
+
118
+ /// UIScreen.main stays on one display on iPhone Duo, so measure the foreground window instead.
119
+ static func currentWindowShortSide() -> CGFloat {
120
+ guard Thread.isMainThread else {
121
+ return min(UIScreen.main.bounds.width, UIScreen.main.bounds.height)
122
+ }
123
+ let scenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
124
+ let scene = scenes.first { $0.activationState == .foregroundActive } ?? scenes.first
125
+ let window = scene?.windows.first { $0.isKeyWindow } ?? scene?.windows.first
126
+ let size: CGSize
127
+ if let window, window.bounds.width > 0 {
128
+ size = window.bounds.size
129
+ } else if let scene {
130
+ size = scene.coordinateSpace.bounds.size
131
+ } else {
132
+ size = UIScreen.main.bounds.size
133
+ }
134
+ return min(size.width, size.height)
135
+ }
136
+ // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
137
+
138
+ /// Same factor Compose's iOS `ProvideOsFontScale` derives from
139
+ /// `UIFont.preferredFont(forTextStyle: .body).pointSize / 17`, so both iOS surfaces scale alike.
140
+ static func currentOsFontScale() -> CGFloat {
141
+ let base = UIFont.systemFont(ofSize: UIFont.labelFontSize)
142
+ return UIFontMetrics.default.scaledFont(for: base).pointSize / base.pointSize
143
+ }
144
+
145
+ /// Synchronous when already on main — an async hop would defer the change by a frame.
146
+ private func onMain(_ work: @escaping () -> Void) {
147
+ if Thread.isMainThread { work() } else { DispatchQueue.main.async(execute: work) }
148
+ }
149
+ }
150
+
151
+ private struct DesignSystemKitsConfigsKey: EnvironmentKey {
152
+ /// Computed, never stored: an un-injected subtree still reads the live holder, just not reactively.
153
+ static var defaultValue: DesignSystemKitsConfigs { DesignSystemKits.shared.getConfigs() }
154
+ }
155
+
156
+ public extension EnvironmentValues {
157
+ /// Injected by `.momoFontScale()`; never set it directly (same trap as `\.momoFontScale`).
158
+ var designSystemKitsConfigs: DesignSystemKitsConfigs {
159
+ get { self[DesignSystemKitsConfigsKey.self] }
160
+ set { self[DesignSystemKitsConfigsKey.self] = newValue }
161
+ }
162
+ }
163
+ // AI-GENERATED END: app-wide design-system holder mirroring Compose's DesignSystemKits
@@ -0,0 +1,68 @@
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
+ import Foundation
9
+
10
+ public extension DesignSystemKits {
11
+ /// Applies configs pushed as JSON by a host that can't share Swift types with the kit (e.g. the KMP bridge).
12
+ /// Invalid JSON is ignored and the current configs are kept.
13
+ func setConfigs(json: String) {
14
+ guard let data = json.data(using: .utf8),
15
+ let payload = try? JSONDecoder().decode(DesignSystemKitsPayload.self, from: data) else { return }
16
+ setConfigs(payload.configs)
17
+ }
18
+ }
19
+
20
+ // Wire format; field names match the host's serializer (momo-app HostDesignSystemKits / DesignSystemData.kt).
21
+ private struct DesignSystemKitsPayload: Decodable {
22
+ let userScaleRate: CGFloat
23
+ let useOSScaleRate: Bool
24
+ let isWhiteList: Bool
25
+ let designSystemConfig: KitConfigPayload?
26
+
27
+ var configs: DesignSystemKitsConfigs {
28
+ DesignSystemKitsConfigs(
29
+ userScaleRate: userScaleRate,
30
+ useOSScaleRate: useOSScaleRate,
31
+ isWhiteList: isWhiteList,
32
+ designSystemConfig: designSystemConfig?.kitConfig
33
+ )
34
+ }
35
+ }
36
+
37
+ private struct KitConfigPayload: Decodable {
38
+ let trustBanner: TrustBannerPayload?
39
+ let headerBar: String?
40
+ let headerGradient: String?
41
+
42
+ var kitConfig: KitConfig {
43
+ KitConfig(trustBanner: trustBanner?.trustBannerData, headerBar: headerBar, headerGradient: headerGradient)
44
+ }
45
+ }
46
+
47
+ private struct TrustBannerPayload: Decodable {
48
+ let content: [String: String]
49
+ let subContent: [String: String]
50
+ let pciImage: String?
51
+ let sslImage: String?
52
+ let urlConfig: String?
53
+ let icons: [String]?
54
+ let momoImage: String?
55
+
56
+ var trustBannerData: TrustBannerData {
57
+ TrustBannerData(
58
+ content: content,
59
+ subContent: subContent,
60
+ pciImage: pciImage,
61
+ momoImage: momoImage,
62
+ sslImage: sslImage,
63
+ icons: icons,
64
+ urlConfig: urlConfig ?? ""
65
+ )
66
+ }
67
+ }
68
+ // AI-GENERATED END: JSON entry point for hosts that can't share Swift types with the kit
@@ -203,7 +203,9 @@ public struct BadgeRibbon: View {
203
203
  /// rotation) — the label gets the same scale applied a second time so it stays right-reading
204
204
  /// while only the ribbon shape flips.
205
205
  public struct RoundedBadgeRibbon: View {
206
+ @Environment(\.appTheme) private var theme
206
207
  @Environment(\.momoFontScale) private var fontScale
208
+ @Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
207
209
  let text: String
208
210
  let position: RibbonPosition
209
211
 
@@ -223,7 +225,12 @@ public struct RoundedBadgeRibbon: View {
223
225
 
224
226
  private var measuredTextSize: CGSize {
225
227
  let fontSize = fontScale(TypographyStyle.labelXsMedium.fontSize)
226
- let font = UIFont.systemFont(ofSize: fontSize, weight: .medium)
228
+ let font = momoUIFont(
229
+ size: fontSize,
230
+ weight: .medium,
231
+ family: theme.font,
232
+ isWhiteList: designSystemKitsConfigs.isWhiteList
233
+ )
227
234
  return text.size(withAttributes: [.font: font])
228
235
  }
229
236
 
@@ -4,16 +4,14 @@ import Foundation
4
4
  private final class MoMoUIKitsBundleToken {}
5
5
 
6
6
  enum MoMoUIKitsResources {
7
+
7
8
  static let bundle: Bundle = {
8
9
  let bundleName = "MoMoUIKitsResources"
9
10
  let tokenBundle = Bundle(for: MoMoUIKitsBundleToken.self)
10
- let frameworkBundle = Bundle(identifier: "org.cocoapods.MoMoUIKits")
11
11
  let candidates = [
12
12
  Bundle.main.resourceURL,
13
13
  tokenBundle.resourceURL,
14
- tokenBundle.bundleURL,
15
- frameworkBundle?.resourceURL,
16
- frameworkBundle?.bundleURL
14
+ tokenBundle.bundleURL
17
15
  ]
18
16
 
19
17
  for candidate in candidates {
@@ -153,7 +153,7 @@ public struct Input: View {
153
153
  handleFocusChange(focused)
154
154
  })
155
155
  .keyboardType(keyboardType)
156
- .font(fontScale.font(size: 14, weight: fontWeight == .bold ? .bold : .regular))
156
+ .kitFont(fontWeight == .bold ? .actionSBold : .bodyDefaultRegular)
157
157
  .ignoreBoldTextSetting()
158
158
  .foregroundColor(getTextColor())
159
159
  .disabled(disabled || readOnly)
@@ -252,7 +252,9 @@ public struct Input: View {
252
252
  }
253
253
  .padding(.horizontal, Spacing.S)
254
254
  .background(theme.colors.background.surface)
255
- .alignmentGuide(.top) { $0[VerticalAlignment.center] }
255
+ // A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
256
+ .fixedSize(horizontal: false, vertical: true)
257
+ .frame(height: 0)
256
258
  .offset(x: Spacing.S)
257
259
  }
258
260
  }
@@ -345,7 +347,12 @@ private struct SecureInputField: UIViewRepresentable {
345
347
  textField.spellCheckingType = .no
346
348
  textField.delegate = context.coordinator
347
349
  textField.keyboardType = keyboardType
348
- textField.font = UIFont.systemFont(ofSize: fontSize, weight: fontWeight)
350
+ textField.font = momoUIFont(
351
+ size: fontSize,
352
+ weight: fontWeight,
353
+ family: context.environment.appTheme.font,
354
+ isWhiteList: context.environment.designSystemKitsConfigs.isWhiteList
355
+ )
349
356
  textField.textColor = textColor
350
357
  textField.isEnabled = !isDisabled
351
358
  textField.setContentHuggingPriority(.defaultLow, for: .horizontal)
@@ -370,7 +377,12 @@ private struct SecureInputField: UIViewRepresentable {
370
377
  if textField.text != text {
371
378
  textField.text = text
372
379
  }
373
- let font = UIFont.systemFont(ofSize: fontSize, weight: fontWeight)
380
+ let font = momoUIFont(
381
+ size: fontSize,
382
+ weight: fontWeight,
383
+ family: context.environment.appTheme.font,
384
+ isWhiteList: context.environment.designSystemKitsConfigs.isWhiteList
385
+ )
374
386
  if textField.font != font {
375
387
  textField.font = font
376
388
  }
@@ -104,9 +104,7 @@ public struct InputPhoneNumber: View {
104
104
  handleFocusChange(focused)
105
105
  })
106
106
  .keyboardType(.numberPad)
107
- .font(size == .small
108
- ? fontScale.font(size: 14, weight: .semibold)
109
- : fontScale.font(size: 18, weight: .bold))
107
+ .kitFont(size == .small ? .headerSSemibold : .headerMBold)
110
108
  .ignoreBoldTextSetting()
111
109
  .foregroundColor(theme.colors.text.default)
112
110
  .applyCursorColor(theme.colors.primary)
@@ -120,7 +120,6 @@ public struct InputSearchProps {
120
120
 
121
121
  public struct InputSearch: View {
122
122
  @Environment(\.appTheme) private var theme
123
- @Environment(\.momoFontScale) private var fontScale
124
123
  @Binding var text: String
125
124
  var buttonText: String = ""
126
125
  var showButtonText: Bool = false
@@ -263,7 +262,7 @@ public struct InputSearch: View {
263
262
  }, onCommit: onSubmit)
264
263
  .disabled(disabled)
265
264
  .foregroundColor(disabled ? theme.colors.text.disable : theme.colors.text.default)
266
- .font(.system(size: fontScale(14), weight: fontWeight))
265
+ .kitFont(size: 14, weight: fontWeight)
267
266
  .ignoreBoldTextSetting()
268
267
  .keyboardType(keyboardType)
269
268
  .applyCursorColor(theme.colors.primary)
@@ -41,9 +41,11 @@ struct UITextViewWrapper: UIViewRepresentable {
41
41
  uiView.tintColor = UIColor(cursorColor)
42
42
  // Read through `context.environment` rather than the global `scaleSize`: that is what makes
43
43
  // SwiftUI re-run updateUIView when the font scale changes.
44
- uiView.font = UIFont.systemFont(
45
- ofSize: context.environment.momoFontScale(16),
46
- weight: fontWeight == .bold ? .bold : .regular
44
+ uiView.font = momoUIFont(
45
+ size: context.environment.momoFontScale(16),
46
+ weight: fontWeight == .bold ? .bold : .regular,
47
+ family: context.environment.appTheme.font,
48
+ isWhiteList: context.environment.designSystemKitsConfigs.isWhiteList
47
49
  )
48
50
  uiView.isEditable = !disabled
49
51
  if uiView.keyboardType != keyboardType {
@@ -277,7 +279,9 @@ public struct InputTextArea: View {
277
279
  }
278
280
  .padding(.horizontal, Spacing.S)
279
281
  .background(theme.colors.background.surface)
280
- .alignmentGuide(.top) { $0[VerticalAlignment.center] }
282
+ // A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
283
+ .fixedSize(horizontal: false, vertical: true)
284
+ .frame(height: 0)
281
285
  .offset(x: Spacing.S)
282
286
  }
283
287
  }
@@ -356,14 +356,13 @@ private struct MoneyTextField: UIViewRepresentable {
356
356
  return numeric.isEmpty ? "" : formatNumberToMoney(numeric)
357
357
  }
358
358
 
359
- // Theme family as Compose `getFontFamily`: Momo Trust Sans only for whitelisted hosts, else system.
360
359
  private func font(_ context: Context) -> UIFont {
361
- let size = context.environment.momoFontScale(20)
362
- if KitDesignSystem.shared.isWhiteList, fontFamily == "MomoTrustSans",
363
- let font = UIFont(name: fontWeight == .bold ? "MomoTrustSans-Bold" : "MomoTrustSans-Regular", size: size) {
364
- return font
365
- }
366
- return .systemFont(ofSize: size, weight: fontWeight)
360
+ momoUIFont(
361
+ size: context.environment.momoFontScale(20),
362
+ weight: fontWeight,
363
+ family: fontFamily,
364
+ isWhiteList: context.environment.designSystemKitsConfigs.isWhiteList
365
+ )
367
366
  }
368
367
 
369
368
  final class Coordinator: NSObject, UITextFieldDelegate {
@@ -0,0 +1,152 @@
1
+ //
2
+ // ModalLayout.swift
3
+ // MoMoUIKits
4
+ //
5
+ // Foldable spec for Popup and BottomSheet (Figma "Modal - Foldable Guideline"). Mirrors Compose
6
+ // `layout/ModalLayout.kt` and RN; keep the three in sync.
7
+ //
8
+
9
+ import SwiftUI
10
+
11
+ /// Foldable modal spec values, in points. Public so host apps can size their own popups and sheets the same way.
12
+ public enum ModalMetrics {
13
+ public static let popupMaxWidth: CGFloat = 450
14
+ public static let popupMinWidth: CGFloat = 280
15
+ public static let popupMaxHeight: CGFloat = 600
16
+ public static let sheetMaxWidth: CGFloat = 653
17
+ public static let sheetMinWidth: CGFloat = 296
18
+ public static let sheetMinHeight: CGFloat = 230
19
+ public static let foldableMinWidth: CGFloat = 600
20
+ public static let iconButtonSize: CGFloat = 32
21
+ public static let iconSize: CGFloat = 20
22
+ public static let phoneScrimOpacity: CGFloat = 0.6
23
+ public static let foldableScrimOpacity: CGFloat = 0.2
24
+ }
25
+
26
+ public struct PopupGeometry: Equatable {
27
+ public let minWidth: CGFloat
28
+ public let maxWidth: CGFloat
29
+ /// nil: as tall as the content, phones keep their own caps
30
+ public let maxHeight: CGFloat?
31
+ public let margin: CGFloat
32
+ public let radius: CGFloat
33
+ }
34
+
35
+ public struct SheetGeometry: Equatable {
36
+ /// nil: spans the window
37
+ public let width: CGFloat?
38
+ /// nil: phones keep their own cap
39
+ public let maxHeight: CGFloat?
40
+ public let minHeight: CGFloat
41
+ public let margin: CGFloat
42
+ public let radius: CGFloat
43
+ }
44
+
45
+ /// Popup / bottom sheet geometry for a window; see `ModalLayout.resolve` and `ScreenLayout.modalLayout`.
46
+ public struct ModalLayout: Equatable {
47
+ public let isFoldable: Bool
48
+ /// Window coordinates of the area popups center in and sheets rest on the bottom of.
49
+ public let placement: CGRect
50
+ public let popup: PopupGeometry
51
+ public let sheet: SheetGeometry
52
+ public let scrimOpacity: CGFloat
53
+ }
54
+
55
+ public extension ScreenLayout {
56
+ /// Foldable = iPhone Duo or a window whose short side is at least 600 (RN parity), so phones
57
+ /// in landscape keep their look.
58
+ var modalLayout: ModalLayout {
59
+ ModalLayout.resolve(width: width, height: height, safeInsets: insets, isDuoDevice: isDuoDevice, hinge: hinge)
60
+ }
61
+ }
62
+
63
+ public extension ModalLayout {
64
+ /// Resolves popup / bottom sheet geometry from plain window metrics, for hosts without a kits screen
65
+ /// (`ScreenLayout.current.modalLayout` covers the key window).
66
+ ///
67
+ /// Points, window coordinates. `safeInsets` is the window safe area; on iPhone Duo it also carries the
68
+ /// control column. `hinge` is the vertical hinge of a half-folded iPhone Duo, nil while flat.
69
+ static func resolve(
70
+ width: CGFloat,
71
+ height: CGFloat,
72
+ safeInsets insets: EdgeInsets = EdgeInsets(),
73
+ isDuoDevice: Bool = false,
74
+ hinge: CGRect? = nil
75
+ ) -> ModalLayout {
76
+ let isFoldable = isDuoDevice || min(width, height) >= ModalMetrics.foldableMinWidth
77
+ guard isFoldable else {
78
+ let placement = CGRect(x: 0, y: 0, width: width, height: height)
79
+ return ModalLayout(
80
+ isFoldable: false,
81
+ placement: placement,
82
+ popup: popupGeometry(placementWidth: width, maxHeight: nil, margin: Spacing.XL, radius: Radius.L),
83
+ sheet: SheetGeometry(width: nil, maxHeight: nil, minHeight: 0, margin: 0, radius: Radius.M),
84
+ scrimOpacity: ModalMetrics.phoneScrimOpacity
85
+ )
86
+ }
87
+
88
+ // the safe area keeps overlays clear of the iPhone Duo control column; half folded they move to the right half
89
+ let hinge = hinge.flatMap { isDuoDevice && $0.minX > 0 && $0.maxX < width ? $0 : nil }
90
+ let left = max(insets.leading, hinge?.maxX ?? 0)
91
+ let placement = CGRect(
92
+ x: left,
93
+ y: insets.top,
94
+ width: max(width - insets.trailing - left, 0),
95
+ height: max(height - insets.top - insets.bottom, 0)
96
+ )
97
+ // outer display and half fold leave little room, so the margins tighten
98
+ let isCompact = isDuoDevice && (hinge != nil || min(width, height) < ModalMetrics.foldableMinWidth)
99
+ let sheetMargin = Spacing.M
100
+ let sheetMaxHeight = height - insets.top - sheetMargin
101
+ let sheetMinWidth = min(ModalMetrics.sheetMinWidth, placement.width)
102
+ return ModalLayout(
103
+ isFoldable: true,
104
+ placement: placement,
105
+ popup: popupGeometry(
106
+ placementWidth: placement.width,
107
+ maxHeight: min(ModalMetrics.popupMaxHeight, placement.height - Spacing.XL * 2),
108
+ margin: isCompact ? Spacing.M : Spacing.XL,
109
+ radius: Radius.XL
110
+ ),
111
+ sheet: SheetGeometry(
112
+ width: max(min(placement.width - sheetMargin * 2, ModalMetrics.sheetMaxWidth), sheetMinWidth),
113
+ maxHeight: sheetMaxHeight,
114
+ minHeight: min(ModalMetrics.sheetMinHeight, sheetMaxHeight),
115
+ margin: sheetMargin,
116
+ radius: Radius.XL
117
+ ),
118
+ scrimOpacity: ModalMetrics.foldableScrimOpacity
119
+ )
120
+ }
121
+
122
+ /// clamp(placement - 2 margin, 280, 450); the 280 floor gives way to a narrower placement.
123
+ private static func popupGeometry(placementWidth: CGFloat, maxHeight: CGFloat?, margin: CGFloat, radius: CGFloat) -> PopupGeometry {
124
+ let minWidth = min(ModalMetrics.popupMinWidth, placementWidth)
125
+ let maxWidth = min(max(placementWidth - margin * 2, minWidth), max(ModalMetrics.popupMaxWidth, minWidth))
126
+ return PopupGeometry(minWidth: minWidth, maxWidth: maxWidth, maxHeight: maxHeight, margin: margin, radius: radius)
127
+ }
128
+ }
129
+
130
+ /// Popup close and sheet header back / close: 32 circle on the surface with a border, 20 icon.
131
+ public struct ModalIconButton: View {
132
+ @Environment(\.appTheme) private var theme
133
+ let icon: String
134
+ let accessibilityId: String
135
+ let action: () -> Void
136
+
137
+ public init(icon: String, accessibilityId: String, action: @escaping () -> Void) {
138
+ self.icon = icon
139
+ self.accessibilityId = accessibilityId
140
+ self.action = action
141
+ }
142
+
143
+ public var body: some View {
144
+ Icon(source: icon, size: ModalMetrics.iconSize, color: theme.colors.text.default)
145
+ .frame(width: ModalMetrics.iconButtonSize, height: ModalMetrics.iconButtonSize)
146
+ .background(Circle().fill(theme.colors.background.surface))
147
+ .overlay(Circle().strokeBorder(theme.colors.border.default, lineWidth: 1))
148
+ .contentShape(Circle())
149
+ .onTapGesture(perform: action)
150
+ .accessibilityIdentifier(accessibilityId)
151
+ }
152
+ }