@@ -218,26 +218,29 @@ public struct AnimatedImage : PlatformViewRepresentable {
218
218
updateView ( uiView, context: context)
219
219
}
220
220
221
+ // public func sizeThatFits(_ proposal: ProposedViewSize, uiView: AnimatedImageViewWrapper, context: Context) -> CGSize? {}
222
+ // func _overrideSizeThatFits(_ size: inout CGSize, in proposedSize: _ProposedSize, uiView: UIViewType) {}
223
+
221
224
public static func dismantleUIView( _ uiView: AnimatedImageViewWrapper , coordinator: Coordinator ) {
222
225
dismantleView ( uiView, coordinator: coordinator)
223
226
}
224
227
#endif
225
228
226
229
func setupIndicator( _ view: AnimatedImageViewWrapper , context: Context ) {
227
- view. wrapped . sd_imageIndicator = imageConfiguration. indicator
228
- view. wrapped . sd_imageTransition = imageConfiguration. transition
230
+ view. sd_imageIndicator = imageConfiguration. indicator
231
+ view. sd_imageTransition = imageConfiguration. transition
229
232
if let placeholderView = imageModel. placeholderView {
230
233
placeholderView. removeFromSuperview ( )
231
234
placeholderView. isHidden = true
232
235
// Placeholder View should below the Indicator View
233
236
if let indicatorView = imageConfiguration. indicator? . indicatorView {
234
237
#if os(macOS)
235
- view. wrapped . addSubview ( placeholderView, positioned: . below, relativeTo: indicatorView)
238
+ view. addSubview ( placeholderView, positioned: . below, relativeTo: indicatorView)
236
239
#else
237
- view. wrapped . insertSubview ( placeholderView, belowSubview: indicatorView)
240
+ view. insertSubview ( placeholderView, belowSubview: indicatorView)
238
241
#endif
239
242
} else {
240
- view. wrapped . addSubview ( placeholderView)
243
+ view. addSubview ( placeholderView)
241
244
}
242
245
placeholderView. bindFrameToSuperviewBounds ( )
243
246
}
@@ -253,7 +256,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
253
256
}
254
257
var webContext = imageModel. webContext ?? [ : ]
255
258
webContext [ . animatedImageClass] = SDAnimatedImage . self
256
- view. wrapped . sd_internalSetImage ( with: imageModel. url, placeholderImage: imageModel. placeholderImage, options: webOptions, context: webContext, setImageBlock: nil , progress: { ( receivedSize, expectedSize, _) in
259
+ view. sd_internalSetImage ( with: imageModel. url, placeholderImage: imageModel. placeholderImage, options: webOptions, context: webContext, setImageBlock: nil , progress: { ( receivedSize, expectedSize, _) in
257
260
let progress : Double
258
261
if ( expectedSize > 0 ) {
259
262
progress = Double ( receivedSize) / Double( expectedSize)
@@ -276,14 +279,14 @@ public struct AnimatedImage : PlatformViewRepresentable {
276
279
self . imageHandler. failureBlock ? ( error ?? NSError ( ) )
277
280
}
278
281
// Finished loading, async
279
- finishUpdateView ( view, context: context, image : image )
282
+ finishUpdateView ( view, context: context)
280
283
}
281
284
}
282
285
283
286
func makeView( context: Context ) -> AnimatedImageViewWrapper {
284
287
let view = AnimatedImageViewWrapper ( )
285
288
if let viewCreateBlock = imageHandler. viewCreateBlock {
286
- viewCreateBlock ( view. wrapped , context)
289
+ viewCreateBlock ( view, context)
287
290
}
288
291
return view
289
292
}
@@ -308,7 +311,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
308
311
}
309
312
#endif
310
313
context. coordinator. imageLoading. imageName = name
311
- view. wrapped . image = image
314
+ view. image = image
312
315
}
313
316
314
317
private func updateViewForData( _ data: Data ? , view: AnimatedImageViewWrapper , context: Context ) {
@@ -321,7 +324,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
321
324
image = PlatformImage . sd_image ( with: data, scale: imageModel. scale)
322
325
}
323
326
context. coordinator. imageLoading. imageData = data
324
- view. wrapped . image = image
327
+ view. image = image
325
328
}
326
329
327
330
private func updateViewForURL( _ url: URL ? , view: AnimatedImageViewWrapper , context: Context ) {
@@ -337,7 +340,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
337
340
shouldLoad = false
338
341
} else if let image = context. coordinator. imageLoading. image {
339
342
shouldLoad = false
340
- view. wrapped . image = image
343
+ view. image = image
341
344
} else {
342
345
shouldLoad = true
343
346
}
@@ -364,32 +367,27 @@ public struct AnimatedImage : PlatformViewRepresentable {
364
367
}
365
368
366
369
// Finished loading, sync
367
- finishUpdateView ( view, context: context, image : view . wrapped . image )
370
+ finishUpdateView ( view, context: context)
368
371
369
372
if let viewUpdateBlock = imageHandler. viewUpdateBlock {
370
- viewUpdateBlock ( view. wrapped , context)
373
+ viewUpdateBlock ( view, context)
371
374
}
372
375
}
373
376
374
377
static func dismantleView( _ view: AnimatedImageViewWrapper , coordinator: Coordinator ) {
375
- view. wrapped . sd_cancelCurrentImageLoad ( )
378
+ view. sd_cancelCurrentImageLoad ( )
376
379
#if os(macOS)
377
- view. wrapped . animates = false
380
+ view. animates = false
378
381
#else
379
- view. wrapped . stopAnimating ( )
382
+ view. stopAnimating ( )
380
383
#endif
381
384
if let viewDestroyBlock = viewDestroyBlock {
382
- viewDestroyBlock ( view. wrapped , coordinator)
385
+ viewDestroyBlock ( view, coordinator)
383
386
}
384
387
}
385
388
386
- func finishUpdateView( _ view: AnimatedImageViewWrapper , context: Context , image : PlatformImage ? ) {
389
+ func finishUpdateView( _ view: AnimatedImageViewWrapper , context: Context ) {
387
390
// Finished loading
388
- if let imageSize = image? . size {
389
- view. imageSize = imageSize
390
- } else {
391
- view. imageSize = nil
392
- }
393
391
configureView ( view, context: context)
394
392
layoutView ( view, context: context)
395
393
}
@@ -436,16 +434,16 @@ public struct AnimatedImage : PlatformViewRepresentable {
436
434
}
437
435
438
436
#if os(macOS)
439
- view. wrapped . imageScaling = contentMode
437
+ view. imageScaling = contentMode
440
438
#else
441
- view. wrapped . contentMode = contentMode
439
+ view. contentMode = contentMode
442
440
#endif
443
441
444
442
// Resizable
445
443
view. resizingMode = imageLayout. resizingMode
446
444
447
445
// Animated Image does not support resizing mode and rendering mode
448
- if let image = view. wrapped . image {
446
+ if let image = view. image {
449
447
var image = image
450
448
// ResizingMode
451
449
if let resizingMode = imageLayout. resizingMode, imageLayout. capInsets != EdgeInsets ( ) {
@@ -462,15 +460,15 @@ public struct AnimatedImage : PlatformViewRepresentable {
462
460
#else
463
461
image = image. resizableImage ( withCapInsets: capInsets, resizingMode: . stretch)
464
462
#endif
465
- view. wrapped . image = image
463
+ view. image = image
466
464
case . tile:
467
465
#if os(macOS)
468
466
image. resizingMode = . tile
469
467
image. capInsets = capInsets
470
468
#else
471
469
image = image. resizableImage ( withCapInsets: capInsets, resizingMode: . tile)
472
470
#endif
473
- view. wrapped . image = image
471
+ view. image = image
474
472
@unknown default :
475
473
// Future cases, not implements
476
474
break
@@ -486,14 +484,14 @@ public struct AnimatedImage : PlatformViewRepresentable {
486
484
#else
487
485
image = image. withRenderingMode ( . alwaysTemplate)
488
486
#endif
489
- view. wrapped . image = image
487
+ view. image = image
490
488
case . original:
491
489
#if os(macOS)
492
490
image. isTemplate = false
493
491
#else
494
492
image = image. withRenderingMode ( . alwaysOriginal)
495
493
#endif
496
- view. wrapped . image = image
494
+ view. image = image
497
495
@unknown default :
498
496
// Future cases, not implements
499
497
break
@@ -529,74 +527,74 @@ public struct AnimatedImage : PlatformViewRepresentable {
529
527
func configureView( _ view: AnimatedImageViewWrapper , context: Context ) {
530
528
// IncrementalLoad
531
529
if let incrementalLoad = imageConfiguration. incrementalLoad {
532
- view. wrapped . shouldIncrementalLoad = incrementalLoad
530
+ view. shouldIncrementalLoad = incrementalLoad
533
531
} else {
534
- view. wrapped . shouldIncrementalLoad = true
532
+ view. shouldIncrementalLoad = true
535
533
}
536
534
537
535
// MaxBufferSize
538
536
if let maxBufferSize = imageConfiguration. maxBufferSize {
539
- view. wrapped . maxBufferSize = maxBufferSize
537
+ view. maxBufferSize = maxBufferSize
540
538
} else {
541
539
// automatically
542
- view. wrapped . maxBufferSize = 0
540
+ view. maxBufferSize = 0
543
541
}
544
542
545
543
// CustomLoopCount
546
544
if let customLoopCount = imageConfiguration. customLoopCount {
547
- view. wrapped . shouldCustomLoopCount = true
548
- view. wrapped . animationRepeatCount = Int ( customLoopCount)
545
+ view. shouldCustomLoopCount = true
546
+ view. animationRepeatCount = Int ( customLoopCount)
549
547
} else {
550
548
// disable custom loop count
551
- view. wrapped . shouldCustomLoopCount = false
549
+ view. shouldCustomLoopCount = false
552
550
}
553
551
554
552
// RunLoop Mode
555
553
if let runLoopMode = imageConfiguration. runLoopMode {
556
- view. wrapped . runLoopMode = runLoopMode
554
+ view. runLoopMode = runLoopMode
557
555
} else {
558
- view. wrapped . runLoopMode = . common
556
+ view. runLoopMode = . common
559
557
}
560
558
561
559
// Pausable
562
560
if let pausable = imageConfiguration. pausable {
563
- view. wrapped . resetFrameIndexWhenStopped = !pausable
561
+ view. resetFrameIndexWhenStopped = !pausable
564
562
} else {
565
- view. wrapped . resetFrameIndexWhenStopped = false
563
+ view. resetFrameIndexWhenStopped = false
566
564
}
567
565
568
566
// Clear Buffer
569
567
if let purgeable = imageConfiguration. purgeable {
570
- view. wrapped . clearBufferWhenStopped = purgeable
568
+ view. clearBufferWhenStopped = purgeable
571
569
} else {
572
- view. wrapped . clearBufferWhenStopped = false
570
+ view. clearBufferWhenStopped = false
573
571
}
574
572
575
573
// Playback Rate
576
574
if let playbackRate = imageConfiguration. playbackRate {
577
- view. wrapped . playbackRate = playbackRate
575
+ view. playbackRate = playbackRate
578
576
} else {
579
- view. wrapped . playbackRate = 1.0
577
+ view. playbackRate = 1.0
580
578
}
581
579
582
580
// Playback Mode
583
581
if let playbackMode = imageConfiguration. playbackMode {
584
- view. wrapped . playbackMode = playbackMode
582
+ view. playbackMode = playbackMode
585
583
} else {
586
- view. wrapped . playbackMode = . normal
584
+ view. playbackMode = . normal
587
585
}
588
586
589
587
// Animation
590
588
#if os(macOS)
591
- if self . isAnimating != view. wrapped . animates {
592
- view. wrapped . animates = self . isAnimating
589
+ if self . isAnimating != view. animates {
590
+ view. animates = self . isAnimating
593
591
}
594
592
#else
595
- if self . isAnimating != view. wrapped . isAnimating {
593
+ if self . isAnimating != view. isAnimating {
596
594
if self . isAnimating {
597
- view. wrapped . startAnimating ( )
595
+ view. startAnimating ( )
598
596
} else {
599
- view. wrapped . stopAnimating ( )
597
+ view. stopAnimating ( )
600
598
}
601
599
}
602
600
#endif
0 commit comments