AttachmentGroup

public struct AttachmentGroup
extension AttachmentGroup: View
extension AttachmentGroup: _ViewEmptyChecking

AttachmentGroup is a UI component that manages a collection of attachments with support for adding, removing, and viewing attachments from various sources.

This component provides a complete interface for attachment management, including:

  • Displaying existing attachments with thumbnails
  • Adding new attachments from photos, camera, files, or scanned documents
  • Previewing attachments
  • Showing upload progress and error states
  • Enforcing maximum attachment limits

Usage

@State private var attachments: [AttachmentInfo] = []
@State private var errorMessage: AttributedString?
let myAttachmentDelegate = MyAttachmentDelegate()

AttachmentGroup(
   title: { Text("Documents") },
   attachments: $attachments,
   maxCount: 5,
   delegate: myAttachmentDelegate,
   errorMessage: $errorMessage,
   operations: {
       AttachmentButtonImage()
           .operationsMenu {
               PhotosPickerMenuItem(filter: [.images])
               FilesPickerMenuItem(filter: [.pdf, .documents])
               CameraMenuItem()
           }
   }
)

How the AttachmentGroup Works and App Responsibilities: The primary data model is an array of AttachmentInfo, which contains the URL(s) and the attachment state. AttachmentGroup relies on the app to prepare attachments for display. Apps are responsible for pre-configuring attachments (e.g., for a “download” use case) in the app’s local folder. Eager downloading is the recommended default approach for attachment previewing.

How Apps Handle Uploading: The AttachmentGroup component is agnostic about the upload destination and method. It uses a delegate pattern for upload logic. Apps must provide an app-specific AttachmentDelegate (a Swift protocol) to handle the actual upload process. A BasicAttachmentDelegate is provided for demonstration or as a base for customization.

Styling and Customizing the UI: By default, all SDK components are Fiori Design compliant. However, Apps have significant control over the UI, including layout, fonts, and colors. Apps can fully customize the attachment icon, information, and even add interactive elements. See MyAttachmentThumbnailMaskStyle in AttachmentGroupExample.swift. Apps can also use a completely different layout see MyAttachmentGroupListStyle, MyAttachmentStyleForListLayout, MyAttachmentInProgressStyleForListLayout, and MyAttachmentWithErrorStyleForListLayout in AttachmentGroupExample.swift.

Custom Preview: Apps can override the default preview behavior by providing an onPreview closure. See theonPreview closure, see onPreview parameter in AttachmentGroupExample.swift.

Apps-Specific Attachment Cache: The BasicAttachmentDelegate includes a “cache” folder concept that may suit your requirements. Apps can use similar code in the “Batch” button action in AttachmentGroupExample.swift for synchroizing attachments between App local storage and backend server.