danielsaidi / DocumentKit

DocumentKit is a Swift SDK that adds more capabilities to DocumentGroup-based apps in SwiftUI.
MIT License
62 stars 3 forks source link

How to Intercept and Handle the "Create Document" Event #1

Closed PlayApple closed 1 year ago

PlayApple commented 1 year ago

Hello, first of all, I would like to express my appreciation for the excellent work on this extension library. After reviewing it, I have a question and would greatly appreciate your guidance.

When I click on "Create Document" or the plus button in the upper right corner, it creates a new file. I would like to know how to listen to and intercept this event, so that when I click on "Create Document", instead of automatically creating a new file, it opens a new view.

Similar to: When the user creates a new document, the system calls the document browser delegate's documentBrowser(_:didRequestDocumentCreationWithHandler:) method.

Thank you in advance for your assistance!

danielsaidi commented 1 year ago

Hi @PlayApple

I'm very happy to hear that you like it :)

I haven't looked into replacing all the buttons, but I'm sure it would be possible to achieve with the same approach as we currently have, but change the code to replace the existing button.

However, instead of adjusting the buttons too much, perhaps you should look into if you can use a reference document to achieve this instead? It however involves a lot more code.

PlayApple commented 1 year ago

Thank you for the answer. I'm very interested in this kind of less code approach with documentgroup. I would like to be able to choose the type of document to create when creating a document, such as a recording document or a checklist document.

So, originally I was thinking of implementing something similar to the documentBrowser(_:didRequestDocumentCreationWithHandler:) method in the document browser delegate.

Or, if I want to import files myself, such as photos to iCloud, what should I do? Should I manage iCloud files myself?

danielsaidi commented 1 year ago

My personal experience is that going along with the document group model is the easiest way, and that deviating from the path it sets is sure to bring you a lot of additional work and pain :)

danielsaidi commented 1 year ago

@PlayApple Did you get it to work? Would love to hear how you did it :)