diff --git a/README.md b/README.md
index a66f27fe..0866cf38 100644
--- a/README.md
+++ b/README.md
@@ -428,6 +428,7 @@ Support levels:
init(red: Double, green: Double, blue: Double, opacity: Double = 1.0)
init(white: Double, opacity: Double = 1.0)
init(hue: Double, saturation: Double, brightness: Double, opacity: Double = 1.0)
+ init(_ color: UIColor)
static let accentColor: Color
static let primary: Color
static let secondary: Color
@@ -1745,6 +1746,21 @@ Support levels:
+
+
+ ✅ |
+ #colorLiteral() |
+
+ 🟠 |
+
+
+ UIColor
+
+ init(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)
+
+
+ |
+
🟠 |
diff --git a/Sources/SkipUI/SkipUI/Color/Color.swift b/Sources/SkipUI/SkipUI/Color/Color.swift
index e12d0e5d..6b593617 100644
--- a/Sources/SkipUI/SkipUI/Color/Color.swift
+++ b/Sources/SkipUI/SkipUI/Color/Color.swift
@@ -50,13 +50,6 @@ public struct Color: ShapeStyle, Hashable, Sendable {
}
#endif
- @available(*, unavailable)
- public init(_ color: Any) {
- #if SKIP
- colorImpl = { androidx.compose.ui.graphics.Color.White }
- #endif
- }
-
@available(*, unavailable)
public init(cgColor: Any /* CGColor */) {
#if SKIP
@@ -112,6 +105,10 @@ public struct Color: ShapeStyle, Hashable, Sendable {
#endif
}
+ public init(_ color: UIColor) {
+ self.init(red: color.red, green: color.green, blue: color.blue, opacity: color.alpha)
+ }
+
private static func clamp(_ value: Double) -> Float {
return max(Float(0.0), min(Float(1.0), Float(value)))
}
diff --git a/Sources/SkipUI/SkipUI/UIKit/UIColor.swift b/Sources/SkipUI/SkipUI/UIKit/UIColor.swift
new file mode 100644
index 00000000..18e884e2
--- /dev/null
+++ b/Sources/SkipUI/SkipUI/UIKit/UIColor.swift
@@ -0,0 +1,23 @@
+// Copyright 2023 Skip
+//
+// This is free software: you can redistribute and/or modify it
+// under the terms of the GNU Lesser General Public License 3.0
+// as published by the Free Software Foundation https://fsf.org
+
+#if !SKIP
+import struct CoreGraphics.CGFloat
+#endif
+
+public final class UIColor {
+ let red: CGFloat
+ let green: CGFloat
+ let blue: CGFloat
+ let alpha: CGFloat
+
+ public init(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
+ self.red = red
+ self.green = green
+ self.blue = blue
+ self.alpha = alpha
+ }
+}
|