init(_:contentType:source:)
Creates and opens new documents, tagging them with a creation source.
Declaration
nonisolated init(_ label: Text? = nil, contentType: UTType? = nil, source: DocumentCreationSource)Parameters
- label:
A label for the button.
- contentType:
An optional content type of the document to create. If not provided, the first content type of the first document type listed in the app definition is used.
- source:
A source for the document creation flow. When a document is created, you can retrieve its source from Filedocumentconfiguration or Urldocumentconfiguration.
Discussion
extension DocumentCreationSource {
static let brainstorming: Self =
DocumentCreationSource(id: "brainstorming")
}
DocumentGroupLaunchScene("Meeting Minutes") {
NewDocumentButton(Text("New meeting minutes…"))
NewDocumentButton(
Text("New brainstorming meeting…"),
source: .brainstorming
)
}