AttachmentContext
open class AttachmentContext
Attachment Context facilitates hierarchical components, i.e. AttachmentGroup and Attachment work together, for example setting and displaying error message and showing and dismissing file picker.
-
Controls the visibility of the system Photos picker for selecting images from the photo library.
Setting this property to
truepresents the PhotosPicker UI component, allowing users to select photos from their device’s photo library. After selection or dismissal, this property should be set back tofalseto hide the picker.Declaration
Swift
public var showPhotosPicker: Bool { get set } -
Controls the visibility of the system Files picker for selecting documents.
Setting this property to
truepresents the FileImporter UI component, allowing users to select documents from their device’s file system or cloud storage. After selection or dismissal, this property should be set back tofalseto hide the picker.Declaration
Swift
public var showFilesPicker: Bool { get set } -
Controls the visibility of the camera interface for capturing photos or videos.
Setting this property to
truepresents the camera UI, allowing users to capture new photos or videos using the device camera. After capturing or dismissal, this property should be set back tofalseto hide the camera interface.Declaration
Swift
public var showCamera: Bool { get set } -
Controls the visibility of the document scanner interface for capturing PDF documents.
Setting this property to
truepresents the document scanning UI, allowing users to capture multi-page documents and convert them to PDF format. After scanning or dismissal, this property should be set back tofalseto hide the scanner.Declaration
Swift
public var showPdfScanner: Bool { get set } -
Controls the visibility of the document scanner interface for capturing individual images.
Setting this property to
truepresents the image scanning UI, allowing users to capture images with document-specific enhancements like perspective correction and edge detection. After scanning or dismissal, this property should be set back tofalseto hide the scanner.Declaration
Swift
public var showImageScanner: Bool { get set } -
The delegate that handles attachment operations like uploading, downloading, and deleting.
This delegate is responsible for implementing the actual business logic for attachment operations. It’s defined as weak to avoid reference cycles since the context might be held by the delegate.
Declaration
Swift
public weak var delegate: AttachmentDelegate? { get set } -
The configuration for the attachment group containing settings and state.
This configuration contains the list of attachments and other settings that control the behavior and appearance of attachment-related UI components.
Declaration
Swift
public var configuration: AttachmentGroupConfiguration? { get set } -
A closure that provides default extra information for newly uploaded attachments.
When an attachment is successfully uploaded, this closure is called to generate optional extra information that will be associated with the attachment in its
.uploadedstate.Declaration
Swift
public var onDefaultExtraInfo: (() -> any AttachmentExtraInfo)? { get set }Return Value
An instance conforming to
AttachmentExtraInfoto associate with uploaded attachments. -
Indicates whether an attachment is currently being uploaded.
This flag is toggled during the upload process and can be observed to show loading indicators or disable certain UI interactions during an ongoing upload.
Declaration
Swift
public var isUploading: Bool { get set } -
Initializes a new attachment context with default settings.
This initializer creates a new instance of
AttachmentContextwith the following default state:Declaration
Swift
public init() -
Deletes an attachment based on its URL.
This method handles attachment deletion with different behavior based on the attachment’s state:
- For
.uploadedattachments: Delegates deletion to theAttachmentDelegateand removes from the list upon success - For
.uploadingor.errorattachments: Immediately removes from the attachment list without delegate involvement
Error handling is provided through the delegate callback, with appropriate error messages displayed for
AttachmentErrorcases or standard errors.Declaration
Swift
public func delete(attachment: URL)Parameters
attachmentThe URL of the attachment to be deleted
- For