AttachmentThumbnail
public struct AttachmentThumbnail
extension AttachmentThumbnail: View
extension AttachmentThumbnail: _ViewEmptyChecking
AttachmentThumbnail is a specialized UI component that renders previews for attachment files asynchronously.
This component intelligently handles different file types by:
- Initially displaying appropriate static file type icons while loading
- Generating thumbnail previews for supported file types (images, PDFs, etc.)
- Maintaining the file type icon for non-previewable file types
- Adapting its appearance based on control state (normal, disabled, read-only)
The thumbnail generation process happens in the background to maintain UI responsiveness, and the component automatically updates when the preview becomes available.
Usage
Use AttachmentThumbnail within an Attachment component to display file previews:
// Basic usage with an image file
Attachment {
AttachmentThumbnail(url: imageURL)
} attachmentTitle: {
Text("Photo")
} attachmentSubtitle: {
Text("2.5MB")
} attachmentFootnote: {
Text("Oct 20, 2025")
}
// Usage with a PDF document
Attachment {
AttachmentThumbnail(url: pdfURL, controlState: viewModel.isEditable ? .normal : .readOnly)
} attachmentTitle: {
Text("Contract")
} attachmentSubtitle: {
Text("PDF • 1.2MB")
} attachmentFootnote: {
Text("Last modified today")
}
The component can also be used standalone when needed:
AttachmentThumbnail(url: fileURL)
-
Undocumented
Declaration
Swift
public init(url: URL, controlState: ControlState = .normal, componentIdentifier: String? = AttachmentThumbnail.identifier) -
Undocumented
Declaration
Swift
static let identifier: String -
Undocumented
Declaration
Swift
init(_ configuration: AttachmentThumbnailConfiguration) -
Declaration
Swift
@MainActor public var body: some View { get } -
Undocumented
Declaration
Swift
public var isEmpty: Bool { get }