Skip to content

Commit

Permalink
Merge pull request #73 from SDWebImage/bugfix_revert_empty_view
Browse files Browse the repository at this point in the history
Revert the EmptyView usage when WebImage does not have placeholder
  • Loading branch information
dreampiggy authored Jan 26, 2020
2 parents 67a5ae9 + f1fabb7 commit ba0f350
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions SDWebImageSwiftUI/Classes/AnimatedImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ public struct AnimatedImage : PlatformViewRepresentable {
// IncrementalLoad
if let incrementalLoad = imageConfiguration.incrementalLoad {
view.wrapped.shouldIncrementalLoad = incrementalLoad
} else {
view.wrapped.shouldIncrementalLoad = true
}

// MaxBufferSize
Expand Down
7 changes: 6 additions & 1 deletion SDWebImageSwiftUI/Classes/WebImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SDWebImage
/// A Image View type to load image from url. Supports static/animated image format.
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
public struct WebImage : View {
static var emptyImage = PlatformImage()
var configurations: [(Image) -> Image] = []

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

0 comments on commit ba0f350

Please sign in to comment.