Adds keychain support
This commit is contained in:
@@ -71,16 +71,51 @@ struct ImageItemView: View
|
||||
@State private var img: NSImage?
|
||||
@Environment(\.xpcClient) var xpcClient
|
||||
|
||||
@State private var containerWidth: CGFloat? = nil
|
||||
|
||||
var aspectRatio: CGFloat {
|
||||
if let size = attachment.size, size.height > 0 {
|
||||
return size.width / size.height
|
||||
} else {
|
||||
return 1.0
|
||||
}
|
||||
}
|
||||
|
||||
var preferredSize: CGSize {
|
||||
return CGSize(
|
||||
width: preferredWidth,
|
||||
height: preferredWidth / aspectRatio
|
||||
)
|
||||
}
|
||||
|
||||
var preferredWidth: CGFloat {
|
||||
if let containerWidth, let attachmentWidth = attachment.size?.width {
|
||||
return CGFloat.minimum(containerWidth, attachmentWidth)
|
||||
} else if let containerWidth {
|
||||
return containerWidth
|
||||
} else {
|
||||
return 200.0 // fallback
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
BubbleView(isFromMe: isFromMe) {
|
||||
if let img {
|
||||
Image(nsImage: img)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(
|
||||
maxWidth: containerWidth
|
||||
)
|
||||
} else {
|
||||
ProgressView()
|
||||
Rectangle()
|
||||
.fill(.gray)
|
||||
|
||||
}
|
||||
}
|
||||
.onGeometryChange(for: CGFloat.self,
|
||||
of: { $0.size.width },
|
||||
action: { containerWidth = $0 })
|
||||
.task {
|
||||
do {
|
||||
let handle = try await xpcClient.openAttachmentFileHandle(
|
||||
|
||||
Reference in New Issue
Block a user