From 04491206841efc844e0054e5d18674bbd291dabd Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 12 Feb 2023 10:53:59 +0100 Subject: [PATCH] Status media: Fix video size --- .../Status/Row/StatusMediaPreviewView.swift | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/Packages/Status/Sources/Status/Row/StatusMediaPreviewView.swift b/Packages/Status/Sources/Status/Row/StatusMediaPreviewView.swift index ead97791..745328fd 100644 --- a/Packages/Status/Sources/Status/Row/StatusMediaPreviewView.swift +++ b/Packages/Status/Sources/Status/Row/StatusMediaPreviewView.swift @@ -146,43 +146,28 @@ public struct StatusMediaPreviewView: View { @ViewBuilder private func makeFeaturedImagePreview(attachment: MediaAttachment) -> some View { ZStack(alignment: .bottomTrailing) { + let size: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight) + let newSize = imageSize(from: size, + newWidth: availableWidth - appLayoutWidth) switch attachment.supportedType { case .image: - if let size = size(for: attachment) { - let newSize = imageSize(from: size, - newWidth: availableWidth - appLayoutWidth) - - LazyImage(url: attachment.url) { state in - if let image = state.image { - image - .resizingMode(.aspectFill) - .cornerRadius(4) - .frame(width: newSize.width, height: newSize.height) - } else { - RoundedRectangle(cornerRadius: 4) - .fill(Color.gray) - .frame(width: newSize.width, height: newSize.height) - } - } - } else { - LazyImage(url: attachment.url) { state in - if let image = state.image { - image - .resizingMode(.aspectFit) - .frame(maxHeight: imageMaxHeight) - .cornerRadius(4) - } else { - RoundedRectangle(cornerRadius: 4) - .fill(Color.gray) - .frame(maxHeight: imageMaxHeight) - } + LazyImage(url: attachment.url) { state in + if let image = state.image { + image + .resizingMode(.aspectFill) + .cornerRadius(4) + .frame(width: newSize.width, height: newSize.height) + } else { + RoundedRectangle(cornerRadius: 4) + .fill(Color.gray) + .frame(width: newSize.width, height: newSize.height) } } + case .gifv, .video, .audio: if let url = attachment.url { VideoPlayerView(viewModel: .init(url: url)) - .frame(maxWidth: isNotifications ? imageMaxHeight : nil) - .frame(height: imageMaxHeight) + .frame(width: newSize.width, height: newSize.height) } case .none: EmptyView()