Contents

AssignedDocumentSubmissionButton

A button that provides submission functionality for the assigned document.

Declaration

@MainActor @preconcurrency struct AssignedDocumentSubmissionButton

Overview

AssignedDocumentSubmissionButton enables students to submit and withdraw assigned documents. The button fetches document data from ClassKit and updates its appearance and behavior based on the current submission status. The button shows loading states during both initial data loading and submission processing.

You can customize the submission process using view modifiers that execute at key points in the submission lifecycle. Use the modifiers to either validate or prepare documents before an action or update your app after an action completes:

For submissions, use:

For withdrawing submissions use:

The following example shows how to create an assigned document submission button and customize its behavior with validation and completion actions:

// Create a basic submission button
AssignedDocumentSubmissionButton(documentURL: documentURL)

// Create menu item with validation and logging
// Provide closures to validate document submissions and respond to completed submissions:
AssignedDocumentSubmissionButton(documentURL: documentURL)
    .onAssignedDocumentWillSubmit { url in
        // Validate the assigned document before submission
        guard await validateDocument(url) else {
            await showAlert("Please complete all sections before submitting")
            return false // Prevents submission
        }
        return true // Allows submission to continue
    }
    .onAssignedDocumentDidSubmit { url in
        // Handle successful submission
        logEvent("Assigned document submitted successfully!")
    }

Topics

Initializers

See Also

Submitting assigned documents