Skip to content

Commit 8441718

Browse files
committed
Merge branch 'master' of https://github.com/SDWebImage/SDWebImageSwiftUI into feature_watchOS_animation
# Conflicts: # SDWebImageSwiftUI/Classes/AnimatedImage.swift
2 parents 4736821 + f056456 commit 8441718

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ var body: some View {
107107

108108
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.
109109

110+
Note: `AnimatedImage` does not support watchOS currently. Because there are no Public API to implement it via `WKInterfaceObjectRepresentable` or `SwiftUI.Image`. We need Apple to provide a better solution. But if you're really interested in this, checkout [feature_watchOS_animation](https://github.com/SDWebImage/SDWebImageSwiftUI/tree/feature_watchOS_animation) branch, which using some super hack to support animated image on watchOS.
111+
110112
## Demo
111113

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

SDWebImageSwiftUI.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'SDWebImageSwiftUI'
11-
s.version = '0.3.2'
11+
s.version = '0.3.3'
1212
s.summary = 'Integration of SDWebImage Asynchronous image loading and SwiftUI framework'
1313

1414
s.description = <<-DESC

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public struct AnimatedImage : PlatformViewRepresentable {
129129
public func updateNSView(_ nsView: AnimatedImageViewWrapper, context: NSViewRepresentableContext<AnimatedImage>) {
130130
updateView(nsView, context: context)
131131
}
132+
133+
public static func dismantleNSView(_ nsView: AnimatedImageViewWrapper, coordinator: ()) {
134+
dismantleView(nsView, coordinator: coordinator)
135+
}
132136
#elseif os(iOS) || os(tvOS)
133137
public func makeUIView(context: UIViewRepresentableContext<AnimatedImage>) -> AnimatedImageViewWrapper {
134138
makeView(context: context)
@@ -137,6 +141,10 @@ public struct AnimatedImage : PlatformViewRepresentable {
137141
public func updateUIView(_ uiView: AnimatedImageViewWrapper, context: UIViewRepresentableContext<AnimatedImage>) {
138142
updateView(uiView, context: context)
139143
}
144+
145+
public static func dismantleUIView(_ uiView: AnimatedImageViewWrapper, coordinator: ()) {
146+
dismantleView(uiView, coordinator: coordinator)
147+
}
140148
#endif
141149

142150
#if os(watchOS)
@@ -220,6 +228,14 @@ public struct AnimatedImage : PlatformViewRepresentable {
220228
layoutView(view, context: context)
221229
}
222230

231+
static func dismantleView(_ view: AnimatedImageViewWrapper, coordinator: ()) {
232+
#if os(macOS)
233+
view.wrapped.animates = false
234+
#else
235+
view.wrapped.stopAnimating()
236+
#endif
237+
}
238+
223239
func layoutView(_ view: AnimatedImageViewWrapper, context: PlatformViewRepresentableContext<AnimatedImage>) {
224240
// AspectRatio
225241
if let _ = imageLayout.aspectRatio {

SDWebImageSwiftUI/Module/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.3.2</string>
18+
<string>0.3.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
</dict>

0 commit comments

Comments
 (0)