mirror of
https://github.com/zhigang1992/Kingfisher.git
synced 2026-04-30 04:55:45 +08:00
Includes checks for visionOS
This commit is contained in:
@@ -127,7 +127,7 @@ extension CGImage {
|
||||
guard let mutableData = CFDataCreateMutable(nil, 0) else {
|
||||
return nil
|
||||
}
|
||||
#if os(xrOS)
|
||||
#if os(visionOS)
|
||||
guard let destination = CGImageDestinationCreateWithData(
|
||||
mutableData, UTType.jpeg.identifier as CFString , 1, nil
|
||||
) else {
|
||||
|
||||
@@ -313,7 +313,7 @@ extension KF.Builder {
|
||||
|
||||
#if !os(watchOS)
|
||||
extension KF.Builder {
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
|
||||
/// Sets a placeholder which is used while retrieving the image.
|
||||
/// - Parameter placeholder: A placeholder to show while retrieving the image from its source.
|
||||
@@ -336,7 +336,7 @@ extension KF.Builder {
|
||||
|
||||
extension KF.Builder {
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
/// Sets the transition for the image task.
|
||||
/// - Parameter transition: The desired transition effect when setting the image to image view.
|
||||
/// - Returns: A `KF.Builder` with changes applied.
|
||||
|
||||
@@ -278,7 +278,7 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
|
||||
/// - Returns: An `Image` object represents the animated image. It is in form of an array of image frames with a
|
||||
/// certain duration. `nil` if anything wrong when creating animated image.
|
||||
public static func animatedImage(data: Data, options: ImageCreatingOptions) -> KFCrossPlatformImage? {
|
||||
#if os(xrOS)
|
||||
#if os(visionOS)
|
||||
let info: [String: Any] = [
|
||||
kCGImageSourceShouldCache as String: true,
|
||||
kCGImageSourceTypeIdentifierHint as String: UTType.gif.identifier
|
||||
|
||||
@@ -201,7 +201,7 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
func resize(to size: CGSize, for contentMode: UIView.ContentMode) -> KFCrossPlatformImage {
|
||||
switch contentMode {
|
||||
case .scaleAspectFit:
|
||||
@@ -513,7 +513,7 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
|
||||
/// For any non-CG-based image or animated image, `base` itself is returned.
|
||||
public func decoded(scale: CGFloat) -> KFCrossPlatformImage {
|
||||
// Prevent animated image (GIF) losing it's images
|
||||
#if os(iOS)
|
||||
#if os(iOS) || os(visionOS)
|
||||
if frameSource != nil { return base }
|
||||
#else
|
||||
if images != nil { return base }
|
||||
@@ -542,7 +542,7 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
|
||||
/// For any non-CG-based image or animated image, `base` itself is returned.
|
||||
public func decoded(on context: CGContext) -> KFCrossPlatformImage {
|
||||
// Prevent animated image (GIF) losing it's images
|
||||
#if os(iOS)
|
||||
#if os(iOS) || os(visionOS)
|
||||
if frameSource != nil { return base }
|
||||
#else
|
||||
if images != nil { return base }
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
import UIKit
|
||||
|
||||
/// Transition effect which will be used when an image downloaded and set by `UIImageView`
|
||||
|
||||
@@ -63,7 +63,7 @@ public struct AnyImageModifier: ImageModifier {
|
||||
}
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
|
||||
import UIKit
|
||||
|
||||
/// Modifier for setting the rendering mode of images.
|
||||
|
||||
@@ -265,7 +265,7 @@ open class AnimatedImageView: UIImageView {
|
||||
private func reset() {
|
||||
animator = nil
|
||||
if let image = image, let frameSource = image.kf.frameSource {
|
||||
#if os(xrOS)
|
||||
#if os(visionOS)
|
||||
let targetSize = bounds.scaled(UITraitCollection.current.displayScale).size
|
||||
#else
|
||||
let targetSize = bounds.scaled(UIScreen.main.scale).size
|
||||
|
||||
@@ -148,7 +148,7 @@ final class ActivityIndicator: Indicator {
|
||||
} else {
|
||||
indicatorStyle = UIActivityIndicatorView.Style.white
|
||||
}
|
||||
#elseif os(xrOS)
|
||||
#elseif os(visionOS)
|
||||
indicatorStyle = UIActivityIndicatorView.Style.medium
|
||||
#else
|
||||
if #available(iOS 13.0, * ) {
|
||||
|
||||
@@ -384,7 +384,7 @@ class ImageCacheTests: XCTestCase {
|
||||
waitForExpectations(timeout: 3, handler: nil)
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
|
||||
func testModifierShouldOnlyApplyForFinalResultWhenMemoryLoad() {
|
||||
let exp = expectation(description: #function)
|
||||
let key = testKeys[0]
|
||||
|
||||
@@ -508,7 +508,7 @@ class ImageDownloaderTests: XCTestCase {
|
||||
waitForExpectations(timeout: 3, handler: nil)
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
|
||||
func testModifierShouldOnlyApplyForFinalResultWhenDownload() {
|
||||
let exp = expectation(description: #function)
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class ImageExtensionTests: XCTestCase {
|
||||
let options = ImageCreatingOptions()
|
||||
let image = KingfisherWrapper<KFCrossPlatformImage>.animatedImage(data: testImageGIFData, options: options)
|
||||
XCTAssertNotNil(image)
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
XCTAssertEqual(image!.kf.imageFrameCount!, 8)
|
||||
#else
|
||||
XCTAssertEqual(image!.kf.images!.count, 8)
|
||||
@@ -66,7 +66,7 @@ class ImageExtensionTests: XCTestCase {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
func testScaleForGIFImage() {
|
||||
let options = ImageCreatingOptions(scale: 2.0, duration: 0.0, preloadAll: false, onlyFirstFrame: false)
|
||||
let image = KingfisherWrapper<KFCrossPlatformImage>.animatedImage(data: testImageGIFData, options: options)
|
||||
@@ -94,7 +94,7 @@ class ImageExtensionTests: XCTestCase {
|
||||
let options = ImageCreatingOptions()
|
||||
let image = KingfisherWrapper<KFCrossPlatformImage>.animatedImage(data: testImageSingleFrameGIFData, options: options)
|
||||
XCTAssertNotNil(image)
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
XCTAssertEqual(image!.kf.imageFrameCount!, 1)
|
||||
#else
|
||||
XCTAssertEqual(image!.kf.images!.count, 1)
|
||||
@@ -113,7 +113,7 @@ class ImageExtensionTests: XCTestCase {
|
||||
let preloadOptions = ImageCreatingOptions(preloadAll: true)
|
||||
let image = KingfisherWrapper<KFCrossPlatformImage>.animatedImage(data: testImageSingleFrameGIFData, options: preloadOptions)!
|
||||
XCTAssertNotNil(image, "The image should be initiated.")
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
XCTAssertNil(image.kf.imageSource, "Image source should be nil")
|
||||
#endif
|
||||
XCTAssertEqual(image.kf.duration, image.kf.duration)
|
||||
@@ -247,7 +247,7 @@ class ImageExtensionTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testDecodeScale() {
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
let image = testImage
|
||||
XCTAssertEqual(image.size, CGSize(width: 64, height: 64))
|
||||
XCTAssertEqual(image.scale, 1.0)
|
||||
@@ -278,7 +278,7 @@ class ImageExtensionTests: XCTestCase {
|
||||
XCTAssertNotNil(gifImage)
|
||||
XCTAssertEqual(gifImage!.kf.normalized, gifImage!)
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
// No need to normalize up orientation image.
|
||||
let normalImage = testImage
|
||||
XCTAssertEqual(normalImage.imageOrientation, .up)
|
||||
|
||||
@@ -48,7 +48,7 @@ class ImageModifierTests: XCTestCase {
|
||||
XCTAssert(modifiedImage == image)
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
|
||||
|
||||
func testRenderingModeImageModifier() {
|
||||
let m1 = RenderingModeImageModifier(renderingMode: .alwaysOriginal)
|
||||
|
||||
@@ -656,7 +656,7 @@ class KingfisherManagerTests: XCTestCase {
|
||||
waitForExpectations(timeout: 3, handler: nil)
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
|
||||
func testShouldApplyImageModifierWhenDownload() {
|
||||
let exp = expectation(description: #function)
|
||||
let url = testURLs[0]
|
||||
|
||||
@@ -35,7 +35,7 @@ class KingfisherOptionsInfoTests: XCTestCase {
|
||||
XCTAssertTrue(options.targetCache === nil)
|
||||
XCTAssertTrue(options.downloader === nil)
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
switch options.transition {
|
||||
case .none: break
|
||||
default: XCTFail("The transition for empty option should be .None. But \(options.transition)")
|
||||
@@ -99,7 +99,7 @@ class KingfisherOptionsInfoTests: XCTestCase {
|
||||
XCTAssertTrue(options.originalCache === cache)
|
||||
XCTAssertTrue(options.downloader === downloader)
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
let transition = ImageTransition.fade(0.5)
|
||||
options.transition = transition
|
||||
switch options.transition {
|
||||
|
||||
@@ -196,7 +196,7 @@ extension KFCrossPlatformImage {
|
||||
}
|
||||
}
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
||||
import UIKit
|
||||
extension KFCrossPlatformImage {
|
||||
static func from(color: KFCrossPlatformColor, size: CGSize) -> KFCrossPlatformImage {
|
||||
|
||||
Reference in New Issue
Block a user