Skip to content

Commit ee7445a

Browse files
committed
Update the readme with more structure, add one Which View to choose chapter
1 parent 3994022 commit ee7445a

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PODS:
1111
- SDWebImage (5.2.5):
1212
- SDWebImage/Core (= 5.2.5)
1313
- SDWebImage/Core (5.2.5)
14-
- SDWebImageSwiftUI (0.5.2):
14+
- SDWebImageSwiftUI (0.6.2):
1515
- SDWebImage (~> 5.1)
1616
- SDWebImageWebPCoder (0.2.5):
1717
- libwebp (~> 1.0)
@@ -34,7 +34,7 @@ EXTERNAL SOURCES:
3434
SPEC CHECKSUMS:
3535
libwebp: 057912d6d0abfb6357d8bb05c0ea470301f5d61e
3636
SDWebImage: 4eabf2fa6695c95c47724214417a9c036c965e4a
37-
SDWebImageSwiftUI: 3a3e3aa707aeedf024af6f9c718177f681edf9de
37+
SDWebImageSwiftUI: 26a485e004cd64f5dde194bd97882aba962ab5b0
3838
SDWebImageWebPCoder: 947093edd1349d820c40afbd9f42acb6cdecd987
3939

4040
PODFILE CHECKSUM: 3fb06a5173225e197f3a4bf2be7e5586a693257a

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ SDWebImageSwiftUI is a SwiftUI image loading framework, which based on [SDWebIma
1313

1414
It brings all your favorite features from SDWebImage, like async image loading, memory/disk caching, animated image playback and performances.
1515

16+
Since it based on SDWebImage, you can get all benefits from the existing community. You can have massive image format support (GIF/APNG/WebP/HEICS/AVIF...) via [Coder Plugins](https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List), PhotoKit support via [SDWebImagePhotosPlugin](https://github.com/SDWebImage/SDWebImagePhotosPlugin), Firebase integration via [FirebaseUI](https://github.com/firebase/FirebaseUI-iOS), etc.
17+
1618
Besides all these features, we do optimization for SwiftUI, like Binding, View Modifier, using the same design pattern to become a good SwiftUI citizen.
1719

1820
Note we do not guarantee the public API stable for current status until v1.0 version. Since SwiftUI is a new platform for us. This framework is under development, feature requests, contributions, and GitHub stars are welcomed.
@@ -66,8 +68,6 @@ let package = Package(
6668
- [x] Supports indicator with activity/progress indicator and customization
6769
- [x] Supports built-in animation and transition, powered by SwiftUI
6870

69-
Note: This `WebImage` using `Image` for internal implementation, which is the best compatible for SwiftUI layout and animation system. But it supports static image format only, because unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animation.
70-
7171
```swift
7272
var body: some View {
7373
WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
@@ -83,8 +83,16 @@ var body: some View {
8383
}
8484
```
8585

86+
Note: This `WebImage` using `Image` for internal implementation, which is the best compatible for SwiftUI layout and animation system. But it supports static image format only, because unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animation.
87+
8688
### Using `AnimatedImage` to play animation
8789

90+
- [x] Supports network image as well as local data and bundle image
91+
- [x] Supports animation control using the SwiftUI Binding
92+
- [x] Supports indicator and transition, powered by SDWebImage and Core Animation
93+
- [x] Supports advanced control like loop count, incremental load, buffer size
94+
- [x] Supports coordinate with native UIKit/AppKit/WatchKit view
95+
8896
```swift
8997
var body: some View {
9098
Group {
@@ -107,16 +115,20 @@ var body: some View {
107115
}
108116
```
109117

110-
- [x] Supports network image as well as local data and bundle image
111-
- [x] Supports animation control using the SwiftUI Binding
112-
- [x] Supports indicator and transition, powered by SDWebImage and Core Animation
113-
- [x] Supports advanced control like loop count, incremental load, buffer size
114-
- [x] Supports coordinate with native UIKit/AppKit/WatchKit view
115-
116118
Note: `AnimatedImage` supports both image url or image data for animated image format. Which use the SDWebImage's [Animated ImageView](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#animated-image-50) for internal implementation. Pay attention that since this base on UIKit/AppKit representable, some advanced SwiftUI layout and animation system may not work as expected. You may need UIKit/AppKit and Core Animation to modify the native view.
117119

118120
Note: From v0.4.0, `AnimatedImage` supports watchOS as well. However, it's not backed by SDWebImage's [Animated ImageView](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#animated-image-50) like iOS/tvOS/macOS. It use some tricks and hacks because of the limitation on current Apple's API. It also use Image/IO decoding system, which means it supports GIF and APNG format only, but not external format like WebP.
119121

122+
## Which View to choose
123+
124+
Why we have two different View types here, is because of current SwiftUI limitation, and we want to beyond that, to provide best solution for both usage.
125+
126+
If you don't need animated image, prefer to use `WebImage` firstly. Which behaves the seamless as built-in SwiftUI View. It SwiftUI works, it works.
127+
128+
If you need animated image, `AnimatedImage` is the only one to choose. Remember it supports static image as well, you don't need to check the url format, just use as it.
129+
130+
But, because `AnimatedImage` use `UIViewRepresentable` and driven by UIKit, currently there may be some small incompatible issues between UIKit and SwiftUI layout and animation system. We try our best to match SwiftUI behavior, and provide the same API as `WebImage`, which make it easy to switch between these two types.
131+
120132
## Demo
121133

122134
To run the example using SwiftUI, following the steps:

0 commit comments

Comments
 (0)