Skip to content

Commit

Permalink
Merge pull request #2124 from onevcat/feature/visionOS
Browse files Browse the repository at this point in the history
Sync changes for visionOS to master
  • Loading branch information
onevcat authored Aug 16, 2023
2 parents eb3926b + f1fe92c commit 8816d9c
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Sources/General/ImageSource/AVAssetImageDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/General/KF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Image/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Sources/Image/ImageDrawing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion Sources/Image/ImageTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion Sources/Networking/ImageModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Views/AnimatedImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Views/Indicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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, * ) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/KingfisherTests/ImageCacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion Tests/KingfisherTests/ImageDownloaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions Tests/KingfisherTests/ImageExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ 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)
XCTAssertEqual(image!.kf.duration, 0.8, accuracy: 0.001)
#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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Tests/KingfisherTests/ImageModifierTests.swift
Original file line number Diff line number Diff line change
Expand 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)
Expand Down
2 changes: 1 addition & 1 deletion Tests/KingfisherTests/KingfisherManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions Tests/KingfisherTests/KingfisherOptionsInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Tests/KingfisherTests/KingfisherTestHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8816d9c

Please sign in to comment.