Skip to content

Commit 8195cc6

Browse files
committed
Fix building for multi-platform
1 parent 1446671 commit 8195cc6

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

Sources/Colors/ColorExtractor.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ extension SystemColor {
2424
/// Extract dark mode color
2525
public var dark: SystemColor {
2626
#if canImport(UIKit)
27+
#if os(watchOS)
28+
// Since watchOS does not have dark/lightmode we just return the color.
29+
self
30+
#else
2731
resolvedColor(with: .init(userInterfaceStyle: .dark))
32+
#endif
2833
#else
2934
var value: SystemColor?
3035

@@ -45,7 +50,12 @@ extension SystemColor {
4550
/// Extract light mode color
4651
public var light: SystemColor {
4752
#if canImport(UIKit)
53+
#if os(watchOS)
54+
// Since watchOS does not have dark/lightmode we just return the color.
55+
self
56+
#else
4857
resolvedColor(with: .init(userInterfaceStyle: .light))
58+
#endif
4959
#else
5060
var value: SystemColor?
5161

@@ -82,33 +92,24 @@ extension SystemColor {
8292
)
8393
}
8494

85-
/// Get the CI Color of the current color
86-
var getCIcolor: CIColor {
87-
#if canImport(UIKit)
88-
return CIColor(color: self)
89-
#elseif canImport(AppKit)
90-
return CIColor(color: self)! // swiftlint:disable:this force_unwrapping
91-
#endif
92-
}
93-
9495
/// Get the red value component of the color
9596
public var redValue: CGFloat {
96-
return getCIcolor.red
97+
return self.cgColor.components?[0] ?? 0
9798
}
9899

99100
/// Get the green value component of the color
100101
public var greenValue: CGFloat {
101-
return getCIcolor.green
102+
return self.cgColor.components?[1] ?? 0
102103
}
103104

104105
/// Get the blue value component of the color
105106
public var blueValue: CGFloat {
106-
return getCIcolor.blue
107+
return self.cgColor.components?[2] ?? 0
107108
}
108109

109110
/// Get the alpha value component of the color
110111
public var alphaValue: CGFloat {
111-
return getCIcolor.alpha
112+
return self.cgColor.components?[3] ?? 0
112113
}
113114

114115
/// Create initializer for (BaseColors.swift)

Sources/Colors/Colors.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ extension Color {
327327
/// A color that represents the system-provided cyan color.
328328
public static var systemCyan: Color {
329329
#if os(iOS) || os(tvOS)
330-
if #available(iOS 15.0, *) {
330+
if #available(iOS 15.0, tvOS 15.0, *) {
331331
Color(UIColor.systemCyan)
332332
} else {
333333
BaseColor.systemCyan
@@ -346,7 +346,7 @@ extension Color {
346346
/// A color that represents the system-provided mint color.
347347
public static var systemMint: Color {
348348
#if os(iOS) || os(tvOS)
349-
if #available(iOS 15.0, *) {
349+
if #available(iOS 15.0, tvOS 15.0, *) {
350350
Color(UIColor.systemMint)
351351
} else {
352352
BaseColor.systemMint

0 commit comments

Comments
 (0)