I am struggling with the same issue. I have hidden the top-level navigation view to get to 90% of the design I want. But I don't know how to add a 'back' button to get back to the document selection view. I added a button in the LH pane ('close') and a @Binding to the top-level DocumentGroup. [Tap on 'close' and set the isDisplayed to false] but I cannot find a way to express to 'DocumentGroup' to return to the file picker.
Any leads on a path forward?
Post
Replies
Boosts
Views
Activity
I was wrong. It appears that it does, you just need to do it right.
Document.init() is called on when the + is tapped. This allows you to set up the generic data structure. Then write() is called and you can alter the fileWrapper() to be a directory() and then add a child fileWrapper() for files within the directory.
Then, to launch the DocumentEditor, a call is made to Document.ini(fileWrapper: FileWrapper, contentType: UTType) and this is passed to the DocumentEditor.
Once the Document is created correctly, the system works. Hope this helps someone else struggling with this sequence.
Same result here. Not sure on a path forward.
Thanks for the test on iOS 13.5. I was using the iOS 14.0 simulator. Looks like an iOS 14.0 bug.
Also struggling with Drag-n-Drop in SwiftUI within an app. If you find an answer to this, please post it. I'll be posting other related questions about my specific issue.
I am also looking for how to do this. If anyone finds a mechanism, please post it!
I am also trying to accomplish the same thing. I have put the NavigationView in the DocumentGroup, but the header of the app is now TWO lines; one for the document group (with just a '<' tool and the filename) and a second header for the navigation sidebar and a tool over the texteditor (proxy for my real editor).
I want to merge those two toolbars. Any ideas?
import SwiftUI
@main
struct HawkMultiPlatformMockupApp: App {
var body: some Scene {
DocumentGroup(newDocument: HawkMultiPlatformMockupDocument()) { fileDocumentConfig in
NavigationView {
OutlineView()
ContentView(document: fileDocumentConfig.$document)
}
}
}
}
struct ContentView: View {
@Binding var document: HawkMultiPlatformMockupDocument
var body: some View {
TextEditor(text: $document.text)
.navigationTitle("Text Editor View")
}
}
struct OutlineView: View {
var body: some View {
List() {
Text("a")
Text("b")
Text("c")
}
.listStyle(SidebarListStyle())
.navigationTitle("Navigation")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Text("add")
}
}
}
}