Skip to content

Commit eb6c7f1

Browse files
committed
Update the test cases and readme about AnimatedImage
1 parent f2f51de commit eb6c7f1

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ var body: some View {
180180
AnimatedImage(name: "animation1", isAnimating: $isAnimating)) // Animation control binding
181181
.maxBufferSize(.max)
182182
.onViewUpdate { view, context in // Advanced native view coordinate
183+
// AppKit Tool Tip
183184
view.toolTip = "Mouseover Tip"
185+
// UIKit advanced content mode
186+
view.contentMode = .topLeft
187+
// Coordinator, used for Cocoa Binding or Delegate method
184188
let coordinator = context.coordinator
185189
}
186190
}
@@ -191,6 +195,8 @@ Note: `AnimatedImage` supports both image url or image data for animated image f
191195

192196
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.
193197

198+
Note: some of methods on `AnimatedImage` will return `some View`, a new Modified Content. You'll lose the type related modifier method. For this case, you can either reorder the method call, or use Native View in `.onViewUpdate` for rescue.
199+
194200
```swift
195201
var body: some View {
196202
AnimatedImage(name: "animation2") // Just for showcase, don't mix them at the same time

Tests/AnimatedImageTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ class AnimatedImageTests: XCTestCase {
163163
XCTAssertEqual(context.coordinator.userInfo?["foo"] as? String, "bar")
164164
}
165165
.placeholder(PlatformImage())
166+
.placeholder {
167+
Circle()
168+
}
166169
.indicator(SDWebImageActivityIndicator.medium)
167170
// Image
168171
.resizable()

Tests/WebImageTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class WebImageTests: XCTestCase {
8282
.onProgress { _, _ in
8383

8484
}
85+
.placeholder(.init(platformImage: PlatformImage()))
8586
.placeholder {
8687
Circle()
8788
}

0 commit comments

Comments
 (0)