@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.
- package/ios/Application/ApplicationEnvironment.swift +2 -3
- package/ios/Application/DesignSystemKits.swift +4 -20
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +0 -8
- package/ios/Application/Localize.swift +7 -31
- package/ios/Application/LocalizeModifier.swift +0 -8
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +0 -1
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +2 -5
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +2 -2
- package/ios/Carousel/Carousel.swift +5 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +1 -3
- package/ios/IconButton/IconButton.swift +0 -2
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +6 -19
- package/ios/Input/InputPhoneNumber.swift +0 -11
- package/ios/Input/InputSearch.swift +0 -6
- package/ios/Input/InputTextArea.swift +1 -12
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +7 -14
- package/ios/Layout/ScreenLayout.swift +2 -7
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +14 -35
- package/ios/Navigation/BottomTab/BottomTab.swift +10 -19
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -10
- package/ios/Navigation/BottomTab/CurvedContainer.swift +5 -11
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +6 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +2 -7
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +3 -9
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +4 -8
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +2 -7
- package/ios/Navigation/Component/HeaderLocation.swift +2 -7
- package/ios/Navigation/Component/HeaderRight.swift +2 -7
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +2 -9
- package/ios/Navigation/Component/SideBar.swift +3 -8
- package/ios/Navigation/Component/SnackBar.swift +5 -13
- package/ios/Navigation/HostBackGestureBridge.swift +3 -9
- package/ios/Navigation/ModalScreen.swift +2 -8
- package/ios/Navigation/Navigation.swift +2 -15
- package/ios/Navigation/NavigationContainer.swift +3 -12
- package/ios/Navigation/Navigator.swift +15 -27
- package/ios/Navigation/StackScreen.swift +8 -28
- package/ios/Navigation/StackTransition.swift +3 -11
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +3 -3
- package/ios/Popup/PopupInput.swift +1 -1
- package/ios/Popup/PopupLayout.swift +3 -3
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +2 -10
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +9 -11
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +12 -25
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Tooltip/Tooltip.swift +2 -7
- package/ios/Typography/FontScale.swift +3 -15
- package/ios/Typography/Text.swift +2 -7
- package/ios/Typography/Typography.swift +8 -10
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/package.json +1 -1
|
@@ -51,12 +51,11 @@ public struct KitConfig: Equatable {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
public class ApplicationEnvironment: ObservableObject {
|
|
54
|
-
//
|
|
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
|
|
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
|
-
///
|
|
31
|
-
///
|
|
32
|
-
///
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
-
///
|
|
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
|
-
//
|
|
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
|
-
///
|
|
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
|
-
|
|
366
|
-
///
|
|
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
|
-
//
|
|
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
|
|
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) {}
|
package/ios/Avatar/Avatar.swift
CHANGED
package/ios/Badge/Badge.swift
CHANGED
|
@@ -198,10 +198,8 @@ public struct BadgeRibbon: View {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
///
|
|
202
|
-
///
|
|
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")
|
package/ios/Button/Button.swift
CHANGED
|
@@ -264,11 +264,8 @@ private struct ButtonPressFeedbackStyle: ButtonStyle {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
///
|
|
268
|
-
/// the
|
|
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
|
|
56
|
-
///
|
|
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
|
-
///
|
|
4
|
-
///
|
|
5
|
-
///
|
|
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
|
-
//
|
|
97
|
-
//
|
|
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
|
}
|
|
@@ -7,12 +7,8 @@ private let datePickerWithLabelsHeight: CGFloat = 238
|
|
|
7
7
|
|
|
8
8
|
// MARK: - DateTimePicker
|
|
9
9
|
|
|
10
|
-
///
|
|
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
|
-
///
|
|
226
|
-
///
|
|
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
|
-
///
|
|
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
|
-
///
|
|
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
|
package/ios/Icon/Icon.swift
CHANGED
|
@@ -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
|
-
//
|
|
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
|
package/ios/Input/Input.swift
CHANGED
|
@@ -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
|
-
//
|
|
105
|
-
//
|
|
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
|
|
166
|
-
//
|
|
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
|
-
//
|
|
413
|
-
//
|
|
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 }
|