@momo-kits/native-kits 0.169.6 → 0.169.7

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 (91) hide show
  1. package/ios/Application/ApplicationEnvironment.swift +2 -3
  2. package/ios/Application/DesignSystemKits.swift +4 -20
  3. package/ios/Application/DesignSystemKitsPayload.swift +0 -8
  4. package/ios/Application/LanguageSource.swift +0 -8
  5. package/ios/Application/Localize.swift +7 -31
  6. package/ios/Application/LocalizeModifier.swift +0 -8
  7. package/ios/Application/MaxApi.swift +3 -11
  8. package/ios/Avatar/Avatar.swift +0 -1
  9. package/ios/Badge/Badge.swift +0 -1
  10. package/ios/Badge/BadgeRibbon.swift +2 -5
  11. package/ios/Button/Button.swift +2 -5
  12. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +2 -2
  13. package/ios/Carousel/Carousel.swift +5 -17
  14. package/ios/Checkbox/Checkbox.swift +0 -2
  15. package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
  16. package/ios/DateTimePicker/DateTimePicker.swift +4 -10
  17. package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
  18. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
  19. package/ios/DateTimePicker/WheelPicker.swift +2 -4
  20. package/ios/Extensions/SkeletonUICompat.swift +0 -8
  21. package/ios/Icon/Icon.swift +1 -3
  22. package/ios/IconButton/IconButton.swift +0 -2
  23. package/ios/Input/ErrorView.swift +0 -7
  24. package/ios/Input/Input.swift +6 -19
  25. package/ios/Input/InputPhoneNumber.swift +0 -11
  26. package/ios/Input/InputSearch.swift +0 -6
  27. package/ios/Input/InputTextArea.swift +1 -12
  28. package/ios/InputDropDown/InputDropDown.swift +1 -11
  29. package/ios/InputMoney/InputMoney.swift +9 -28
  30. package/ios/InputOTP/InputOTP.swift +2 -9
  31. package/ios/Layout/Item.swift +1 -2
  32. package/ios/Layout/ModalLayout.swift +7 -14
  33. package/ios/Layout/ScreenLayout.swift +2 -7
  34. package/ios/Loader/Loader.swift +3 -12
  35. package/ios/Lottie/LottieView.swift +0 -11
  36. package/ios/Navigation/BottomSheet.swift +14 -35
  37. package/ios/Navigation/BottomTab/BottomTab.swift +10 -19
  38. package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -10
  39. package/ios/Navigation/BottomTab/CurvedContainer.swift +5 -11
  40. package/ios/Navigation/BottomTab/DuoBarCompression.swift +6 -12
  41. package/ios/Navigation/BottomTab/DuoTabBar.swift +2 -7
  42. package/ios/Navigation/BottomTab/TabBarMetrics.swift +3 -9
  43. package/ios/Navigation/Component/FloatingButton.swift +4 -11
  44. package/ios/Navigation/Component/Header.swift +4 -8
  45. package/ios/Navigation/Component/HeaderBackground.swift +2 -8
  46. package/ios/Navigation/Component/HeaderJourney.swift +2 -7
  47. package/ios/Navigation/Component/HeaderLocation.swift +2 -7
  48. package/ios/Navigation/Component/HeaderRight.swift +2 -7
  49. package/ios/Navigation/Component/HeaderTitle.swift +1 -6
  50. package/ios/Navigation/Component/HeaderUser.swift +2 -9
  51. package/ios/Navigation/Component/SideBar.swift +3 -8
  52. package/ios/Navigation/Component/SnackBar.swift +5 -13
  53. package/ios/Navigation/HostBackGestureBridge.swift +3 -9
  54. package/ios/Navigation/ModalScreen.swift +2 -8
  55. package/ios/Navigation/Navigation.swift +2 -15
  56. package/ios/Navigation/NavigationContainer.swift +3 -12
  57. package/ios/Navigation/Navigator.swift +15 -27
  58. package/ios/Navigation/StackScreen.swift +8 -28
  59. package/ios/Navigation/StackTransition.swift +3 -11
  60. package/ios/Navigation/SwipeBackHaptic.swift +2 -7
  61. package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
  62. package/ios/Pagination/PaginationDot.swift +0 -9
  63. package/ios/Pagination/PaginationNumber.swift +1 -9
  64. package/ios/Pagination/PaginationScroll.swift +2 -14
  65. package/ios/Pagination/PaginationWhiteDot.swift +1 -10
  66. package/ios/Popup/PopupDisplay.swift +3 -3
  67. package/ios/Popup/PopupInput.swift +1 -1
  68. package/ios/Popup/PopupLayout.swift +3 -3
  69. package/ios/PopupView/FullscreenPopup.swift +3 -4
  70. package/ios/PopupView/PopupView.swift +2 -2
  71. package/ios/PopupView/Utils++.swift +1 -2
  72. package/ios/ProgressInfo/ProgressInfo.swift +2 -13
  73. package/ios/Skeleton/Skeleton.swift +2 -10
  74. package/ios/Slider/Slider.swift +5 -12
  75. package/ios/StatusBarTap/StatusBarTap.h +2 -3
  76. package/ios/StatusBarTap/StatusBarTap.m +3 -16
  77. package/ios/Stepper/Stepper.swift +8 -27
  78. package/ios/Steps/Steps.swift +9 -11
  79. package/ios/Swipeable/SwipeCell.swift +2 -2
  80. package/ios/Swipeable/SwipeCellModel.swift +3 -6
  81. package/ios/TabView/TabView.swift +12 -25
  82. package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
  83. package/ios/Tooltip/Tooltip.swift +2 -7
  84. package/ios/Typography/FontScale.swift +3 -15
  85. package/ios/Typography/Text.swift +2 -7
  86. package/ios/Typography/Typography.swift +8 -10
  87. package/ios/Uploader/Uploader.swift +2 -17
  88. package/ios/native-kits.podspec +1 -1
  89. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  90. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
  91. package/package.json +1 -1
@@ -51,12 +51,11 @@ public struct KitConfig: Equatable {
51
51
  }
52
52
 
53
53
  public class ApplicationEnvironment: ObservableObject {
54
- // AI-GENERATED START: expose the host bridge to modules outside MoMoUIKits (e.g. the demo pod)
54
+ // Public so modules outside MoMoUIKits (e.g. the demo pod) can reach the host bridge.
55
55
  public let applicationContext: MiniAppContext?
56
56
  public let composeApi: KitComposeApi?
57
57
  public let config: KitConfig?
58
58
  public let maxApi: MaxApi?
59
- // AI-GENERATED END: expose the host bridge to modules outside MoMoUIKits (e.g. the demo pod)
60
59
 
61
60
  public init(applicationContext: MiniAppContext? = nil, composeApi: KitComposeApi? = nil, config: KitConfig? = nil, maxApi: MaxApi? = nil) {
62
61
  self.applicationContext = applicationContext
@@ -67,7 +66,7 @@ public class ApplicationEnvironment: ObservableObject {
67
66
  }
68
67
 
69
68
  extension ApplicationEnvironment {
70
- /// Closes the mini app: through `composeApi` as before, else `maxApi` (Compose `maxApi.dismiss`).
69
+ /// Closes the mini app through `composeApi`, else `maxApi` (Compose `maxApi.dismiss`).
71
70
  func requestDismiss() {
72
71
  if let composeApi {
73
72
  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,19 +20,17 @@ 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
+ /// Mirrors Compose's `DesignSystemKits`; Swift reserves `init`, so there is no `init(source:)`: the host pushes
24
+ /// `setConfigs(_:)` at startup and on every change. Also tracks the OS Dynamic Type factor. Views re-render
25
+ /// only under `.momoFontScale()` (`NavigationContainer` applies it).
34
26
  public final class DesignSystemKits: ObservableObject {
35
27
  public static let shared = DesignSystemKits()
36
28
 
37
29
  @Published private var configs = DesignSystemKitsConfigs()
38
30
  @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)
31
+ /// Republished when the window scene resizes (iPhone Duo fold/unfold) so the font scale follows.
40
32
  @Published public private(set) var windowShortSide: CGFloat = DesignSystemKits.currentWindowShortSide()
41
33
  private var geometryObservations: [ObjectIdentifier: NSKeyValueObservation] = [:]
42
- // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
43
34
 
44
35
  private init() {
45
36
  NotificationCenter.default.addObserver(
@@ -48,7 +39,6 @@ public final class DesignSystemKits: ObservableObject {
48
39
  name: UIContentSizeCategory.didChangeNotification,
49
40
  object: nil
50
41
  )
51
- // AI-GENERATED START: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
52
42
  NotificationCenter.default.addObserver(
53
43
  self,
54
44
  selector: #selector(sceneDidActivate(_:)),
@@ -60,7 +50,6 @@ public final class DesignSystemKits: ObservableObject {
60
50
  .compactMap { $0 as? UIWindowScene }
61
51
  .forEach(self.observeGeometry(of:))
62
52
  }
63
- // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
64
53
  }
65
54
 
66
55
  public func setConfigs(_ configs: DesignSystemKitsConfigs) {
@@ -80,9 +69,7 @@ public final class DesignSystemKits: ObservableObject {
80
69
  userScaleRate: configs.userScaleRate,
81
70
  useOSScaleRate: configs.useOSScaleRate,
82
71
  osFontScale: osFontScale,
83
- // AI-GENERATED START: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
84
72
  windowShortSide: windowShortSide
85
- // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
86
73
  )
87
74
  }
88
75
 
@@ -92,7 +79,6 @@ public final class DesignSystemKits: ObservableObject {
92
79
  osFontScale = next
93
80
  }
94
81
 
95
- // AI-GENERATED START: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
96
82
  @objc private func sceneDidActivate(_ notification: Notification) {
97
83
  guard let scene = notification.object as? UIWindowScene else { return }
98
84
  observeGeometry(of: scene)
@@ -133,7 +119,6 @@ public final class DesignSystemKits: ObservableObject {
133
119
  }
134
120
  return min(size.width, size.height)
135
121
  }
136
- // AI-GENERATED END: republish the font scale when the window scene is resized (iPhone Duo fold/unfold)
137
122
 
138
123
  /// Same factor Compose's iOS `ProvideOsFontScale` derives from
139
124
  /// `UIFont.preferredFont(forTextStyle: .body).pointSize / 17`, so both iOS surfaces scale alike.
@@ -160,4 +145,3 @@ public extension EnvironmentValues {
160
145
  set { self[DesignSystemKitsConfigsKey.self] = newValue }
161
146
  }
162
147
  }
163
- // 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.
@@ -90,4 +83,3 @@ public final class UserDefaultsLanguageSource: NSObject, LanguageSource {
90
83
  onChange?(currentLanguage)
91
84
  }
92
85
  }
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 {
@@ -339,35 +324,26 @@ public final class Localize: ObservableObject {
339
324
  private struct LocalizeBox: Equatable {
340
325
  let localize: Localize
341
326
  let language: String
342
- // AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
327
+ // Invalidates consumers on dictionary changes too, not just language switches.
343
328
  let revision: Int
344
- // AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
345
329
 
346
330
  init(_ localize: Localize) {
347
331
  self.localize = localize
348
332
  self.language = localize.currentLanguage
349
- // AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
350
333
  self.revision = localize.revision
351
- // AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
352
334
  }
353
335
 
354
336
  static func == (lhs: LocalizeBox, rhs: LocalizeBox) -> Bool {
355
- // AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
356
337
  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
338
  }
359
339
  }
360
340
 
361
341
  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
342
+ /// Carries the full kit dictionary, so an un-injected consumer still renders instead of
364
343
  /// 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.
344
+ /// A `static let`, never rebuilt: without `.momoLocalize()` (or `NavigationContainer`) the
345
+ /// language is right on first render but does not live-update.
369
346
  static let defaultValue = LocalizeBox(Localize.shared)
370
- // AI-GENERATED END: default to the app-language-observing shared instance
371
347
  }
372
348
 
373
349
  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 {
@@ -27,4 +20,3 @@ private struct MomoLocalizeModifier: ViewModifier {
27
20
  .environment(\.localize, localize)
28
21
  }
29
22
  }
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,7 +41,6 @@ public struct Badge: View {
41
41
  }
42
42
 
43
43
  private var badgeColor: Color {
44
- // Default colors based on label type
45
44
  let defaultColor: Color = isNumber(label)
46
45
  ? theme.colors.error.primary
47
46
  : theme.colors.warning.primary
@@ -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")
@@ -264,11 +264,8 @@ private struct ButtonPressFeedbackStyle: ButtonStyle {
264
264
  }
265
265
  }
266
266
 
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).
267
+ /// The style label takes the full proposed width before iOS 17, stretching the background
268
+ /// past the content; `fixedSize` there only, as on 17+ it would stop long titles truncating.
272
269
  private struct HugContentOnLegacyOS: ViewModifier {
273
270
  let isFull: Bool
274
271
 
@@ -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] = []
@@ -1,17 +1,8 @@
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.
4
+ /// A custom drag-driven pager, not a ScrollView or `TabView(.page)`, which can't express the loop
5
+ /// virtualization or the inactive-slide opacity/scale effects.
15
6
  public struct Carousel<Content: View>: View {
16
7
  // MARK: Lifecycle
17
8
 
@@ -93,11 +84,8 @@ public struct Carousel<Content: View>: View {
93
84
  // Offset so the current page is centered within the viewport padding.
94
85
  let baseOffset = -CGFloat(currentPage) * step + contentPadding
95
86
 
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.
87
+ // Only a window around `currentPage` renders (`loop` means `itemCount * 1000` slides; Compose's
88
+ // pager is lazy); clear spacers of the skipped width keep the HStack size for `baseOffset`.
101
89
  let windowRadius = 3
102
90
  let windowStart = max(0, currentPage - windowRadius)
103
91
  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
  }
@@ -1,10 +1,3 @@
1
- //
2
- // Theme.swift
3
- // MoMoUIKits
4
- //
5
- // Created by sophia on 25/2/26.
6
- //
7
-
8
1
  import Foundation
9
2
  import SwiftUI
10
3
 
@@ -7,12 +7,8 @@ private let datePickerWithLabelsHeight: CGFloat = 238
7
7
 
8
8
  // MARK: - DateTimePicker
9
9
 
10
- /// A wheel-style date/time picker matching Compose `DateTimePicker`.
11
- ///
12
- /// The `format` string drives which columns are shown:
13
- /// - `DD` day, `MM` month, `YYYY` year, `HH` hour, `mm` minute.
14
- /// - `"HH:mm"` shows hour + minute; a lone `"HH"` switches the hour wheel to a
15
- /// 12-hour clock with an AM/PM column.
10
+ /// Wheel date/time picker matching Compose `DateTimePicker`. `format` picks the columns (`DD`, `MM`,
11
+ /// `YYYY`, `HH`, `mm`); a lone `"HH"` switches the hour wheel to a 12-hour clock with an AM/PM column.
16
12
  public struct DateTimePicker: View {
17
13
  @Environment(\.appTheme) private var theme
18
14
 
@@ -39,7 +35,6 @@ public struct DateTimePicker: View {
39
35
  let effectiveMin = minDate ?? DateTimePickerUtils.createRelativeDate(years: -10)
40
36
  let effectiveMax = maxDate ?? DateTimePickerUtils.createRelativeDate(years: 10)
41
37
 
42
- // needCheckRange is true only when the caller supplied no bounds.
43
38
  let needCheckRange = (minDate == nil && maxDate == nil)
44
39
 
45
40
  self._currentData = State(initialValue: Self.pickerData(
@@ -222,9 +217,8 @@ public struct DateTimePicker: View {
222
217
  emitIfValid()
223
218
  }
224
219
 
225
- /// Emit `onChange` only when the assembled date is valid and (when bounds were
226
- /// not supplied) within the effective min/max range. Mirrors the Compose
227
- /// `snapshotFlow.mapNotNull` filter.
220
+ /// Emits `onChange` only for a valid date, range-checked only when no bounds were supplied
221
+ /// (Compose's `snapshotFlow.mapNotNull` filter).
228
222
  private func emitIfValid() {
229
223
  guard let date = currentData.toDate() else { return }
230
224
  if !needCheckRange {
@@ -2,8 +2,7 @@ import Foundation
2
2
 
3
3
  // MARK: - PickerData
4
4
 
5
- /// Internal mutable representation of the picker's current selection.
6
- /// Mirrors Compose `PickerData`.
5
+ /// The picker's current selection (Compose `PickerData`).
7
6
  public struct DateTimePickerData: Equatable {
8
7
  public var day: Int
9
8
  public var month: Int
@@ -28,7 +27,6 @@ public struct DateTimePickerData: Equatable {
28
27
  self.timeMode = timeMode
29
28
  }
30
29
 
31
- /// Convert to a `DateComponents` based value. Returns `nil` if the date is invalid.
32
30
  public func toDate(calendar: Calendar = Calendar.current) -> Date? {
33
31
  var components = DateComponents()
34
32
  components.year = year
@@ -38,7 +38,6 @@ public enum DateTimePickerUtils {
38
38
  }
39
39
  }
40
40
 
41
- /// Number of days in a given month/year.
42
41
  private static func daysInMonth(year: Int, month: Int) -> Int {
43
42
  switch month {
44
43
  case 1, 3, 5, 7, 8, 10, 12: return 31
@@ -90,7 +89,6 @@ public enum DateTimePickerUtils {
90
89
  return (startMonth...endMonth).map { paddingNum($0) }
91
90
  }
92
91
 
93
- /// Get a list of year strings between min and max date.
94
92
  public static func getYears(minDate: DateComponents, maxDate: DateComponents) -> [String] {
95
93
  let startYear = minDate.year ?? 0
96
94
  let endYear = maxDate.year ?? 0
@@ -120,7 +118,6 @@ public enum DateTimePickerUtils {
120
118
  return minutes
121
119
  }
122
120
 
123
- /// Today's date.
124
121
  public static func getCurrentDateTime() -> Date {
125
122
  return Date()
126
123
  }
@@ -8,10 +8,8 @@ private let wheelPickerBorderWidth: CGFloat = 1
8
8
 
9
9
  // MARK: - WheelPicker
10
10
 
11
- /// A reusable single-column wheel picker, mirroring Compose `WheelPicker.kt`.
12
- ///
13
- /// Five rows tall with the selection in the middle row. A drag always settles on a row
14
- /// (Compose snaps once the scroll stops) and then reports it via `onChange(name, value)`.
11
+ /// Single-column wheel (Compose `WheelPicker.kt`), five rows tall with the selection in the middle.
12
+ /// A drag always settles on a row (Compose snaps once the scroll stops), then reports it via `onChange`.
15
13
  public struct WheelPicker: View {
16
14
  @Environment(\.appTheme) private var theme
17
15
 
@@ -1,11 +1,3 @@
1
- // File: ios/Extensions/SkeletonUICompat.swift
2
- // Created At: 2026-10-07 12:03:28 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-opus-5-5
6
-
7
- // AI-GENERATED START: keep SkeletonUI extensions visible to MoMoUIKits clients
8
1
  // Unused here on purpose: Swift 5 exposes extension members of every module a dependency imports, so clients
9
2
  // that only `import MoMoUIKits` rely on SkeletonUI's (e.g. `Text(String?)` in NativeWidget). Removing it breaks them.
10
3
  import SkeletonUI
11
- // AI-GENERATED END: keep SkeletonUI extensions visible to MoMoUIKits clients
@@ -21,7 +21,6 @@ let iconSources: [String: String] = {
21
21
  // unrepresentable sentinel: omitted -> theme text color, `nil` -> untinted.
22
22
  public let iconThemeColor = Color(.sRGB, red: -1, green: -1, blue: -1, opacity: -1)
23
23
 
24
- // Icon ViewModel
25
24
  public struct Icon: View {
26
25
  @Environment(\.appTheme) private var theme
27
26
 
@@ -55,8 +54,7 @@ public struct Icon: View {
55
54
  .scaledToFit()
56
55
  .foregroundColor(resolvedColor)
57
56
  .frame(width: size, height: size)
58
- // Mirrors Compose's auto-generated `contentDescription = "img|$iconUrl"`
59
- // when no explicit label is provided.
57
+ // Compose's auto-generated `contentDescription = "img|$iconUrl"` when no label is given.
60
58
  .accessibilityLabel(accessibilityLabel ?? "img|\(uri)")
61
59
  } else {
62
60
  // Compose keeps the sized box for an unknown key, so layouts don't collapse.
@@ -8,7 +8,6 @@ public enum IconSize {
8
8
  case medium
9
9
  case small
10
10
 
11
- /// Container width/height of the button.
12
11
  var containerSize: CGFloat {
13
12
  switch self {
14
13
  case .large: return 48
@@ -17,7 +16,6 @@ public enum IconSize {
17
16
  }
18
17
  }
19
18
 
20
- /// Glyph size of the icon inside the button.
21
19
  var iconSize: CGFloat {
22
20
  switch self {
23
21
  case .large: return 24
@@ -1,10 +1,3 @@
1
- //
2
- // ErrorView.swift
3
- // Pods
4
- //
5
- // Created by sophia on 13/1/26.
6
- //
7
-
8
1
  import SwiftUI
9
2
 
10
3
  public struct ErrorView: View {
@@ -101,10 +101,8 @@ public struct Input: View {
101
101
  let textBinding = Binding<String>(
102
102
  get: { self.text },
103
103
  set: { newValue in
104
- // Trim atomically before publishing, mirroring Kotlin's `onValueChange`
105
- // (`newText.take(maxLength)` before the state ever updates) — avoids a
106
- // render with the untrimmed value that a separate `.onChange` correction
107
- // would otherwise briefly show.
104
+ // Trimmed before publishing, like Compose's `newText.take(maxLength)`: an `.onChange`
105
+ // correction would briefly render the untrimmed value.
108
106
  let limited = limitText(newValue)
109
107
  self.text = limited
110
108
  self.onChangeText?(limited)
@@ -112,15 +110,12 @@ public struct Input: View {
112
110
  )
113
111
 
114
112
  VStack(alignment: .leading, spacing: 0) {
115
- // Input container
116
113
  HStack(alignment: .center, spacing: 0) {
117
- // Leading icon
118
114
  if !leadingIcon.isEmpty {
119
115
  Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconColor ?? theme.colors.text.hint)
120
116
  .padding(.trailing, Spacing.M)
121
117
  }
122
118
 
123
- // Text input field
124
119
  ZStack(alignment: .leading) {
125
120
  if text.isEmpty {
126
121
  MomoText(
@@ -162,16 +157,12 @@ public struct Input: View {
162
157
  .onAppear {
163
158
  if autofocus { isFieldFocused = true }
164
159
  }
165
- // SwiftUI reads a TextField's UIKit input traits only when it
166
- // builds the backing UITextField, so a later `keyboardType`
167
- // change is silently dropped. The secure path can call
168
- // `reloadInputViews()` in `updateUIView`; here the only lever
169
- // is to force a rebuild.
160
+ // SwiftUI reads UIKit input traits only when it builds the UITextField, so a later
161
+ // `keyboardType` change is dropped; force a rebuild.
170
162
  .id(keyboardType.rawValue)
171
163
  }
172
164
  }
173
165
 
174
- // Clear button (only show when focused and has text)
175
166
  if isFocused && !text.isEmpty {
176
167
  SwiftUI.Button(action: {
177
168
  text = ""
@@ -183,7 +174,6 @@ public struct Input: View {
183
174
  .accessibilityIdentifier("ic_clear")
184
175
  }
185
176
 
186
- // Loading indicator
187
177
  if loading {
188
178
  ActivityIndicator(isAnimating: .constant(true), style: .medium, color: getRightIconColor())
189
179
  .frame(width: 16, height: 16)
@@ -220,7 +210,6 @@ public struct Input: View {
220
210
  )
221
211
  .overlay(alignment: .topLeading) { floatingLabel }
222
212
 
223
- // Error or hint
224
213
  ErrorView(
225
214
  errorMessage: error,
226
215
  errorSpacing: errorSpacing,
@@ -409,10 +398,8 @@ private struct SecureInputField: UIViewRepresentable {
409
398
  self.parent = parent
410
399
  }
411
400
 
412
- // When a secure text field regains focus (or turns secure while editing),
413
- // iOS marks the existing text as "committed" and the next keystroke would
414
- // replace ALL of it. Re-inserting via insertText() puts it back into an
415
- // "active editing" state (and moves the caret to the end).
401
+ // A secure field regaining focus (or turning secure mid-edit) marks its text committed, so
402
+ // the next keystroke would replace all of it; re-inserting resumes editing, caret at the end.
416
403
  func reinsertText(in textField: UITextField) {
417
404
  let existingText = textField.text ?? ""
418
405
  guard !existingText.isEmpty else { return }