Skip to content

Commit 5985e01

Browse files
authored
Merge pull request #49 from SDWebImage/improve_empty_view
Little improvement to WebImage to use EmptyView instead of EmptyImage when no placeholder available
2 parents 0b59086 + bbdcd8d commit 5985e01

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

Example/SDWebImageSwiftUIDemo/ContentView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct ContentView: View {
3131
"https://nokiatech.github.io/heif/content/image_sequences/starfield_animation.heic",
3232
"https://www.sample-videos.com/img/Sample-png-image-1mb.png",
3333
"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
34+
"https://raw.githubusercontent.com/ibireme/YYImage/master/Demo/YYImageDemo/mew_baseline.jpg",
3435
"http://via.placeholder.com/200x200.jpg"]
3536
@State var animated: Bool = false // You can change between WebImage/AnimatedImage
3637

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let package = Package(
7878
### Using `WebImage` to load network image
7979

8080
- [x] Supports placeholder and detail options control for image loading as SDWebImage
81-
- [x] Supports progressive image loading
81+
- [x] Supports progressive image loading (like baseline)
8282
- [x] Supports success/failure/progress changes event for custom handling
8383
- [x] Supports indicator with activity/progress indicator and customization
8484
- [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
108108
### Using `AnimatedImage` to play animation
109109

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

117117
```swift
118118
var body: some View {
119119
Group {
120120
// Network
121-
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"))
121+
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"), options: [.progressiveLoad]) // Progressive Load
122122
.onFailure { error in
123123
// Error
124124
}

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import SwiftUI
1010
import SDWebImage
1111

1212
public struct WebImage : View {
13-
static var emptyImage = PlatformImage()
14-
1513
var url: URL?
1614
var options: SDWebImageOptions
1715
var context: [SDWebImageContextOption : Any]?
@@ -49,7 +47,7 @@ public struct WebImage : View {
4947
if placeholder != nil {
5048
placeholder
5149
} else {
52-
Image(platformImage: WebImage.emptyImage)
50+
EmptyView()
5351
}
5452
}
5553
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)

SDWebImageSwiftUI/Module/SDWebImageSwiftUI.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
*/
88

99
#import <Foundation/Foundation.h>
10-
#import <SDWebImageSwiftUI/SDAnimatedImageInterface.h>
11-
#import <SDWebImageSwiftUI/SDAnimatedImageInterfaceWrapper.h>
1210

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

1917
// In this header, you should import all the public headers of your framework using statements like #import <SDWebImageSwiftUI/PublicHeader.h>
20-
21-
18+
#import <SDWebImageSwiftUI/SDAnimatedImageInterface.h>
19+
#import <SDWebImageSwiftUI/SDAnimatedImageInterfaceWrapper.h>

0 commit comments

Comments
 (0)