@@ -350,7 +350,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
350350 }
351351
352352 // 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) {
354354 var image = image
355355 // ResizingMode
356356 if let resizingMode = imageLayout. resizingMode, imageLayout. capInsets != EdgeInsets ( ) {
@@ -556,11 +556,11 @@ extension AnimatedImage {
556556 // So, if we don't override this method, SwiftUI ignore the content mode on actual ImageView
557557 // To workaround, we want to call the default `SwifUI.View.aspectRatio(_:contentMode:)` method
558558 // 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
560560 // Fired Radar: FB7413534
561561 self . imageLayout. aspectRatio = aspectRatio
562562 self . imageLayout. contentMode = contentMode
563- return self . modifier ( EmptyModifier ( ) ) . aspectRatio ( aspectRatio, contentMode: contentMode)
563+ return self . modifier ( _AspectRatioLayout ( aspectRatio: aspectRatio, contentMode: contentMode) )
564564 }
565565
566566 /// Constrains this view's dimensions to the aspect ratio of the given size.
@@ -572,13 +572,7 @@ extension AnimatedImage {
572572 /// - Returns: A view that constrains this view's dimensions to
573573 /// `aspectRatio`, using `contentMode` as its scaling algorithm.
574574 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)
582576 }
583577
584578 /// Scales this view to fit its parent.
0 commit comments