Skip to content

Commit 8192aec

Browse files
committed
Remove the unused HostingView hack
1 parent 2b2ee4f commit 8192aec

File tree

2 files changed

+0
-29
lines changed

2 files changed

+0
-29
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,6 @@ public struct AnimatedImage : PlatformViewRepresentable {
261261
}
262262
self.imageHandler.progressBlock?(receivedSize, expectedSize)
263263
}) { (image, data, error, cacheType, finished, _) in
264-
if #available(iOS 14.0, macOS 11.0, watchOS 7.0, tvOS 14.0, *) {
265-
// Do nothing. on iOS 14's SwiftUI, the @Published will always trigger another `updateUIView` call with new UIView instance.
266-
} else {
267-
// This is a hack because of iOS 13's SwiftUI bug, the @Published does not trigger another `updateUIView` call
268-
// Here I have to use UIKit/AppKit API to triger the same effect (the window change implicitly cause re-render)
269-
if let hostingView = view.findHostingView() {
270-
if let _ = hostingView.window {
271-
#if os(macOS)
272-
hostingView.viewDidMoveToWindow()
273-
#else
274-
hostingView.didMoveToWindow()
275-
#endif
276-
}
277-
}
278-
}
279264
context.coordinator.imageLoading.image = image
280265
context.coordinator.imageLoading.isLoading = false
281266
context.coordinator.imageLoading.progress = 1

SDWebImageSwiftUI/Classes/ImageViewWrapper.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,6 @@ extension PlatformView {
8282
self.leadingAnchor.constraint(equalTo: superview.leadingAnchor, constant: 0).isActive = true
8383
self.trailingAnchor.constraint(equalTo: superview.trailingAnchor, constant: 0).isActive = true
8484
}
85-
86-
/// Finding the HostingView for UIKit/AppKit View.
87-
/// - Parameter entry: The entry platform view
88-
/// - Returns: The hosting view.
89-
func findHostingView() -> PlatformView? {
90-
var superview = self.superview
91-
while let s = superview {
92-
if NSStringFromClass(type(of: s)).contains("HostingView") {
93-
return s
94-
}
95-
superview = s.superview
96-
}
97-
return nil
98-
}
9985
}
10086

10187
#endif

0 commit comments

Comments
 (0)