mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-25 06:22:06 +01:00
use default frame for preview images that API returns incorrect (width: 0, height: 0) (#1915)
This commit is contained in:
parent
46b8fbde29
commit
62eeba5334
@ -197,9 +197,7 @@ struct DefaultPreviewImage: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func calculateSize(_ proposal: ProposedViewSize) -> CGSize {
|
private func calculateSize(_ proposal: ProposedViewSize) -> CGSize {
|
||||||
guard originalWidth > 0 else { return CGSize.zero }
|
switch (proposal.width, proposal.height) {
|
||||||
|
|
||||||
return switch (proposal.width, proposal.height) {
|
|
||||||
case (nil, nil):
|
case (nil, nil):
|
||||||
CGSize(width: originalWidth, height: originalWidth)
|
CGSize(width: originalWidth, height: originalWidth)
|
||||||
case let (nil, .some(height)):
|
case let (nil, .some(height)):
|
||||||
@ -207,8 +205,12 @@ struct DefaultPreviewImage: View {
|
|||||||
case (0, _):
|
case (0, _):
|
||||||
CGSize.zero
|
CGSize.zero
|
||||||
case let (.some(width), _):
|
case let (.some(width), _):
|
||||||
|
if originalWidth == 0 {
|
||||||
|
CGSize(width: width, height: width / 2)
|
||||||
|
} else {
|
||||||
CGSize(width: width, height: width / originalWidth * originalHeight)
|
CGSize(width: width, height: width / originalWidth * originalHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user