Threaded layout fixes (#1730)
* Fixes #1727 - Layout issues caused by the new timelineMediaFrame * Better handle small media thumbnails * fixed an issue where sometimes the reply gets greedier than the content --------- Co-authored-by: Mauro Romito <mauro.romito@element.io>
This commit is contained in:
@@ -18,8 +18,19 @@ import SwiftUI
|
||||
|
||||
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 {
|
||||
aspectRatio(contentAspectRatio, contentMode: .fit)
|
||||
.frame(maxHeight: min(300, max(100, contentHeight ?? .infinity)))
|
||||
let minMediaHeight = 100.0
|
||||
let maxMediaHeight = 300.0
|
||||
|
||||
if let contentHeight, contentHeight < minMediaHeight { // Special case very small images
|
||||
aspectRatio(contentAspectRatio, contentMode: .fit)
|
||||
.frame(minHeight: minMediaHeight, maxHeight: minMediaHeight)
|
||||
} else {
|
||||
aspectRatio(contentAspectRatio, contentMode: .fit)
|
||||
.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ struct ImageRoomTimelineView: View {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.content.height,
|
||||
aspectRatio: timelineItem.content.height)
|
||||
aspectRatio: timelineItem.content.aspectRatio)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(L10n.commonImage)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user