@@ -172,6 +172,24 @@ public struct AnimatedImage : PlatformViewRepresentable {
172
172
}
173
173
#endif
174
174
175
+ func loadImage( _ view: AnimatedImageViewWrapper , url: URL ) {
176
+ let operationKey = NSStringFromClass ( type ( of: view. wrapped) )
177
+ let currentOperation = view. wrapped. sd_imageLoadOperation ( forKey: operationKey)
178
+ if currentOperation != nil {
179
+ return
180
+ }
181
+ view. wrapped. sd_setImage ( with: url, placeholderImage: placeholder, options: webOptions, context: webContext, progress: { ( receivedSize, expectedSize, _) in
182
+ self . imageModel. progressBlock ? ( receivedSize, expectedSize)
183
+ } ) { ( image, error, cacheType, _) in
184
+ if let image = image {
185
+ self . imageModel. image = image
186
+ self . imageModel. successBlock ? ( image, cacheType)
187
+ } else {
188
+ self . imageModel. failureBlock ? ( error ?? NSError ( ) )
189
+ }
190
+ }
191
+ }
192
+
175
193
func makeView( context: PlatformViewRepresentableContext < AnimatedImage > ) -> AnimatedImageViewWrapper {
176
194
AnimatedImageViewWrapper ( )
177
195
}
@@ -185,16 +203,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
185
203
#endif
186
204
} else {
187
205
if let url = url {
188
- view. wrapped. sd_setImage ( with: url, placeholderImage: placeholder, options: webOptions, context: webContext, progress: { ( receivedSize, expectedSize, _) in
189
- self . imageModel. progressBlock ? ( receivedSize, expectedSize)
190
- } ) { ( image, error, cacheType, _) in
191
- self . imageModel. image = image
192
- if let image = image {
193
- self . imageModel. successBlock ? ( image, cacheType)
194
- } else {
195
- self . imageModel. failureBlock ? ( error ?? NSError ( ) )
196
- }
197
- }
206
+ loadImage ( view, url: url)
198
207
}
199
208
}
200
209
0 commit comments