Skip to content

Commit 59634bf

Browse files
committed
Update the readme about the options and context usage, like delayPlaceholder
1 parent 80e3137 commit 59634bf

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

README.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,21 @@ let package = Package(
110110
```swift
111111
var body: some View {
112112
WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
113-
.onSuccess { image, cacheType in
114-
// Success
115-
}
116-
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
117-
.placeholder(Image(systemName: "photo")) // Placeholder Image
118-
// Supports ViewBuilder as well
119-
.placeholder {
120-
Rectangle().foregroundColor(.gray)
121-
}
122-
.indicator(.activity) // Activity Indicator
123-
.animation(.easeInOut(duration: 0.5)) // Animation Duration
124-
.transition(.fade) // Fade Transition
125-
.scaledToFit()
126-
.frame(width: 300, height: 300, alignment: .center)
113+
// Supports options and context, like `.delayPlaceholder` to show placeholder only when error
114+
.onSuccess { image, cacheType in
115+
// Success
116+
}
117+
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
118+
.placeholder(Image(systemName: "photo")) // Placeholder Image
119+
// Supports ViewBuilder as well
120+
.placeholder {
121+
Rectangle().foregroundColor(.gray)
122+
}
123+
.indicator(.activity) // Activity Indicator
124+
.animation(.easeInOut(duration: 0.5)) // Animation Duration
125+
.transition(.fade) // Fade Transition
126+
.scaledToFit()
127+
.frame(width: 300, height: 300, alignment: .center)
127128
}
128129
```
129130

@@ -155,8 +156,8 @@ var body: some View {
155156
```swift
156157
var body: some View {
157158
Group {
158-
// Network
159-
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"), options: [.progressiveLoad]) // Progressive Load
159+
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"))
160+
// Supports options and context, like `.progressiveLoad` for progressive animation loading
160161
.onFailure { error in
161162
// Error
162163
}
@@ -187,11 +188,13 @@ Note: `AnimatedImage` supports both image url or image data for animated image f
187188
Note: `AnimatedImage` some methods like `.transition`, `.indicator` and `.aspectRatio` have the same naming as `SwiftUI.View` protocol methods. But the args receive the different type. This is because `AnimatedImage` supports to be used with UIKit/AppKit component and animation. If you find ambiguity, use full type declaration instead of the dot expression syntax.
188189

189190
```swift
190-
AnimatedImage(name: "animation2") // Just for showcase, don't mix them at the same time
191-
.indicator(SDWebImageProgressIndicator.default) // UIKit indicator component
192-
.indicator(Indicator.progress) // SwiftUI indicator component
193-
.transition(SDWebImageTransition.flipFromLeft) // UIKit animation transition
194-
.transition(AnyTransition.flipFromLeft) // SwiftUI animation transition
191+
var body: some View {
192+
AnimatedImage(name: "animation2") // Just for showcase, don't mix them at the same time
193+
.indicator(SDWebImageProgressIndicator.default) // UIKit indicator component
194+
.indicator(Indicator.progress) // SwiftUI indicator component
195+
.transition(SDWebImageTransition.flipFromLeft) // UIKit animation transition
196+
.transition(AnyTransition.flipFromLeft) // SwiftUI animation transition
197+
}
195198
```
196199

197200
### Which View to choose

0 commit comments

Comments
 (0)