Declaration
import { DocumentLaunchView } from 'swiftui-react-native';nonisolated struct DocumentLaunchView<Actions, DocumentView> where Actions : View, DocumentView : ViewInitializers
24 SwiftUI initializers back <DocumentLaunchView>. The props you pass pick one.
<DocumentLaunchView
title: string
for: string[]
actions?: ReactNode
onDocumentOpen?: ReactNode | ((arg0: string) => ReactNode)
/>nonisolated init(
_ title: some StringProtocol,
for contentTypes: [UTType],
@ContentBuilder _ actions: () -> Actions,
@ContentBuilder onDocumentOpen: @escaping (URL) -> DocumentView
)title*stringA title to use for the view title.
for*string[]Content types that the view can open.
Swift
for contentTypes: [UTType]actionsReactNodeA content builder returning the view's actions
onDocumentOpenReactNode | ((arg0: string) => ReactNode)A closure that handles an open file.
Also takes the common view props: modifiers, style and testID.
Overview
doc://com.apple.documentation/documentation/bundleresources/information-property-list/uisupportsdocumentbrowser to YES in your app's
information property list. Without this key, document creation doesn't work.
Configure DocumentLaunchView to open and display files and trigger custom
actions.
For example, an application that offers writing books can present
the DocumentLaunchView as its launch view:
public import UniformTypeIdentifiers
struct BookEditorLaunchView: View {
var body: some View {
DocumentLaunchView(for: [.book]) {
NewDocumentButton("Start New Book")
} onDocumentOpen: { url in
BookEditor(url)
}
}
}
struct BookEditor: View {
init(_ url: URL) { }
}
extension UTType {
static let book = UTType(exportedAs: "com.example.bookEditor")
}An alternative to
DocumentLaunchViewis a scene variant of this API:DocumentGroupLaunchScene. If the app definition containsDocumentGroupscenes, consider using aDocumentGroupLaunchSceneinstead of this view.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Relationships
Conforms to
- View
See also
More in Documents.