Status media: Fix video size

This commit is contained in:
Thomas Ricouard 2023-02-12 10:53:59 +01:00
parent 2c3705a1da
commit 0449120684

View file

@ -146,12 +146,11 @@ public struct StatusMediaPreviewView: View {
@ViewBuilder @ViewBuilder
private func makeFeaturedImagePreview(attachment: MediaAttachment) -> some View { private func makeFeaturedImagePreview(attachment: MediaAttachment) -> some View {
ZStack(alignment: .bottomTrailing) { ZStack(alignment: .bottomTrailing) {
switch attachment.supportedType { let size: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
case .image:
if let size = size(for: attachment) {
let newSize = imageSize(from: size, let newSize = imageSize(from: size,
newWidth: availableWidth - appLayoutWidth) newWidth: availableWidth - appLayoutWidth)
switch attachment.supportedType {
case .image:
LazyImage(url: attachment.url) { state in LazyImage(url: attachment.url) { state in
if let image = state.image { if let image = state.image {
image image
@ -164,25 +163,11 @@ public struct StatusMediaPreviewView: View {
.frame(width: newSize.width, height: newSize.height) .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)
}
}
}
case .gifv, .video, .audio: case .gifv, .video, .audio:
if let url = attachment.url { if let url = attachment.url {
VideoPlayerView(viewModel: .init(url: url)) VideoPlayerView(viewModel: .init(url: url))
.frame(maxWidth: isNotifications ? imageMaxHeight : nil) .frame(width: newSize.width, height: newSize.height)
.frame(height: imageMaxHeight)
} }
case .none: case .none:
EmptyView() EmptyView()