Skip to content

Commit ad09e65

Browse files
committed
Audit CoreColor and update CoreSystem.default
1 parent d0e8ce9 commit ad09e65

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

Sources/OpenSwiftUICore/Graphic/Color/CoreColor.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
// CoreColor.swift
33
// OpenSwiftUICore
44
//
5+
// Audited for 6.4.41
56
// Status: Complete
67
// ID: 4330A474F53D66045762501ED6F8A749 (SwiftUICore)
78

89
#if canImport(Darwin)
910
package import Foundation
1011
import OpenSwiftUI_SPI
1112

12-
// MARK: - Color.Resolved + PlatformColor [6.4.41]
13+
// MARK: - Color.Resolved + PlatformColor
1314

1415
extension Color.Resolved {
1516
package init?(platformColor: AnyObject) {
1617
var red: CGFloat = 0
1718
var green: CGFloat = 0
1819
var blue: CGFloat = 0
1920
var alpha: CGFloat = 0
20-
let result = CoreColorPlatformColorGetComponents(system: .defaults, color: platformColor, red: &red, green: &green, blue: &blue, alpha: &alpha)
21+
let result = CoreColorPlatformColorGetComponents(system: .default, color: platformColor, red: &red, green: &green, blue: &blue, alpha: &alpha)
2122
if result {
2223
self.init(colorSpace: .sRGB, red: Float(red), green: Float(green), blue: Float(blue), opacity: Float(alpha))
2324
} else {
@@ -34,22 +35,22 @@ extension Color.Resolved {
3435
}
3536
}
3637

37-
// MARK: - CoreColor + PlatformColor [6.4.41]
38+
// MARK: - CoreColor + PlatformColor
3839

3940
extension CoreColor {
4041
package static func platformColor(resolvedColor: Color.Resolved) -> NSObject? {
4142
platformColor(red: CGFloat(resolvedColor.red), green: CGFloat(resolvedColor.green), blue: CGFloat(resolvedColor.blue), alpha: CGFloat(resolvedColor.opacity))
4243
}
4344

4445
package static func platformColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> NSObject? {
45-
CorePlatformColorForRGBA(system: .defaults, red: red, green: green, blue: blue, alpha: alpha) as? NSObject
46+
CorePlatformColorForRGBA(system: .default, red: red, green: green, blue: blue, alpha: alpha) as? NSObject
4647
}
4748
}
4849

4950
#if OPENSWIFTUI_LINK_COREUI
5051
package import CoreUI
5152

52-
// MARK: - CoreUINamedColorProvider [6.4.41]
53+
// MARK: - CoreUINamedColorProvider
5354

5455
package protocol CoreUINamedColorProvider {
5556
static func effectiveCGColor(cuiColor: CUINamedColor, in environment: EnvironmentValues) -> CGColor?

Sources/OpenSwiftUICore/Graphic/Color/SystemColors.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,19 @@ package enum SystemColorType: ColorProvider {
206206
package var kitColor: AnyObject? {
207207
#if canImport(Darwin)
208208
switch self {
209-
case .red: CoreColor.systemRedColor(with: .defaults)
210-
case .orange: CoreColor.systemOrangeColor(with: .defaults)
211-
case .yellow: CoreColor.systemYellowColor(with: .defaults)
212-
case .green: CoreColor.systemGreenColor(with: .defaults)
213-
case .teal: CoreColor.systemTealColor(with: .defaults)
214-
case .mint: CoreColor.systemMintColor(with: .defaults)
215-
case .cyan: CoreColor.systemCyanColor(with: .defaults)
216-
case .blue: CoreColor.systemBlueColor(with: .defaults)
217-
case .indigo: CoreColor.systemIndigoColor(with: .defaults)
218-
case .purple: CoreColor.systemPurpleColor(with: .defaults)
219-
case .pink: CoreColor.systemPinkColor(with: .defaults)
220-
case .brown: CoreColor.systemBrownColor(with: .defaults)
221-
case .gray: CoreColor.systemGrayColor(with: .defaults)
209+
case .red: CoreColor.systemRedColor(with: .default)
210+
case .orange: CoreColor.systemOrangeColor(with: .default)
211+
case .yellow: CoreColor.systemYellowColor(with: .default)
212+
case .green: CoreColor.systemGreenColor(with: .default)
213+
case .teal: CoreColor.systemTealColor(with: .default)
214+
case .mint: CoreColor.systemMintColor(with: .default)
215+
case .cyan: CoreColor.systemCyanColor(with: .default)
216+
case .blue: CoreColor.systemBlueColor(with: .default)
217+
case .indigo: CoreColor.systemIndigoColor(with: .default)
218+
case .purple: CoreColor.systemPurpleColor(with: .default)
219+
case .pink: CoreColor.systemPinkColor(with: .default)
220+
case .brown: CoreColor.systemBrownColor(with: .default)
221+
case .gray: CoreColor.systemGrayColor(with: .default)
222222
default: nil
223223
}
224224
#else

Sources/OpenSwiftUICore/Util/CoreSystemUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Audited for 6.5.4
66
// Status: Complete
77

8-
import OpenSwiftUI_SPI
8+
package import OpenSwiftUI_SPI
99

1010
// NOTE: use runtime check instead of #if targetEnvironment(macCatalyst)
1111
// Because Mac Catalyst will use macOS-varient build of OpenSwiftUICore.framework and Mac Catalyst/UIKitForMac varient of OpenSwiftUI.framework
@@ -40,7 +40,7 @@ package func isAppKitBased() -> Bool {
4040

4141
extension CoreSystem {
4242
@inline(__always)
43-
static var defaults: CoreSystem {
43+
package static var `default`: CoreSystem {
4444
#if canImport(Darwin)
4545
isAppKitBased() ? .appKit : .uiKit
4646
#else

Tests/OpenSwiftUICoreTests/Util/CoreSystemUtilsTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ struct CoreSystemUtilsTests {
1313
#expect(isCatalyst() == true)
1414
#expect(isUIKitBased() == true)
1515
#expect(isAppKitBased() == false)
16+
#expect(CoreSystem.default == .uiKit)
1617
#elseif os(macOS)
1718
#expect(isCatalyst() == false)
1819
#expect(isUIKitBased() == false)
1920
#expect(isAppKitBased() == true)
21+
#expect(CoreSystem.default == .appKit)
2022
#elseif os(iOS) || os(visionOS)
2123
#expect(isCatalyst() == false)
2224
#expect(isUIKitBased() == true)
2325
#expect(isAppKitBased() == false)
26+
#expect(CoreSystem.default == .uiKit)
2427
#else
2528
#expect(isCatalyst() == false)
2629
#expect(isUIKitBased() == false)
2730
#expect(isAppKitBased() == false)
31+
#expect(CoreSystem.default == .unknown)
2832
#endif
2933
}
3034
}

0 commit comments

Comments
 (0)