Skip to content

Commit

Permalink
Using the hack on watchOS to fix the issue when aspect fit with nil v…
Browse files Browse the repository at this point in the history
…alue, this need SwiftUI to provide public API
  • Loading branch information
dreampiggy committed Oct 29, 2019
1 parent 3017ca7 commit b5d775f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions SDWebImageSwiftUI/Classes/AnimatedImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,17 @@ extension AnimatedImage {
// Fired Radar: FB7413534
imageLayout.aspectRatio = aspectRatio
imageLayout.contentMode = contentMode
#if os(macOS) || os(iOS) || os(tvOS)
return self.modifier(EmptyModifier()).aspectRatio(aspectRatio, contentMode: contentMode)
#else
if let aspectRatio = aspectRatio {
return AnyView(self.modifier(EmptyModifier()).aspectRatio(aspectRatio, contentMode: contentMode))
} else {
// on watchOS, there are no workaround like `AnimatedImageViewWrapper` to override `intrinsicContentSize`, so the aspect ratio is undetermined and cause sizing issues
// To workaround, we do not call default implementation for this case, using original solution instead
return AnyView(self)
}
#endif
}

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

0 comments on commit b5d775f

Please sign in to comment.