Skip to content

Commit 9061bea

Browse files
committed
Add all the available version check, allows for lower firmware deployment target version user
1 parent 1582e80 commit 9061bea

File tree

9 files changed

+51
-7
lines changed

9 files changed

+51
-7
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import SDWebImage
1212
#if os(iOS) || os(tvOS) || os(macOS)
1313

1414
/// A coordinator object used for `AnimatedImage`native view bridge for UIKit/AppKit/WatchKit.
15+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1516
public final class AnimatedImageCoordinator: NSObject {
1617

1718
/// Any user-provided object for actual coordinator, such as delegate method, taget-action
@@ -22,6 +23,7 @@ public final class AnimatedImageCoordinator: NSObject {
2223
}
2324

2425
/// Data Binding Object, only properties in this object can support changes from user with @State and refresh
26+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
2527
final class AnimatedImageModel : ObservableObject {
2628
/// URL image
2729
@Published var url: URL?
@@ -36,6 +38,7 @@ final class AnimatedImageModel : ObservableObject {
3638
}
3739

3840
/// Completion Handler Binding Object, supports dynamic @State changes
41+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
3942
final class AnimatedImageHandler: ObservableObject {
4043
// Completion Handler
4144
@Published var successBlock: ((PlatformImage, SDImageCacheType) -> Void)?
@@ -47,6 +50,7 @@ final class AnimatedImageHandler: ObservableObject {
4750
}
4851

4952
/// Layout Binding Object, supports dynamic @State changes
53+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
5054
final class AnimatedImageLayout : ObservableObject {
5155
var contentMode: ContentMode?
5256
var aspectRatio: CGFloat?
@@ -58,6 +62,7 @@ final class AnimatedImageLayout : ObservableObject {
5862
}
5963

6064
/// Configuration Binding Object, supports dynamic @State changes
65+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
6166
final class AnimatedImageConfiguration: ObservableObject {
6267
var incrementalLoad: Bool?
6368
var maxBufferSize: UInt?
@@ -73,6 +78,7 @@ final class AnimatedImageConfiguration: ObservableObject {
7378
}
7479

7580
/// A Image View type to load image from url, data or bundle. Supports animated and static image format.
81+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
7682
public struct AnimatedImage : PlatformViewRepresentable {
7783
@ObservedObject var imageModel = AnimatedImageModel()
7884
@ObservedObject var imageHandler = AnimatedImageHandler()
@@ -444,6 +450,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
444450
}
445451

446452
// Layout
453+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
447454
extension AnimatedImage {
448455

449456
/// Configurate this view's image with the specified cap insets and options.
@@ -483,6 +490,7 @@ extension AnimatedImage {
483490
}
484491

485492
// Aspect Ratio
493+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
486494
extension AnimatedImage {
487495
/// Constrains this view's dimensions to the specified aspect ratio.
488496
/// - Parameters:
@@ -541,6 +549,7 @@ extension AnimatedImage {
541549
}
542550

543551
// AnimatedImage Modifier
552+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
544553
extension AnimatedImage {
545554

546555
/// Total loop count for animated image rendering. Defaults to nil.
@@ -610,6 +619,7 @@ extension AnimatedImage {
610619
}
611620

612621
// Completion Handler
622+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
613623
extension AnimatedImage {
614624

615625
/// Provide the action when image load fails.
@@ -641,6 +651,7 @@ extension AnimatedImage {
641651
}
642652

643653
// View Coordinator Handler
654+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
644655
extension AnimatedImage {
645656

646657
/// Provide the action when view representable create the native view.
@@ -668,6 +679,7 @@ extension AnimatedImage {
668679
}
669680

670681
// Web Image convenience
682+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
671683
extension AnimatedImage {
672684

673685
/// Associate a placeholder when loading image with url
@@ -695,6 +707,7 @@ extension AnimatedImage {
695707
}
696708

697709
#if DEBUG
710+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
698711
struct AnimatedImage_Previews : PreviewProvider {
699712
static var previews: some View {
700713
Group {

SDWebImageSwiftUI/Classes/ImageManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import SwiftUI
1010
import SDWebImage
1111

12+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1213
class ImageManager : ObservableObject {
1314
@Published var image: PlatformImage? // loaded image, note when progressive loading, this will published multiple times with different partial image
1415
@Published var isLoading: Bool = false // whether network is loading or cache is querying, should only be used for indicator binding

SDWebImageSwiftUI/Classes/ImageViewWrapper.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import SDWebImage
1212
#if os(iOS) || os(tvOS) || os(macOS)
1313

1414
/// Use wrapper to solve tne `UIImageView`/`NSImageView` frame size become image size issue (SwiftUI's Bug)
15+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1516
public class AnimatedImageViewWrapper : PlatformView {
1617
var wrapped = SDAnimatedImageView()
1718
var interpolationQuality = CGInterpolationQuality.default
@@ -67,29 +68,33 @@ public class AnimatedImageViewWrapper : PlatformView {
6768
}
6869
}
6970

70-
private var sd_imageNameKey: Void?
71-
private var sd_imageDataKey: Void?
71+
7272
/// Store the Animated Image loading state, to avoid re-query duinrg `updateView(_:)` until Source of Truth changes
73+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
7374
extension PlatformView {
75+
static private var sd_imageNameKey: Void?
76+
static private var sd_imageDataKey: Void?
77+
7478
var sd_imageName: String? {
7579
get {
76-
objc_getAssociatedObject(self, &sd_imageNameKey) as? String
80+
objc_getAssociatedObject(self, &UIView.sd_imageNameKey) as? String
7781
}
7882
set {
79-
objc_setAssociatedObject(self, &sd_imageNameKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
83+
objc_setAssociatedObject(self, &UIView.sd_imageNameKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
8084
}
8185
}
8286
var sd_imageData: Data? {
8387
get {
84-
objc_getAssociatedObject(self, &sd_imageDataKey) as? Data
88+
objc_getAssociatedObject(self, &UIView.sd_imageDataKey) as? Data
8589
}
8690
set {
87-
objc_setAssociatedObject(self, &sd_imageDataKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
91+
objc_setAssociatedObject(self, &UIView.sd_imageDataKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
8892
}
8993
}
9094
}
9195

9296
/// Use wrapper to solve the `UIProgressView`/`NSProgressIndicator` frame origin NaN crash (SwiftUI's bug)
97+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
9398
public class ProgressIndicatorWrapper : PlatformView {
9499
#if os(macOS)
95100
var wrapped = NSProgressIndicator()

SDWebImageSwiftUI/Classes/Indicator/ActivityIndicator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SwiftUI
1010

1111
#if os(macOS) || os(iOS) || os(tvOS)
1212
/// An activity indicator (system style)
13+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1314
public struct ActivityIndicator: PlatformViewRepresentable {
1415
@Binding var isAnimating: Bool
1516
var style: Style
@@ -71,6 +72,7 @@ public struct ActivityIndicator: PlatformViewRepresentable {
7172
#endif
7273
}
7374

75+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
7476
extension ActivityIndicator {
7577
public enum Style {
7678
case medium

SDWebImageSwiftUI/Classes/Indicator/Indicator.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Foundation
1010
import SwiftUI
1111

1212
/// A type to build the indicator
13+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1314
public struct Indicator<T> where T : View {
1415
var content: (Binding<Bool>, Binding<CGFloat>) -> T
1516

@@ -26,6 +27,7 @@ public struct Indicator<T> where T : View {
2627
/// A implementation detail View Modifier with indicator
2728
/// SwiftUI View Modifier construced by using a internal View type which modify the `body`
2829
/// It use type system to represent the view hierarchy, and Swift `some View` syntax to hide the type detail for users
30+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
2931
struct IndicatorViewModifier<T> : ViewModifier where T : View {
3032
@ObservedObject var imageManager: ImageManager
3133

@@ -44,6 +46,7 @@ struct IndicatorViewModifier<T> : ViewModifier where T : View {
4446
}
4547

4648
#if os(macOS) || os(iOS) || os(tvOS)
49+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
4750
extension Indicator where T == ActivityIndicator {
4851
/// Activity Indicator
4952
public static var activity: Indicator {
@@ -61,6 +64,7 @@ extension Indicator where T == ActivityIndicator {
6164
}
6265
}
6366

67+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
6468
extension Indicator where T == ProgressIndicator {
6569
/// Progress Indicator
6670
public static var progress: Indicator {

SDWebImageSwiftUI/Classes/Indicator/ProgressIndicator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SwiftUI
1010

1111
#if os(macOS) || os(iOS) || os(tvOS)
1212
/// A progress bar indicator (system style)
13+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1314
public struct ProgressIndicator: PlatformViewRepresentable {
1415
@Binding var isAnimating: Bool
1516
@Binding var progress: CGFloat
@@ -101,6 +102,7 @@ public struct ProgressIndicator: PlatformViewRepresentable {
101102
#endif
102103
}
103104

105+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
104106
extension ProgressIndicator {
105107
public enum Style {
106108
case `default`

SDWebImageSwiftUI/Classes/SDWebImageSwiftUI.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import Foundation
1010
import SwiftUI
1111

1212
#if os(macOS)
13+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1314
public typealias PlatformImage = NSImage
1415
#else
16+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1517
public typealias PlatformImage = UIImage
1618
#endif
1719

20+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1821
extension Image {
1922
init(platformImage: PlatformImage) {
2023
#if os(macOS)
@@ -26,21 +29,27 @@ extension Image {
2629
}
2730

2831
#if os(macOS)
32+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
2933
public typealias PlatformView = NSView
3034
#endif
3135
#if os(iOS) || os(tvOS)
36+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
3237
public typealias PlatformView = UIView
3338
#endif
3439
#if os(watchOS)
40+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
3541
public typealias PlatformView = WKInterfaceObject
3642
#endif
3743

3844
#if os(macOS)
45+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
3946
public typealias PlatformViewRepresentable = NSViewRepresentable
4047
#endif
4148
#if os(iOS) || os(tvOS)
49+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
4250
public typealias PlatformViewRepresentable = UIViewRepresentable
4351
#endif
4452
#if os(watchOS)
53+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
4554
public typealias PlatformViewRepresentable = WKInterfaceObjectRepresentable
4655
#endif

SDWebImageSwiftUI/Classes/Transition/Transition.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import SwiftUI
1010

11+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1112
extension AnyTransition {
1213

1314
/// Fade-in transition

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import SwiftUI
1010
import SDWebImage
1111

12-
/// A Image View type to load image from url. Supports static image format.
12+
/// A Image View type to load image from url. Supports static/animated image format.
13+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1314
public struct WebImage : View {
1415
var configurations: [(Image) -> Image] = []
1516

@@ -90,6 +91,7 @@ public struct WebImage : View {
9091
}
9192

9293
// Layout
94+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
9395
extension WebImage {
9496
func configure(_ block: @escaping (Image) -> Image) -> WebImage {
9597
var result = self
@@ -127,6 +129,7 @@ extension WebImage {
127129
}
128130

129131
// Completion Handler
132+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
130133
extension WebImage {
131134

132135
/// Provide the action when image load fails.
@@ -158,6 +161,7 @@ extension WebImage {
158161
}
159162

160163
// WebImage Modifier
164+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
161165
extension WebImage {
162166

163167
/// Associate a placeholder when loading image with url
@@ -198,6 +202,7 @@ extension WebImage {
198202
}
199203

200204
// Indicator
205+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
201206
extension WebImage {
202207

203208
/// Associate a indicator when loading image with url
@@ -214,6 +219,7 @@ extension WebImage {
214219
}
215220

216221
// Animated Image support (Beta)
222+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
217223
extension WebImage {
218224

219225
/// Make the image to support animated images. The animation will start when view appears, and pause when disappears.
@@ -259,6 +265,7 @@ extension WebImage {
259265
}
260266

261267
#if DEBUG
268+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
262269
struct WebImage_Previews : PreviewProvider {
263270
static var previews: some View {
264271
Group {

0 commit comments

Comments
 (0)