@momo-kits/native-kits 0.167.1-beta.16-debug → 0.167.1-beta.17-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 (38) hide show
  1. package/CLAUDE.md +4 -6
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/compose.podspec +1 -1
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +14 -0
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -5
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +2 -2
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +2 -2
  10. package/gradle.properties +1 -1
  11. package/ios/Application/ApplicationEnvironment.swift +6 -13
  12. package/ios/Template/TrustBanner/TrustBanner.swift +7 -39
  13. package/ios/Title/Title.swift +8 -3
  14. package/ios/Typography/FontScale.swift +11 -14
  15. package/ios/Typography/FontScaleStore.swift +58 -0
  16. package/ios/Typography/KitDesignSystem.swift +17 -0
  17. package/ios/Typography/Text.swift +36 -20
  18. package/ios/Typography/Typography.swift +2 -2
  19. package/ios/native-kits.podspec +1 -1
  20. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  21. package/package.json +1 -1
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  23. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Example.xcscheme +0 -32
  24. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  25. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  26. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/WorkspaceSettings.xcsettings +0 -16
  27. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
  28. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
  29. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
  30. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
  31. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
  32. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
  33. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
  34. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +0 -58
  35. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios.xcscheme +0 -58
  36. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +0 -60
  37. package/ios/Application/DesignSystemKits.swift +0 -100
  38. package/ios/Application/DesignSystemKitsPayload.swift +0 -68
@@ -1,100 +0,0 @@
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
-
40
- private init() {
41
- NotificationCenter.default.addObserver(
42
- self,
43
- selector: #selector(contentSizeCategoryDidChange),
44
- name: UIContentSizeCategory.didChangeNotification,
45
- object: nil
46
- )
47
- }
48
-
49
- public func setConfigs(_ configs: DesignSystemKitsConfigs) {
50
- onMain {
51
- // Re-assigning an unchanged value would still publish and invalidate every kit subtree.
52
- guard self.configs != configs else { return }
53
- self.configs = configs
54
- }
55
- }
56
-
57
- public func getConfigs() -> DesignSystemKitsConfigs {
58
- configs
59
- }
60
-
61
- public var fontScale: FontScale {
62
- FontScale(
63
- userScaleRate: configs.userScaleRate,
64
- useOSScaleRate: configs.useOSScaleRate,
65
- osFontScale: osFontScale
66
- )
67
- }
68
-
69
- @objc private func contentSizeCategoryDidChange() {
70
- let next = Self.currentOsFontScale()
71
- guard next != osFontScale else { return }
72
- osFontScale = next
73
- }
74
-
75
- /// Same factor Compose's iOS `ProvideOsFontScale` derives from
76
- /// `UIFont.preferredFont(forTextStyle: .body).pointSize / 17`, so both iOS surfaces scale alike.
77
- static func currentOsFontScale() -> CGFloat {
78
- let base = UIFont.systemFont(ofSize: UIFont.labelFontSize)
79
- return UIFontMetrics.default.scaledFont(for: base).pointSize / base.pointSize
80
- }
81
-
82
- /// Synchronous when already on main — an async hop would defer the change by a frame.
83
- private func onMain(_ work: @escaping () -> Void) {
84
- if Thread.isMainThread { work() } else { DispatchQueue.main.async(execute: work) }
85
- }
86
- }
87
-
88
- private struct DesignSystemKitsConfigsKey: EnvironmentKey {
89
- /// Computed, never stored: an un-injected subtree still reads the live holder, just not reactively.
90
- static var defaultValue: DesignSystemKitsConfigs { DesignSystemKits.shared.getConfigs() }
91
- }
92
-
93
- public extension EnvironmentValues {
94
- /// Injected by `.momoFontScale()`; never set it directly (same trap as `\.momoFontScale`).
95
- var designSystemKitsConfigs: DesignSystemKitsConfigs {
96
- get { self[DesignSystemKitsConfigsKey.self] }
97
- set { self[DesignSystemKitsConfigsKey.self] = newValue }
98
- }
99
- }
100
- // AI-GENERATED END: app-wide design-system holder mirroring Compose's DesignSystemKits
@@ -1,68 +0,0 @@
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
- sslImage: sslImage,
62
- urlConfig: urlConfig,
63
- icons: icons,
64
- momoImage: momoImage
65
- )
66
- }
67
- }
68
- // AI-GENERATED END: JSON entry point for hosts that can't share Swift types with the kit