mirror of
https://github.com/lumaa-dev/BubbleApp.git
synced 2025-01-07 14:21:43 +01:00
support multiple attachments
This commit is contained in:
parent
6894abb4bf
commit
8d185f3187
@ -7,6 +7,7 @@ import AVKit
|
|||||||
struct PostAttachment: View {
|
struct PostAttachment: View {
|
||||||
@Environment(AppDelegate.self) private var appDelegate: AppDelegate
|
@Environment(AppDelegate.self) private var appDelegate: AppDelegate
|
||||||
var attachment: MediaAttachment
|
var attachment: MediaAttachment
|
||||||
|
var isFeatured: Bool = true
|
||||||
@State private var player: AVPlayer?
|
@State private var player: AVPlayer?
|
||||||
|
|
||||||
var appLayoutWidth: CGFloat = 10
|
var appLayoutWidth: CGFloat = 10
|
||||||
@ -18,6 +19,7 @@ struct PostAttachment: View {
|
|||||||
}
|
}
|
||||||
private let imageMaxHeight: CGFloat = 300
|
private let imageMaxHeight: CGFloat = 300
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let mediaSize: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
|
let mediaSize: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
|
||||||
let newSize = imageSize(from: mediaSize)
|
let newSize = imageSize(from: mediaSize)
|
||||||
@ -30,7 +32,7 @@ struct PostAttachment: View {
|
|||||||
image
|
image
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fill)
|
.aspectRatio(contentMode: .fill)
|
||||||
.frame(width: newSize.width, height: newSize.height)
|
.frame(width: !isFeatured ? imageMaxHeight / 1.5 : newSize.width, height: !isFeatured ? imageMaxHeight: newSize.height)
|
||||||
.overlay(
|
.overlay(
|
||||||
RoundedRectangle(cornerRadius: 15)
|
RoundedRectangle(cornerRadius: 15)
|
||||||
.stroke(.gray.opacity(0.3), lineWidth: 1)
|
.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()
|
.clipped()
|
||||||
.clipShape(.rect(cornerRadius: 15))
|
.clipShape(.rect(cornerRadius: 15))
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
|
Loading…
Reference in New Issue
Block a user