From 8d185f31873a1116e461be2469ad17cb30e9eeab Mon Sep 17 00:00:00 2001 From: Lumaa Date: Thu, 4 Jan 2024 23:54:36 +0100 Subject: [PATCH] support multiple attachments --- Threaded/Components/PostAttachment.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Threaded/Components/PostAttachment.swift b/Threaded/Components/PostAttachment.swift index ce8b734..84c8551 100644 --- a/Threaded/Components/PostAttachment.swift +++ b/Threaded/Components/PostAttachment.swift @@ -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())