Skip to content

Commit b5d775f

Browse files
committed
Using the hack on watchOS to fix the issue when aspect fit with nil value, this need SwiftUI to provide public API
1 parent 3017ca7 commit b5d775f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,17 @@ extension AnimatedImage {
519519
// Fired Radar: FB7413534
520520
imageLayout.aspectRatio = aspectRatio
521521
imageLayout.contentMode = contentMode
522+
#if os(macOS) || os(iOS) || os(tvOS)
522523
return self.modifier(EmptyModifier()).aspectRatio(aspectRatio, contentMode: contentMode)
524+
#else
525+
if let aspectRatio = aspectRatio {
526+
return AnyView(self.modifier(EmptyModifier()).aspectRatio(aspectRatio, contentMode: contentMode))
527+
} else {
528+
// on watchOS, there are no workaround like `AnimatedImageViewWrapper` to override `intrinsicContentSize`, so the aspect ratio is undetermined and cause sizing issues
529+
// To workaround, we do not call default implementation for this case, using original solution instead
530+
return AnyView(self)
531+
}
532+
#endif
523533
}
524534

525535
/// Constrains this view's dimensions to the aspect ratio of the given size.

0 commit comments

Comments
 (0)