From 1e1ddccc1a4498e53e0107a37fc2a5da9713f259 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 5 Apr 2020 14:22:32 +0800 Subject: [PATCH] Update the test cases and readme about AnimatedImage --- README.md | 6 ++++++ Tests/AnimatedImageTests.swift | 3 +++ Tests/WebImageTests.swift | 1 + 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 099588d..51f5e08 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,11 @@ var body: some View { AnimatedImage(name: "animation1", isAnimating: $isAnimating)) // Animation control binding .maxBufferSize(.max) .onViewUpdate { view, context in // Advanced native view coordinate + // AppKit tooltip for mouse hover view.toolTip = "Mouseover Tip" + // UIKit advanced content mode + view.contentMode = .topLeft + // Coordinator, used for Cocoa Binding or Delegate method let coordinator = context.coordinator } } @@ -191,6 +195,8 @@ Note: `AnimatedImage` supports both image url or image data for animated image f 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. +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. + ```swift var body: some View { AnimatedImage(name: "animation2") // Just for showcase, don't mix them at the same time diff --git a/Tests/AnimatedImageTests.swift b/Tests/AnimatedImageTests.swift index d0664f0..3b27f57 100644 --- a/Tests/AnimatedImageTests.swift +++ b/Tests/AnimatedImageTests.swift @@ -163,6 +163,9 @@ class AnimatedImageTests: XCTestCase { XCTAssertEqual(context.coordinator.userInfo?["foo"] as? String, "bar") } .placeholder(PlatformImage()) + .placeholder { + Circle() + } .indicator(SDWebImageActivityIndicator.medium) // Image .resizable() diff --git a/Tests/WebImageTests.swift b/Tests/WebImageTests.swift index 3a4c6e1..8be68fb 100644 --- a/Tests/WebImageTests.swift +++ b/Tests/WebImageTests.swift @@ -82,6 +82,7 @@ class WebImageTests: XCTestCase { .onProgress { _, _ in } + .placeholder(.init(platformImage: PlatformImage())) .placeholder { Circle() }