Merge pull request #321 from woxtu/available
Update platform names in `available` attributes
This commit is contained in:
commit
9cf2f513c9
|
@ -655,7 +655,7 @@ class ViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContentView.swift
|
// 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 {
|
struct ContentView : View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import SDWebImage
|
||||||
#if !os(watchOS)
|
#if !os(watchOS)
|
||||||
|
|
||||||
/// A coordinator object used for `AnimatedImage`native view bridge for UIKit/AppKit.
|
/// 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 {
|
public final class AnimatedImageCoordinator: NSObject {
|
||||||
|
|
||||||
/// Any user-provided object for actual coordinator, such as delegate method, taget-action
|
/// Any user-provided object for actual coordinator, such as delegate method, taget-action
|
||||||
|
@ -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
|
/// 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 {
|
final class AnimatedImageModel : ObservableObject {
|
||||||
enum Kind {
|
enum Kind {
|
||||||
case url
|
case url
|
||||||
|
@ -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
|
/// 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 {
|
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 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
|
@Published var isLoading: Bool = false // whether network is loading or cache is querying, should only be used for indicator binding
|
||||||
|
@ -66,7 +66,7 @@ final class AnimatedLoadingModel : ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Completion Handler Binding Object, supports dynamic @State changes
|
/// 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 {
|
final class AnimatedImageHandler: ObservableObject {
|
||||||
// Completion Handler
|
// Completion Handler
|
||||||
@Published var successBlock: ((PlatformImage, Data?, SDImageCacheType) -> Void)?
|
@Published var successBlock: ((PlatformImage, Data?, SDImageCacheType) -> Void)?
|
||||||
|
@ -78,7 +78,7 @@ final class AnimatedImageHandler: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Layout Binding Object, supports dynamic @State changes
|
/// 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 {
|
final class AnimatedImageLayout : ObservableObject {
|
||||||
var contentMode: ContentMode?
|
var contentMode: ContentMode?
|
||||||
var aspectRatio: CGFloat?
|
var aspectRatio: CGFloat?
|
||||||
|
@ -90,7 +90,7 @@ final class AnimatedImageLayout : ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration Binding Object, supports dynamic @State changes
|
/// 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 {
|
final class AnimatedImageConfiguration: ObservableObject {
|
||||||
var incrementalLoad: Bool?
|
var incrementalLoad: Bool?
|
||||||
var maxBufferSize: UInt?
|
var maxBufferSize: UInt?
|
||||||
|
@ -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.
|
/// 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 {
|
public struct AnimatedImage : PlatformViewRepresentable {
|
||||||
@ObservedObject var imageModel: AnimatedImageModel
|
@ObservedObject var imageModel: AnimatedImageModel
|
||||||
@ObservedObject var imageHandler = AnimatedImageHandler()
|
@ObservedObject var imageHandler = AnimatedImageHandler()
|
||||||
|
@ -591,7 +591,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout
|
// 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 {
|
extension AnimatedImage {
|
||||||
|
|
||||||
/// Configurate this view's image with the specified cap insets and options.
|
/// Configurate this view's image with the specified cap insets and options.
|
||||||
|
@ -631,7 +631,7 @@ extension AnimatedImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aspect Ratio
|
// 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 {
|
extension AnimatedImage {
|
||||||
func setImageLayoutAspectRatio(_ aspectRatio: CGFloat?, contentMode: ContentMode) {
|
func setImageLayoutAspectRatio(_ aspectRatio: CGFloat?, contentMode: ContentMode) {
|
||||||
self.imageLayout.aspectRatio = aspectRatio
|
self.imageLayout.aspectRatio = aspectRatio
|
||||||
|
@ -693,7 +693,7 @@ extension AnimatedImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnimatedImage Modifier
|
// 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 {
|
extension AnimatedImage {
|
||||||
|
|
||||||
/// Total loop count for animated image rendering. Defaults to nil.
|
/// Total loop count for animated image rendering. Defaults to nil.
|
||||||
|
@ -770,7 +770,7 @@ extension AnimatedImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Completion Handler
|
// 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 {
|
extension AnimatedImage {
|
||||||
|
|
||||||
/// Provide the action when image load fails.
|
/// Provide the action when image load fails.
|
||||||
|
@ -802,7 +802,7 @@ extension AnimatedImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// View Coordinator Handler
|
// 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 {
|
extension AnimatedImage {
|
||||||
|
|
||||||
/// Provide the action when view representable create the native view.
|
/// Provide the action when view representable create the native view.
|
||||||
|
@ -839,7 +839,7 @@ extension SDWebImageIndicator where Self == SDWebImageProgressIndicator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Web Image convenience, based on UIKit/AppKit API
|
// 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 {
|
extension AnimatedImage {
|
||||||
|
|
||||||
/// Associate a indicator when loading image with url
|
/// Associate a indicator when loading image with url
|
||||||
|
@ -860,7 +860,7 @@ extension AnimatedImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#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 {
|
struct AnimatedImage_Previews : PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import SwiftUI
|
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 {
|
extension Image {
|
||||||
@inlinable init(platformImage: PlatformImage) {
|
@inlinable init(platformImage: PlatformImage) {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
|
@ -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 {
|
extension PlatformImage {
|
||||||
static var empty = PlatformImage()
|
static var empty = PlatformImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !os(macOS)
|
#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 {
|
extension PlatformImage.Orientation {
|
||||||
@inlinable var toSwiftUI: Image.Orientation {
|
@inlinable var toSwiftUI: Image.Orientation {
|
||||||
switch self {
|
switch self {
|
||||||
|
@ -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 {
|
extension Image.Orientation {
|
||||||
@inlinable var toPlatform: PlatformImage.Orientation {
|
@inlinable var toPlatform: PlatformImage.Orientation {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
|
@ -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.
|
/// 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.
|
/// 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 {
|
public final class ImageManager : ObservableObject {
|
||||||
/// loaded image, note when progressive loading, this will published multiple times with different partial image
|
/// loaded image, note when progressive loading, this will published multiple times with different partial image
|
||||||
public var image: PlatformImage? {
|
public var image: PlatformImage? {
|
||||||
|
@ -136,7 +136,7 @@ public final class ImageManager : ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Completion Handler
|
// 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 {
|
extension ImageManager {
|
||||||
/// Provide the action when image load fails.
|
/// Provide the action when image load fails.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Combine
|
||||||
import SDWebImage
|
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.
|
/// 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 {
|
public final class ImagePlayer : ObservableObject {
|
||||||
var player: SDAnimatedImagePlayer?
|
var player: SDAnimatedImagePlayer?
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import SDWebImage
|
||||||
#if !os(watchOS)
|
#if !os(watchOS)
|
||||||
|
|
||||||
/// Use wrapper to solve tne `UIImageView`/`NSImageView` frame size become image size issue (SwiftUI's Bug)
|
/// 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 {
|
public class AnimatedImageViewWrapper : PlatformView {
|
||||||
/// The wrapped actual image view, using SDWebImage's aniamted image view
|
/// The wrapped actual image view, using SDWebImage's aniamted image view
|
||||||
public var wrapped = SDAnimatedImageView()
|
public var wrapped = SDAnimatedImageView()
|
||||||
|
@ -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 {
|
extension PlatformView {
|
||||||
/// Adds constraints to this `UIView` instances `superview` object to make sure this always has the same size as the superview.
|
/// 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.
|
/// Please note that this has no effect if its `superview` is `nil` – add this `UIView` instance as a subview before calling this.
|
||||||
|
|
|
@ -10,7 +10,7 @@ import SwiftUI
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
/// A type to build the indicator
|
/// 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 {
|
public struct Indicator<T> where T : View {
|
||||||
var content: (Binding<Bool>, Binding<Double>) -> T
|
var content: (Binding<Bool>, Binding<Double>) -> T
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public struct Indicator<T> where T : View {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A observable model to report indicator loading status
|
/// 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 {
|
public class IndicatorStatus : ObservableObject {
|
||||||
/// whether indicator is loading or not
|
/// whether indicator is loading or not
|
||||||
var isLoading: Bool = false {
|
var isLoading: Bool = false {
|
||||||
|
@ -48,7 +48,7 @@ public class IndicatorStatus : ObservableObject {
|
||||||
/// A implementation detail View Modifier with indicator
|
/// A implementation detail View Modifier with indicator
|
||||||
/// SwiftUI View Modifier construced by using a internal View type which modify the `body`
|
/// 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
|
/// 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 {
|
public struct IndicatorViewModifier<T> : ViewModifier where T : View {
|
||||||
|
|
||||||
/// The loading status
|
/// The loading status
|
||||||
|
@ -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 {
|
extension Indicator where T == AnyView {
|
||||||
/// Activity Indicator
|
/// Activity Indicator
|
||||||
public static var activity: Indicator<T> {
|
public static var activity: Indicator<T> {
|
||||||
|
@ -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 {
|
extension Indicator where T == AnyView {
|
||||||
/// Progress Indicator
|
/// Progress Indicator
|
||||||
public static var progress: Indicator<T> {
|
public static var progress: Indicator<T> {
|
||||||
|
|
|
@ -11,53 +11,53 @@ import SwiftUI
|
||||||
@_exported import SDWebImage // Automatically import SDWebImage
|
@_exported import SDWebImage // Automatically import SDWebImage
|
||||||
|
|
||||||
#if os(macOS)
|
#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
|
public typealias PlatformImage = NSImage
|
||||||
#else
|
#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
|
public typealias PlatformImage = UIImage
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if os(macOS)
|
#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
|
public typealias PlatformView = NSView
|
||||||
#endif
|
#endif
|
||||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
#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
|
public typealias PlatformView = UIView
|
||||||
#endif
|
#endif
|
||||||
#if os(watchOS)
|
#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
|
public typealias PlatformView = WKInterfaceObject
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if os(macOS)
|
#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
|
public typealias PlatformViewRepresentable = NSViewRepresentable
|
||||||
#endif
|
#endif
|
||||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
#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
|
public typealias PlatformViewRepresentable = UIViewRepresentable
|
||||||
#endif
|
#endif
|
||||||
#if os(watchOS)
|
#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
|
public typealias PlatformViewRepresentable = WKInterfaceObjectRepresentable
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if os(macOS)
|
#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 {
|
extension NSViewRepresentable {
|
||||||
typealias PlatformViewType = NSViewType
|
typealias PlatformViewType = NSViewType
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if os(iOS) || os(tvOS) || os(visionOS)
|
#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 {
|
extension UIViewRepresentable {
|
||||||
typealias PlatformViewType = UIViewType
|
typealias PlatformViewType = UIViewType
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if os(watchOS)
|
#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 {
|
extension WKInterfaceObjectRepresentable {
|
||||||
typealias PlatformViewType = WKInterfaceObjectType
|
typealias PlatformViewType = WKInterfaceObjectType
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import SwiftUI
|
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 {
|
extension AnyTransition {
|
||||||
|
|
||||||
/// Fade-in transition
|
/// Fade-in transition
|
||||||
|
|
|
@ -47,7 +47,7 @@ public enum WebImagePhase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Data Binding Object, only properties in this object can support changes from user with @State and refresh
|
/// 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 WebImageModel : ObservableObject {
|
final class WebImageModel : ObservableObject {
|
||||||
/// URL image
|
/// URL image
|
||||||
@Published var url: URL?
|
@Published var url: URL?
|
||||||
|
@ -56,7 +56,7 @@ final class WebImageModel : ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Completion Handler Binding Object, supports dynamic @State changes
|
/// 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 WebImageHandler: ObservableObject {
|
final class WebImageHandler: ObservableObject {
|
||||||
// Completion Handler
|
// Completion Handler
|
||||||
@Published var successBlock: ((PlatformImage, Data?, SDImageCacheType) -> Void)?
|
@Published var successBlock: ((PlatformImage, Data?, SDImageCacheType) -> Void)?
|
||||||
|
@ -65,7 +65,7 @@ final class WebImageHandler: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration Binding Object, supports dynamic @State changes
|
/// 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 WebImageConfiguration: ObservableObject {
|
final class WebImageConfiguration: ObservableObject {
|
||||||
var retryOnAppear: Bool = true
|
var retryOnAppear: Bool = true
|
||||||
var cancelOnDisappear: Bool = true
|
var cancelOnDisappear: Bool = true
|
||||||
|
@ -79,7 +79,7 @@ final class WebImageConfiguration: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Image View type to load image from url. Supports static/animated image format.
|
/// A Image View type to load image from url. Supports static/animated 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 WebImage<Content> : View where Content: View {
|
public struct WebImage<Content> : View where Content: View {
|
||||||
var transaction: Transaction
|
var transaction: Transaction
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ public struct WebImage<Content> : View where Content: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layout
|
// 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 WebImage {
|
extension WebImage {
|
||||||
func configure(_ block: @escaping (Image) -> Image) -> WebImage {
|
func configure(_ block: @escaping (Image) -> Image) -> WebImage {
|
||||||
var result = self
|
var result = self
|
||||||
|
@ -382,7 +382,7 @@ extension WebImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Completion Handler
|
// 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 WebImage {
|
extension WebImage {
|
||||||
|
|
||||||
/// Provide the action when image load fails.
|
/// Provide the action when image load fails.
|
||||||
|
@ -414,7 +414,7 @@ extension WebImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebImage Modifier
|
// WebImage 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 WebImage {
|
extension WebImage {
|
||||||
/// Control the behavior to retry the failed loading when view become appears again
|
/// Control the behavior to retry the failed loading when view become appears again
|
||||||
/// - Parameter flag: Whether or not to retry the failed loading
|
/// - Parameter flag: Whether or not to retry the failed loading
|
||||||
|
@ -432,7 +432,7 @@ extension WebImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicator
|
// 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, *)
|
||||||
extension WebImage {
|
extension WebImage {
|
||||||
|
|
||||||
/// Associate a indicator when loading image with url
|
/// Associate a indicator when loading image with url
|
||||||
|
@ -449,7 +449,7 @@ extension WebImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animated Image
|
// Animated 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 WebImage {
|
extension WebImage {
|
||||||
|
|
||||||
/// Total loop count for animated image rendering. Defaults to nil.
|
/// Total loop count for animated image rendering. Defaults to nil.
|
||||||
|
@ -517,7 +517,7 @@ extension WebImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#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 WebImage_Previews : PreviewProvider {
|
struct WebImage_Previews : PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
|
|
Loading…
Reference in New Issue