Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/Tuist/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
// Status: Blocked by ResolvedGradient
// ID: A45C110C8134A7DB30776EFC6CE1E8A6 (SwiftUICore)

#if canImport(Darwin)

public import CoreGraphics
public import OpenCoreGraphicsShims

// MARK: - CGColor + Color

Expand Down Expand Up @@ -103,5 +101,3 @@ extension Color.Resolved {
// get
// }
//}

#endif
16 changes: 2 additions & 14 deletions Sources/OpenSwiftUICore/Graphic/Color/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
// ID: 3A792CB70CFCF892676D7ADF8BCA260F (SwiftUICore)

import Foundation
#if canImport(Darwin)
public import CoreGraphics
#endif
public import OpenCoreGraphicsShims

// MARK: - Color

Expand Down Expand Up @@ -99,7 +97,6 @@ public struct Color: Hashable, CustomStringConvertible, Sendable {
provider.resolve(in: environment)
}

#if canImport(Darwin)
/// A Core Graphics representation of the color, if available.
///
/// You can get a
Expand All @@ -113,10 +110,9 @@ public struct Color: Hashable, CustomStringConvertible, Sendable {
/// color, this property is `nil`. To evaluate all types of colors, use the
/// `resolve(in:)` method.
@available(*, deprecated, renamed: "resolve(in:)")
public var cgColor: CoreGraphics.CGColor? {
public var cgColor: CGColor? {
provider.staticColor
}
#endif

/// Hashes the essential components of the color by feeding them into the
/// given hash function.
Expand Down Expand Up @@ -157,9 +153,7 @@ package protocol ColorProvider: Hashable {

func apply(color: Color, to shape: inout _ShapeStyle_Shape)

#if canImport(Darwin)
var staticColor: CGColor? { get }
#endif

var kitColor: AnyObject? { get }

Expand All @@ -169,9 +163,7 @@ package protocol ColorProvider: Hashable {
}

extension ColorProvider {
#if canImport(Darwin)
package var staticColor: CGColor? { nil }
#endif

package var kitColor: AnyObject? { nil }

Expand Down Expand Up @@ -217,9 +209,7 @@ package class AnyColorBox: AnyShapeStyleBox, @unchecked Sendable {

package func resolve(in environment: EnvironmentValues) -> Color.Resolved { _openSwiftUIBaseClassAbstractMethod() }
package func apply(color: Color, to shape: inout _ShapeStyle_Shape) { _openSwiftUIBaseClassAbstractMethod() }
#if canImport(Darwin)
package var staticColor: CGColor? { _openSwiftUIBaseClassAbstractMethod() }
#endif
package var kitColor: AnyObject? { _openSwiftUIBaseClassAbstractMethod() }
package func hash(into hasher: inout Hasher) { _openSwiftUIBaseClassAbstractMethod() }
package var description: String { _openSwiftUIBaseClassAbstractMethod() }
Expand Down Expand Up @@ -256,11 +246,9 @@ private final class ColorBox<P>: AnyColorBox, @unchecked Sendable where P: Color
base.apply(color: color, to: &shape)
}

#if canImport(Darwin)
override var staticColor: CGColor? {
base.staticColor
}
#endif

override var kitColor: AnyObject? {
base.kitColor
Expand Down
7 changes: 1 addition & 6 deletions Sources/OpenSwiftUICore/Graphic/Color/ConstantColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// ID: 7C95FE02C0C9104041ABD4890B043CBE (SwiftUICore)

import Foundation
import OpenCoreGraphicsShims
import OpenSwiftUI_SPI

// MARK: - Color.Resolved
Expand Down Expand Up @@ -93,11 +94,9 @@ private struct ResolvedColorProvider: ColorProvider {
color
}

#if canImport(Darwin)
var staticColor: CGColor? {
color.cgColor
}
#endif

var colorDescription: String {
let linearRed = color.linearRed
Expand Down Expand Up @@ -281,9 +280,7 @@ extension Color.Resolved {

extension Color {
struct DisplayP3: ColorProvider {
#if canImport(Darwin)
private static let p3ColorSpace = CGColorSpace(name: CGColorSpace.displayP3)!
#endif

let red: CGFloat
let green: CGFloat
Expand All @@ -294,12 +291,10 @@ extension Color {
Color.Resolved(displayP3Red: Float(red), green: Float(green), blue: Float(blue), opacity: opacity)
}

#if canImport(Darwin)
var staticColor: CGColor? {
var components: [CGFloat] = [red, green, blue, CGFloat(opacity)]
return CGColor(colorSpace: Self.p3ColorSpace, components: &components)
}
#endif
}
}

Expand Down
8 changes: 1 addition & 7 deletions Sources/OpenSwiftUICore/Graphic/Color/ModifiedColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
// ID: B495DF025D9B78431A787E266E7D8FB1 (SwiftUI)
// ID: F28C5F7FF836E967BAC87540A3CB4F65 (SwiftUICore)

#if canImport(Darwin)
import CoreGraphics
import Foundation
#endif
import OpenCoreGraphicsShims
import OpenSwiftUI_SPI

@available(OpenSwiftUI_v1_0, *)
Expand All @@ -25,14 +23,12 @@ extension Color {
base.provider.resolve(in: environment).multiplyingOpacity(by: Float(opacity))
}

#if canImport(Darwin)
var staticColor: CGColor? {
guard let baseStaticColor = base.provider.staticColor else {
return nil
}
return baseStaticColor.copy(alpha: opacity * baseStaticColor.alpha)!
}
#endif

var description: String {
"\(Int(opacity * 100 + 0.5))% \(base)"
Expand Down Expand Up @@ -157,14 +153,12 @@ extension Color {
return resolved
}

#if canImport(Darwin)
var staticColor: CGColor? {
guard let baseStaticColor = base.provider.staticColor else {
return nil
}
return baseStaticColor.copy(alpha: CGFloat(opacity))!
}
#endif
}

public func _settingOpacity(_ opacity: Double) -> Color {
Expand Down
3 changes: 0 additions & 3 deletions Sources/OpenSwiftUICore/Graphic/Color/RGBColorSpace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// Status: Complete

import Foundation
#if canImport(Darwin)
import CoreGraphics
#endif

extension Color {
/// A profile that specifies how to interpret a color value for display.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ extension DisplayList.ViewUpdater {
static let keyPath = "backgroundColor"

static func boxValue(_ value: Color.Resolved) -> NSObject {
#if canImport(Darwin)
unsafeDowncast(value.cgColor, to: NSObject.self)
#else
_openSwiftUIPlatformUnimplementedFailure()
#endif
}
}

Expand Down Expand Up @@ -190,14 +186,10 @@ extension DisplayList.ViewUpdater {
static let keyPath = "contentsMultiplyColor"

static func boxValue(_ value: Color.Resolved?) -> NSObject {
#if canImport(Darwin)
guard let value else {
return NSNull()
}
return unsafeDowncast(value.cgColor, to: NSObject.self)
#else
_openSwiftUIPlatformUnimplementedFailure()
#endif
}
}

Expand Down
4 changes: 0 additions & 4 deletions Sources/OpenSwiftUICore/Shape/ShapeLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,7 @@ extension DisplayList.ViewUpdater {
static let keyPath = "shadowColor"

static func boxValue(_ value: Color.Resolved) -> NSObject {
#if canImport(Darwin)
unsafeDowncast(value.cgColor, to: NSObject.self)
#else
_openSwiftUIPlatformUnimplementedFailure()
#endif
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions Sources/OpenSwiftUICore/Util/CoreGlue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public import CoreText
#endif
@_spiOnly
public import OpenAttributeGraphShims
public import OpenCoreGraphicsShims
import OpenSwiftUI_SPI

// MARK: - CoreGlue
Expand Down Expand Up @@ -263,12 +264,12 @@ open class CoreGlue2: NSObject {
_openSwiftUIBaseClassAbstractMethod()
}

#if canImport(CoreText)
#if canImport(ObjectiveC)
@objc(makeSummarySymbolHostIsOn:font:foregroundColor:)
#endif
open func makeSummarySymbolHost(isOn: Bool, font: CTFont, foregroundColor: CGColor) -> AnyObject {
_openSwiftUIBaseClassAbstractMethod()
}
#endif

#if canImport(Darwin)
override dynamic public init() {
Expand Down
Loading