From 57fe857a30f5e865ae22e70b571bb7ca3ee0eb8c Mon Sep 17 00:00:00 2001 From: Matt <85322+mattmassicotte@users.noreply.github.com> Date: Fri, 29 Mar 2024 08:51:29 -0400 Subject: [PATCH] Color wrapper --- Sources/NSUI/Color.swift | 12 ++++++++++++ Tests/NSUITests/ColorTests.swift | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Sources/NSUI/Color.swift create mode 100644 Tests/NSUITests/ColorTests.swift diff --git a/Sources/NSUI/Color.swift b/Sources/NSUI/Color.swift new file mode 100644 index 0000000..ed56d51 --- /dev/null +++ b/Sources/NSUI/Color.swift @@ -0,0 +1,12 @@ +import SwiftUI + +extension Color { + @available(macOS 12.0, *) + public init(nsuiColor: NSUIColor) { +#if canImport(AppKit) && !targetEnvironment(macCatalyst) + self.init(nsColor: nsuiColor) +#elseif canImport(UIKit) + self.init(uiColor: nsuiColor) +#endif + } +} diff --git a/Tests/NSUITests/ColorTests.swift b/Tests/NSUITests/ColorTests.swift new file mode 100644 index 0000000..c82de21 --- /dev/null +++ b/Tests/NSUITests/ColorTests.swift @@ -0,0 +1,10 @@ +import SwiftUI +import XCTest + +import NSUI + +final class ColorTests: XCTestCase { + func testInit() { + let _ = Color(nsuiColor: NSUIColor.red) + } +}