Merge pull request #49 from SDWebImage/improve_empty_view

Little improvement to WebImage to use EmptyView instead of EmptyImage when no placeholder available
This commit is contained in:
DreamPiggy 2019-11-10 18:32:25 +08:00 committed by GitHub
commit 5985e0119e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 11 deletions

View File

@ -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

View File

@ -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
@ -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
}

View File

@ -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]?
@ -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)

View File

@ -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;
@ -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>