Fixes #3173 - Force frame sizes for timeline items that are missing sizing info.

This commit is contained in:
Stefan Ceriu 2024-09-11 10:38:33 +03:00 committed by Stefan Ceriu
parent 10fcb5575d
commit 65bacfaae3
21 changed files with 43 additions and 43 deletions

View File

@ -11,6 +11,7 @@ extension View {
/// Constrains the max height of a media item in the timeline, whilst preserving its aspect ratio.
@ViewBuilder
func timelineMediaFrame(height contentHeight: CGFloat?, aspectRatio contentAspectRatio: CGFloat?) -> some View {
let defaultMediaSize = 100.0
let minMediaHeight = 100.0
let maxMediaHeight = 300.0
@ -23,9 +24,8 @@ extension View {
.frame(maxHeight: min(maxMediaHeight, max(minMediaHeight, contentHeight ?? .infinity)))
// Required to prevent the reply details to get higher priority in rendering the width of the view.
.aspectRatio(contentAspectRatio, contentMode: .fit)
} else { // Otherwise let the image load and use its native aspect ratio with a max height
aspectRatio(contentMode: .fit)
.frame(maxHeight: maxMediaHeight)
} else { // Otherwise force the image to be `defaultMediaSize` x `defaultMediaSize`
frame(width: defaultMediaSize, height: defaultMediaSize)
}
}
}