From a27be14185316b99d0763019407341dd8b01dc77 Mon Sep 17 00:00:00 2001 From: Mohamed Ali Date: Sun, 20 Jun 2021 18:40:57 +0300 Subject: [PATCH] fix: build for tvOS, macOS and watchOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - change UIColor by _PlatformColor in LazyImageView - add secondarySystemBackground in extension of UIColor when it’s targeted for tvOS and watchOS --- Package.resolved | 4 ++-- Sources/Internal.swift | 11 +++++++++++ Sources/LazyImage.swift | 4 +++- Sources/LazyImageView.swift | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index b8fb192..ba3ad54 100644 --- a/Package.resolved +++ b/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/kean/Nuke.git", "state": { "branch": null, - "revision": "5a8d11b4b8fd631f2937d2e41910ae329aed31b7", - "version": "10.0.0" + "revision": "69ae6d5b8c4b898450432f94bd35f863d3830cfc", + "version": "10.3.0" } } ] diff --git a/Sources/Internal.swift b/Sources/Internal.swift index 8e82100..b786241 100644 --- a/Sources/Internal.swift +++ b/Sources/Internal.swift @@ -104,6 +104,17 @@ extension UIView.ContentMode { #endif +#if os(tvOS) || os(watchOS) +import UIKit + +extension UIColor { + @objc(secondarySystemBackgroundColor) + public static var secondarySystemBackground: UIColor { + return lightGray.withAlphaComponent(0.5) + } +} +#endif + extension ImageRequest { struct ID: Hashable { let imageId: String? diff --git a/Sources/LazyImage.swift b/Sources/LazyImage.swift index 4dd623a..b466300 100644 --- a/Sources/LazyImage.swift +++ b/Sources/LazyImage.swift @@ -215,7 +215,7 @@ public struct LazyImage: View { } #endif } else { - Rectangle().foregroundColor(Color(_PlatformColor.secondarySystemBackground)) + Rectangle().foregroundColor(Color(.secondarySystemBackground)) } } @@ -267,6 +267,8 @@ public struct LazyImageState { public var image: Image? { #if os(macOS) return imageContainer.map { Image($0.image) } +#elseif os(watchOS) +return imageContainer.map { Image(uiImage: $0.image) } #else return imageContainer.map { Image($0.image) } #endif diff --git a/Sources/LazyImageView.swift b/Sources/LazyImageView.swift index 8f839f6..623f4d1 100644 --- a/Sources/LazyImageView.swift +++ b/Sources/LazyImageView.swift @@ -198,7 +198,7 @@ public final class LazyImageView: _PlatformBaseView { if #available(iOS 13.0, *) { color = .secondarySystemBackground } else { - color = UIColor.lightGray.withAlphaComponent(0.5) + color = _PlatformColor.lightGray.withAlphaComponent(0.5) } #if os(macOS) view.wantsLayer = true