Let user pick document type to create when using SwiftUI & DocumentGroup

My document-based app supports several different file types. It is currently written in SwiftUI using a UIDocumentBrowserViewController. I'm trying to convert to the new SwiftUI (v2) DocumentGroup paradigm. I need to let the user pick which kind of document to create when they tap the Create button in the document browser. Using DocumentGroup paradigm, I don't see how this is possible. When you create a DocumentGroup, you have to specify the document right there:

Code Block
var body: some Scene {
    DocumentGroup(newDocument: TextDocument()) { file in
        TextDocumentEditor(document: file.$document)
    }
}


When using UIKit, the browser calls a delegate function didRequestDocumentCreationWithHandler that lets the app inject some UI for picking a document type, before proceeding on. In fact, what you can do is provide the document browser with a template file to be used for creating the new doc. Is that possible in SwiftUI 2?
I've implemented a template picker by adding a template property to my FileDocument and checking it in the editor View and then optionally showing the template picker or the editor. This works well, but I don't see a way to dismiss the window back to the browser if they want to cancel out of the template picker.
beckersoft, that’s an interesting approach. I thought of trying something like that, but my app supports different file types (different file extensions) and by the time the editor gets invoked, the OS has already generated a file at the location the user chose. The app had to choose what kind of file to create as part of initializing the DocumentGroup. If the user then chooses a different file type in the template picker, I don’t think it’s easy to convert the file that was already created. It feels like I’m really working against the system and that may come back to bite me.

It also seems that if you cancel out of the template picker, there’s already a document created that you’d really want to be deleted.
Can you please share some code? Thanks!
Let user pick document type to create when using SwiftUI & DocumentGroup
 
 
Q