Skip to content

Commit

Permalink
Merge pull request #321 from woxtu/available
Browse files Browse the repository at this point in the history
Update platform names in `available` attributes
  • Loading branch information
dreampiggy authored Jun 18, 2024
2 parents 9372a08 + 522e8bc commit 9cf2f51
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ class ViewController: UIViewController {
}

// ContentView.swift
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
struct ContentView : View {
var body: some View {
Group {
Expand Down
28 changes: 14 additions & 14 deletions SDWebImageSwiftUI/Classes/AnimatedImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SDWebImage
#if !os(watchOS)

/// A coordinator object used for `AnimatedImage`native view bridge for UIKit/AppKit.
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public final class AnimatedImageCoordinator: NSObject {

/// Any user-provided object for actual coordinator, such as delegate method, taget-action
Expand All @@ -25,7 +25,7 @@ public final class AnimatedImageCoordinator: NSObject {
}

/// Data Binding Object, only properties in this object can support changes from user with @State and refresh
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
final class AnimatedImageModel : ObservableObject {
enum Kind {
case url
Expand Down Expand Up @@ -53,7 +53,7 @@ final class AnimatedImageModel : ObservableObject {
}

/// Loading Binding Object, only properties in this object can support changes from user with @State and refresh
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
final class AnimatedLoadingModel : ObservableObject {
@Published var image: PlatformImage? // loaded image, note when progressive loading, this will published multiple times with different partial image
@Published var isLoading: Bool = false // whether network is loading or cache is querying, should only be used for indicator binding
Expand All @@ -66,7 +66,7 @@ final class AnimatedLoadingModel : ObservableObject {
}

/// Completion Handler Binding Object, supports dynamic @State changes
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
final class AnimatedImageHandler: ObservableObject {
// Completion Handler
@Published var successBlock: ((PlatformImage, Data?, SDImageCacheType) -> Void)?
Expand All @@ -78,7 +78,7 @@ final class AnimatedImageHandler: ObservableObject {
}

/// Layout Binding Object, supports dynamic @State changes
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
final class AnimatedImageLayout : ObservableObject {
var contentMode: ContentMode?
var aspectRatio: CGFloat?
Expand All @@ -90,7 +90,7 @@ final class AnimatedImageLayout : ObservableObject {
}

/// Configuration Binding Object, supports dynamic @State changes
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
final class AnimatedImageConfiguration: ObservableObject {
var incrementalLoad: Bool?
var maxBufferSize: UInt?
Expand All @@ -106,7 +106,7 @@ final class AnimatedImageConfiguration: ObservableObject {
}

/// A Image View type to load image from url, data or bundle. Supports animated and static image format.
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct AnimatedImage : PlatformViewRepresentable {
@ObservedObject var imageModel: AnimatedImageModel
@ObservedObject var imageHandler = AnimatedImageHandler()
Expand Down Expand Up @@ -591,7 +591,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
}

// Layout
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AnimatedImage {

/// Configurate this view's image with the specified cap insets and options.
Expand Down Expand Up @@ -631,7 +631,7 @@ extension AnimatedImage {
}

// Aspect Ratio
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AnimatedImage {
func setImageLayoutAspectRatio(_ aspectRatio: CGFloat?, contentMode: ContentMode) {
self.imageLayout.aspectRatio = aspectRatio
Expand Down Expand Up @@ -693,7 +693,7 @@ extension AnimatedImage {
}

// AnimatedImage Modifier
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AnimatedImage {

/// Total loop count for animated image rendering. Defaults to nil.
Expand Down Expand Up @@ -770,7 +770,7 @@ extension AnimatedImage {
}

// Completion Handler
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AnimatedImage {

/// Provide the action when image load fails.
Expand Down Expand Up @@ -802,7 +802,7 @@ extension AnimatedImage {
}

// View Coordinator Handler
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AnimatedImage {

/// Provide the action when view representable create the native view.
Expand Down Expand Up @@ -839,7 +839,7 @@ extension SDWebImageIndicator where Self == SDWebImageProgressIndicator {
}

// Web Image convenience, based on UIKit/AppKit API
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AnimatedImage {

/// Associate a indicator when loading image with url
Expand All @@ -860,7 +860,7 @@ extension AnimatedImage {
}

#if DEBUG
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
struct AnimatedImage_Previews : PreviewProvider {
static var previews: some View {
Group {
Expand Down
8 changes: 4 additions & 4 deletions SDWebImageSwiftUI/Classes/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import SwiftUI

@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Image {
@inlinable init(platformImage: PlatformImage) {
#if os(macOS)
Expand All @@ -20,13 +20,13 @@ extension Image {
}
}

@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension PlatformImage {
static var empty = PlatformImage()
}

#if !os(macOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension PlatformImage.Orientation {
@inlinable var toSwiftUI: Image.Orientation {
switch self {
Expand All @@ -52,7 +52,7 @@ extension PlatformImage.Orientation {
}
}

@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Image.Orientation {
@inlinable var toPlatform: PlatformImage.Orientation {
switch self {
Expand Down
4 changes: 2 additions & 2 deletions SDWebImageSwiftUI/Classes/ImageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SDWebImage

/// A Image observable object for handle image load process. This drive the Source of Truth for image loading status.
/// You can use `@ObservedObject` to associate each instance of manager to your View type, which update your view's body from SwiftUI framework when image was loaded.
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public final class ImageManager : ObservableObject {
/// loaded image, note when progressive loading, this will published multiple times with different partial image
public var image: PlatformImage? {
Expand Down Expand Up @@ -136,7 +136,7 @@ public final class ImageManager : ObservableObject {
}

// Completion Handler
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension ImageManager {
/// Provide the action when image load fails.
/// - Parameters:
Expand Down
2 changes: 1 addition & 1 deletion SDWebImageSwiftUI/Classes/ImagePlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Combine
import SDWebImage

/// A Image observable object for handle aniamted image playback. This is used to avoid `@State` update may capture the View struct type and cause memory leak.
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public final class ImagePlayer : ObservableObject {
var player: SDAnimatedImagePlayer?

Expand Down
4 changes: 2 additions & 2 deletions SDWebImageSwiftUI/Classes/ImageViewWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SDWebImage
#if !os(watchOS)

/// Use wrapper to solve tne `UIImageView`/`NSImageView` frame size become image size issue (SwiftUI's Bug)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public class AnimatedImageViewWrapper : PlatformView {
/// The wrapped actual image view, using SDWebImage's aniamted image view
public var wrapped = SDAnimatedImageView()
Expand Down Expand Up @@ -67,7 +67,7 @@ public class AnimatedImageViewWrapper : PlatformView {
}
}

@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension PlatformView {
/// Adds constraints to this `UIView` instances `superview` object to make sure this always has the same size as the superview.
/// Please note that this has no effect if its `superview` is `nil` – add this `UIView` instance as a subview before calling this.
Expand Down
10 changes: 5 additions & 5 deletions SDWebImageSwiftUI/Classes/Indicator/Indicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
import Combine

/// A type to build the indicator
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct Indicator<T> where T : View {
var content: (Binding<Bool>, Binding<Double>) -> T

Expand All @@ -25,7 +25,7 @@ public struct Indicator<T> where T : View {
}

/// A observable model to report indicator loading status
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public class IndicatorStatus : ObservableObject {
/// whether indicator is loading or not
var isLoading: Bool = false {
Expand All @@ -48,7 +48,7 @@ public class IndicatorStatus : ObservableObject {
/// A implementation detail View Modifier with indicator
/// SwiftUI View Modifier construced by using a internal View type which modify the `body`
/// It use type system to represent the view hierarchy, and Swift `some View` syntax to hide the type detail for users
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public struct IndicatorViewModifier<T> : ViewModifier where T : View {

/// The loading status
Expand All @@ -72,7 +72,7 @@ public struct IndicatorViewModifier<T> : ViewModifier where T : View {
}
}

@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Indicator where T == AnyView {
/// Activity Indicator
public static var activity: Indicator<T> {
Expand All @@ -90,7 +90,7 @@ extension Indicator where T == AnyView {
}
}

@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension Indicator where T == AnyView {
/// Progress Indicator
public static var progress: Indicator<T> {
Expand Down
22 changes: 11 additions & 11 deletions SDWebImageSwiftUI/Classes/SDWebImageSwiftUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,53 @@ import SwiftUI
@_exported import SDWebImage // Automatically import SDWebImage

#if os(macOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformImage = NSImage
#else
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformImage = UIImage
#endif

#if os(macOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformView = NSView
#endif
#if os(iOS) || os(tvOS) || os(visionOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformView = UIView
#endif
#if os(watchOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformView = WKInterfaceObject
#endif

#if os(macOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformViewRepresentable = NSViewRepresentable
#endif
#if os(iOS) || os(tvOS) || os(visionOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformViewRepresentable = UIViewRepresentable
#endif
#if os(watchOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformViewRepresentable = WKInterfaceObjectRepresentable
#endif

#if os(macOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension NSViewRepresentable {
typealias PlatformViewType = NSViewType
}
#endif
#if os(iOS) || os(tvOS) || os(visionOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension UIViewRepresentable {
typealias PlatformViewType = UIViewType
}
#endif
#if os(watchOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension WKInterfaceObjectRepresentable {
typealias PlatformViewType = WKInterfaceObjectType
}
Expand Down
2 changes: 1 addition & 1 deletion SDWebImageSwiftUI/Classes/Transition/Transition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
extension AnyTransition {

/// Fade-in transition
Expand Down
Loading

0 comments on commit 9cf2f51

Please sign in to comment.