Skip to content

Commit 92de407

Browse files
committed
Update the AnimatedImage API to expose the SDAnimatedImageView
This is not necessary to hide the details and use UIView super view
1 parent 6f693bb commit 92de407

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ final class AnimatedImageHandler: ObservableObject {
6666
@Published var failureBlock: ((Error) -> Void)?
6767
@Published var progressBlock: ((Int, Int) -> Void)?
6868
// Coordinator Handler
69-
@Published var viewCreateBlock: ((PlatformView, AnimatedImage.Context) -> Void)?
70-
@Published var viewUpdateBlock: ((PlatformView, AnimatedImage.Context) -> Void)?
69+
@Published var viewCreateBlock: ((SDAnimatedImageView, AnimatedImage.Context) -> Void)?
70+
@Published var viewUpdateBlock: ((SDAnimatedImageView, AnimatedImage.Context) -> Void)?
7171
}
7272

7373
/// Layout Binding Object, supports dynamic @State changes
@@ -109,7 +109,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
109109
/// A observed object to pass through the image manager loading status to indicator
110110
@ObservedObject var indicatorStatus = IndicatorStatus()
111111

112-
static var viewDestroyBlock: ((PlatformView, Coordinator) -> Void)?
112+
static var viewDestroyBlock: ((SDAnimatedImageView, Coordinator) -> Void)?
113113

114114
/// A Binding to control the animation. You can bind external logic to control the animation status.
115115
/// True to start animation, false to stop animation.
@@ -770,23 +770,23 @@ extension AnimatedImage {
770770
/// Provide the action when view representable create the native view.
771771
/// - Parameter action: The action to perform. The first arg is the native view. The seconds arg is the context.
772772
/// - Returns: A view that triggers `action` when view representable create the native view.
773-
public func onViewCreate(perform action: ((PlatformView, Context) -> Void)? = nil) -> AnimatedImage {
773+
public func onViewCreate(perform action: ((SDAnimatedImageView, Context) -> Void)? = nil) -> AnimatedImage {
774774
self.imageHandler.viewCreateBlock = action
775775
return self
776776
}
777777

778778
/// Provide the action when view representable update the native view.
779779
/// - Parameter action: The action to perform. The first arg is the native view. The seconds arg is the context.
780780
/// - Returns: A view that triggers `action` when view representable update the native view.
781-
public func onViewUpdate(perform action: ((PlatformView, Context) -> Void)? = nil) -> AnimatedImage {
781+
public func onViewUpdate(perform action: ((SDAnimatedImageView, Context) -> Void)? = nil) -> AnimatedImage {
782782
self.imageHandler.viewUpdateBlock = action
783783
return self
784784
}
785785

786786
/// Provide the action when view representable destroy the native view
787787
/// - Parameter action: The action to perform. The first arg is the native view. The seconds arg is the coordinator (with userInfo).
788788
/// - Returns: A view that triggers `action` when view representable destroy the native view.
789-
public static func onViewDestroy(perform action: ((PlatformView, Coordinator) -> Void)? = nil) {
789+
public static func onViewDestroy(perform action: ((SDAnimatedImageView, Coordinator) -> Void)? = nil) {
790790
self.viewDestroyBlock = action
791791
}
792792
}

SDWebImageSwiftUI/Classes/ImageViewWrapper.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import SDWebImage
1414
/// Use wrapper to solve tne `UIImageView`/`NSImageView` frame size become image size issue (SwiftUI's Bug)
1515
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
1616
public class AnimatedImageViewWrapper : PlatformView {
17-
var wrapped = SDAnimatedImageView()
17+
/// The wrapped actual image view, using SDWebImage's aniamted image view
18+
public var wrapped = SDAnimatedImageView()
1819
var interpolationQuality = CGInterpolationQuality.default
1920
var shouldAntialias = false
2021
var resizable = false

0 commit comments

Comments
 (0)