Skip to content

Revert the EmptyView usage when WebImage does not have placeholder #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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