mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Group image and video metadata in specialised structs (#3518)
This commit is contained in:
@@ -10,18 +10,18 @@ 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 {
|
||||
func timelineMediaFrame(imageInfo: ImageInfoProxy?) -> some View {
|
||||
let defaultMediaSize = 100.0
|
||||
let minMediaHeight = 100.0
|
||||
let maxMediaHeight = 300.0
|
||||
|
||||
if let contentHeight, contentHeight < minMediaHeight { // Special case very small images
|
||||
aspectRatio(contentAspectRatio, contentMode: .fit)
|
||||
if let contentHeight = imageInfo?.size?.height, contentHeight < minMediaHeight { // Special case very small images
|
||||
aspectRatio(imageInfo?.aspectRatio, contentMode: .fit)
|
||||
.frame(minHeight: minMediaHeight, maxHeight: minMediaHeight)
|
||||
} else {
|
||||
if let contentAspectRatio {
|
||||
if let contentAspectRatio = imageInfo?.aspectRatio {
|
||||
aspectRatio(contentAspectRatio, contentMode: .fit)
|
||||
.frame(maxHeight: min(maxMediaHeight, max(minMediaHeight, contentHeight ?? .infinity)))
|
||||
.frame(maxHeight: min(maxMediaHeight, max(minMediaHeight, imageInfo?.size?.height ?? .infinity)))
|
||||
// Required to prevent the reply details to get higher priority in rendering the width of the view.
|
||||
.aspectRatio(contentAspectRatio, contentMode: .fit)
|
||||
} else { // Otherwise force the image to be `defaultMediaSize` x `defaultMediaSize`
|
||||
|
||||
Reference in New Issue
Block a user