Skip to content

Commit ba0f350

Browse files
authored
Merge pull request #73 from SDWebImage/bugfix_revert_empty_view
Revert the EmptyView usage when WebImage does not have placeholder
2 parents 67a5ae9 + f1fabb7 commit ba0f350

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ public struct AnimatedImage : PlatformViewRepresentable {
400400
// IncrementalLoad
401401
if let incrementalLoad = imageConfiguration.incrementalLoad {
402402
view.wrapped.shouldIncrementalLoad = incrementalLoad
403+
} else {
404+
view.wrapped.shouldIncrementalLoad = true
403405
}
404406

405407
// MaxBufferSize

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import SDWebImage
1212
/// A Image View type to load image from url. Supports static/animated image format.
1313
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
1414
public struct WebImage : View {
15+
static var emptyImage = PlatformImage()
1516
var configurations: [(Image) -> Image] = []
1617

1718
var placeholder: AnyView?
@@ -68,7 +69,11 @@ public struct WebImage : View {
6869
if placeholder != nil {
6970
placeholder
7071
} else {
71-
EmptyView()
72+
// Should not use `EmptyView`, which does not respect to the container's frame modifier
73+
// Using a empty image instead for better compatible
74+
configurations.reduce(Image(platformImage: WebImage.emptyImage)) { (previous, configuration) in
75+
configuration(previous)
76+
}
7277
}
7378
}
7479
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)

0 commit comments

Comments
 (0)