support multiple attachments

This commit is contained in:
Lumaa 2024-01-04 23:54:36 +01:00
parent 6894abb4bf
commit 8d185f3187

View File

@ -7,6 +7,7 @@ import AVKit
struct PostAttachment: View {
@Environment(AppDelegate.self) private var appDelegate: AppDelegate
var attachment: MediaAttachment
var isFeatured: Bool = true
@State private var player: AVPlayer?
var appLayoutWidth: CGFloat = 10
@ -18,6 +19,7 @@ struct PostAttachment: View {
}
private let imageMaxHeight: CGFloat = 300
var body: some View {
let mediaSize: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
let newSize = imageSize(from: mediaSize)
@ -30,7 +32,7 @@ struct PostAttachment: View {
image
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: newSize.width, height: newSize.height)
.frame(width: !isFeatured ? imageMaxHeight / 1.5 : newSize.width, height: !isFeatured ? imageMaxHeight: newSize.height)
.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(.gray.opacity(0.3), lineWidth: 1)
@ -101,7 +103,7 @@ struct PostAttachment: View {
}
}
}
.frame(width: newSize.width, height: newSize.height)
.frame(width: !isFeatured ? imageMaxHeight / 1.5 : newSize.width, height: !isFeatured ? imageMaxHeight: newSize.height)
.clipped()
.clipShape(.rect(cornerRadius: 15))
.contentShape(Rectangle())