Skip to content

Commit 896627d

Browse files
committed
Update the readme with indicator and transition
1 parent 5bcdaf6 commit 896627d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Example/SDWebImageSwiftUIDemo/ContentView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct ContentView: View {
102102
.resizable()
103103
.scaledToFit()
104104
.frame(width: CGFloat(100), height: CGFloat(100), alignment: .center)
105+
.animation(.easeInOut(duration: 0.5))
106+
.transition(.opacity)
105107
#else
106108
WebImage(url: URL(string:url))
107109
.resizable()

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,21 @@ let package = Package(
6161

6262
### Using `WebImage` to load network image
6363

64-
- [x] Supports the placeholder and detail options control for image loading as SDWebImage.
65-
- [x] Supports the success/failure/progress changes event for custom handling.
64+
- [x] Supports the placeholder and detail options control for image loading as SDWebImage
65+
- [x] Supports the success/failure/progress changes event for custom handling
66+
- [x] Supports the indicator with activity/progress indicator and customization
6667

67-
Note: Unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animation. This `WebImage` using `Image` for internal implementation and supports static image format only.
68+
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.
6869

6970
```swift
7071
var body: some View {
7172
WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
7273
.onSuccess { image, cacheType in
7374
// Success
7475
}
76+
.indicator { isAnimating, _ in
77+
ActivityIndicator(isAnimating) // Activity Indicator
78+
}
7579
.resizable()
7680
.scaledToFit()
7781
.frame(width: 300, height: 300, alignment: .center)
@@ -88,6 +92,7 @@ var body: some View {
8892
.onFailure { error in
8993
// Error
9094
}
95+
.transition(.fade) // Fade Transition
9196
.scaledToFit()
9297
// Data
9398
AnimatedImage(data: try! Data(contentsOf: URL(fileURLWithPath: "/tmp/foo.webp")))
@@ -101,9 +106,10 @@ var body: some View {
101106

102107
- [x] Supports network image as well as local data and bundle image
103108
- [x] Supports animation control using the SwiftUI Binding
104-
- [x] Supports advanced control like loop count, incremental load, buffer size.
109+
- [x] Supports indicator and transition powered by SDWebImage and CoreAnimation
110+
- [x] Supports advanced control like loop count, incremental load, buffer size
105111

106-
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.
112+
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, if you need advanced customized layout and animation, you need CoreAnimation to help.
107113

108114
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.
109115

0 commit comments

Comments
 (0)