Skip to content

Little improvement to WebImage to use EmptyView instead of EmptyImage when no placeholder available #49

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
Nov 10, 2019
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
1 change: 1 addition & 0 deletions Example/SDWebImageSwiftUIDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct ContentView: View {
"https://nokiatech.github.io/heif/content/image_sequences/starfield_animation.heic",
"https://www.sample-videos.com/img/Sample-png-image-1mb.png",
"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
"https://raw.githubusercontent.com/ibireme/YYImage/master/Demo/YYImageDemo/mew_baseline.jpg",
"http://via.placeholder.com/200x200.jpg"]
@State var animated: Bool = false // You can change between WebImage/AnimatedImage

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let package = Package(
### Using `WebImage` to load network image

- [x] Supports placeholder and detail options control for image loading as SDWebImage
- [x] Supports progressive image loading
- [x] Supports progressive image loading (like baseline)
- [x] Supports success/failure/progress changes event for custom handling
- [x] Supports indicator with activity/progress indicator and customization
- [x] Supports built-in animation and transition, powered by SwiftUI
Expand Down Expand Up @@ -108,17 +108,17 @@ Note: This `WebImage` using `Image` for internal implementation, which is the be
### Using `AnimatedImage` to play animation

- [x] Supports network image as well as local data and bundle image
- [x] Supports animated progressive image loading
- [x] Supports animated progressive image loading (like web browser)
- [x] Supports animation control using the SwiftUI Binding
- [x] Supports indicator and transition, powered by SDWebImage and Core Animation
- [x] Supports advanced control like loop count, incremental load, buffer size
- [x] Supports advanced control like loop count, playback rate, buffer size, runloop mode, etc
- [x] Supports coordinate with native UIKit/AppKit/WatchKit view

```swift
var body: some View {
Group {
// Network
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"))
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"), options: [.progressiveLoad]) // Progressive Load
.onFailure { error in
// Error
}
Expand Down
4 changes: 1 addition & 3 deletions SDWebImageSwiftUI/Classes/WebImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import SwiftUI
import SDWebImage

public struct WebImage : View {
static var emptyImage = PlatformImage()

var url: URL?
var options: SDWebImageOptions
var context: [SDWebImageContextOption : Any]?
Expand Down Expand Up @@ -49,7 +47,7 @@ public struct WebImage : View {
if placeholder != nil {
placeholder
} else {
Image(platformImage: WebImage.emptyImage)
EmptyView()
}
}
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
Expand Down
6 changes: 2 additions & 4 deletions SDWebImageSwiftUI/Module/SDWebImageSwiftUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/

#import <Foundation/Foundation.h>
#import <SDWebImageSwiftUI/SDAnimatedImageInterface.h>
#import <SDWebImageSwiftUI/SDAnimatedImageInterfaceWrapper.h>

//! Project version number for SDWebImageSwiftUI.
FOUNDATION_EXPORT double SDWebImageSwiftUIVersionNumber;
Expand All @@ -17,5 +15,5 @@ FOUNDATION_EXPORT double SDWebImageSwiftUIVersionNumber;
FOUNDATION_EXPORT const unsigned char SDWebImageSwiftUIVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <SDWebImageSwiftUI/PublicHeader.h>


#import <SDWebImageSwiftUI/SDAnimatedImageInterface.h>
#import <SDWebImageSwiftUI/SDAnimatedImageInterfaceWrapper.h>