@@ -350,7 +350,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
350
350
}
351
351
352
352
// Animated Image does not support resizing mode and rendering mode
353
- if let image = view. wrapped. image, !image. sd_isAnimated , !image . conforms ( to: SDAnimatedImageProtocol . self) {
353
+ if let image = view. wrapped. image, !image. conforms ( to: SDAnimatedImageProtocol . self) {
354
354
var image = image
355
355
// ResizingMode
356
356
if let resizingMode = imageLayout. resizingMode, imageLayout. capInsets != EdgeInsets ( ) {
@@ -556,11 +556,11 @@ extension AnimatedImage {
556
556
// So, if we don't override this method, SwiftUI ignore the content mode on actual ImageView
557
557
// To workaround, we want to call the default `SwifUI.View.aspectRatio(_:contentMode:)` method
558
558
// But 2: there are no way to call a Protocol Extention default implementation in Swift 5.1
559
- // So, we need a hack, that create a empty modifier, they call method on that view instead
559
+ // So, we directly call the implementation detail modifier instead
560
560
// Fired Radar: FB7413534
561
561
self . imageLayout. aspectRatio = aspectRatio
562
562
self . imageLayout. contentMode = contentMode
563
- return self . modifier ( EmptyModifier ( ) ) . aspectRatio ( aspectRatio, contentMode: contentMode)
563
+ return self . modifier ( _AspectRatioLayout ( aspectRatio: aspectRatio, contentMode: contentMode) )
564
564
}
565
565
566
566
/// Constrains this view's dimensions to the aspect ratio of the given size.
@@ -572,13 +572,7 @@ extension AnimatedImage {
572
572
/// - Returns: A view that constrains this view's dimensions to
573
573
/// `aspectRatio`, using `contentMode` as its scaling algorithm.
574
574
public func aspectRatio( _ aspectRatio: CGSize , contentMode: ContentMode ) -> some View {
575
- var ratio : CGFloat ?
576
- if aspectRatio. width > 0 && aspectRatio. height > 0 {
577
- ratio = aspectRatio. width / aspectRatio. height
578
- } else {
579
- NSException ( name: . invalidArgumentException, reason: " \( type ( of: self ) ) . \( #function) should be called with positive aspectRatio " , userInfo: nil ) . raise ( )
580
- }
581
- return self . aspectRatio ( ratio, contentMode: contentMode)
575
+ return self . aspectRatio ( aspectRatio. width / aspectRatio. height, contentMode: contentMode)
582
576
}
583
577
584
578
/// Scales this view to fit its parent.
0 commit comments