mirror of
https://github.com/lumaa-dev/BubbleApp.git
synced 2025-02-02 11:37:05 +01:00
supports imaging
This commit is contained in:
parent
4bda91845a
commit
95c63952e1
@ -7,7 +7,10 @@ import AVKit
|
||||
struct PostAttachment: View {
|
||||
@Environment(AppDelegate.self) private var appDelegate: AppDelegate
|
||||
var attachment: MediaAttachment
|
||||
|
||||
var isFeatured: Bool = true
|
||||
var isImaging: Bool = false
|
||||
|
||||
@State private var player: AVPlayer?
|
||||
|
||||
var appLayoutWidth: CGFloat = 10
|
||||
@ -24,6 +27,7 @@ struct PostAttachment: View {
|
||||
let mediaSize: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
|
||||
let newSize = imageSize(from: mediaSize)
|
||||
|
||||
if !isImaging {
|
||||
GeometryReader { _ in
|
||||
// Audio later because it's a lil harder
|
||||
if attachment.supportedType == .image {
|
||||
@ -115,6 +119,42 @@ struct PostAttachment: View {
|
||||
.clipped()
|
||||
.clipShape(.rect(cornerRadius: 15))
|
||||
.contentShape(Rectangle())
|
||||
} else {
|
||||
imaging
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var imaging: some View {
|
||||
let mediaSize: CGSize = size(for: attachment) ?? .init(width: imageMaxHeight, height: imageMaxHeight)
|
||||
let newSize = imageSize(from: mediaSize)
|
||||
|
||||
GeometryReader { _ in
|
||||
// Audio later because it's a lil harder
|
||||
if let url = attachment.previewUrl {
|
||||
AsyncImage(url: url) { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: !isFeatured ? imageMaxHeight / 1.5 : newSize.width, height: !isFeatured ? imageMaxHeight: newSize.height)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 15)
|
||||
.stroke(.gray.opacity(0.3), lineWidth: 1)
|
||||
)
|
||||
} placeholder: {
|
||||
ZStack(alignment: .center) {
|
||||
Color.gray
|
||||
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: !isFeatured ? imageMaxHeight / 1.5 : newSize.width, height: !isFeatured ? imageMaxHeight: newSize.height)
|
||||
.clipped()
|
||||
.clipShape(.rect(cornerRadius: 15))
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
|
||||
private func size(for media: MediaAttachment) -> CGSize? {
|
||||
|
Loading…
x
Reference in New Issue
Block a user