iOS Folders: New File and New Folder under + in the navigation bar !217
2 files changed, +23 −3
Layout: unified · split
Sources/OrgstarMobile/FoldersScreen.swift +22 −2
| @@ -19,8 +19,6 @@ struct FoldersScreen: View { | ||
| 19 | 19 | ForEach(workspace.rootPaths, id: \.self) { root in |
| 20 | 20 | Section((root as NSString).lastPathComponent) { |
| 21 | 21 | FolderContents(workspace: workspace, root: root, folder: "", deleting: $deleting, changes: changes) |
| 22 | Button("New File…", systemImage: "doc.badge.plus") { creating = NewItem(folder: root, isFolder: false) } | |
| 23 | Button("New Folder…", systemImage: "folder.badge.plus") { creating = NewItem(folder: root, isFolder: true) } | |
| 24 | 22 | Button("Remove Folder", role: .destructive) { try? workspace.removeRoot(path: root) } |
| 25 | 23 | } |
| 26 | 24 | } |
| @@ -49,6 +47,20 @@ struct FoldersScreen: View { | ||
| 49 | 47 | ToolbarItem(placement: .topBarLeading) { |
| 50 | 48 | Button("Add Folder", systemImage: "folder.badge.plus") { importing = true } |
| 51 | 49 | } |
| 50 | if !workspace.rootPaths.isEmpty { | |
| 51 | ToolbarItem(placement: .primaryAction) { | |
| 52 | Menu("New", systemImage: "plus") { | |
| 53 | // One added folder takes them directly; several each get a submenu. | |
| 54 | if workspace.rootPaths.count == 1, let root = workspace.rootPaths.first { | |
| 55 | newItems(in: root) | |
| 56 | } else { | |
| 57 | ForEach(workspace.rootPaths, id: \.self) { root in | |
| 58 | Menu((root as NSString).lastPathComponent) { newItems(in: root) } | |
| 59 | } | |
| 60 | } | |
| 61 | } | |
| 62 | } | |
| 63 | } | |
| 52 | 64 | } |
| 53 | 65 | .fileImporter(isPresented: $importing, allowedContentTypes: [.folder]) { result in |
| 54 | 66 | guard case .success(let url) = result else { return } |
| @@ -166,6 +178,14 @@ private extension View { | ||
| 166 | 178 | } |
| 167 | 179 | } |
| 168 | 180 | |
| 181 | extension FoldersScreen { | |
| 182 | @ViewBuilder | |
| 183 | private func newItems(in folder: String) -> some View { | |
| 184 | Button("New File…", systemImage: "doc.badge.plus") { creating = NewItem(folder: folder, isFolder: false) } | |
| 185 | Button("New Folder…", systemImage: "folder.badge.plus") { creating = NewItem(folder: folder, isFolder: true) } | |
| 186 | } | |
| 187 | } | |
| 188 | ||
| 169 | 189 | /// A subfolder to show, relative to its root. |
| 170 | 190 | struct FolderRoute: Hashable { |
| 171 | 191 | let root: String |
docs/manual/guide/14-ios.org +1 −1
| @@ -22,7 +22,7 @@ orgstar on iOS works on folders you choose, in iCloud Drive or in another app's | ||
| 22 | 22 | |
| 23 | 23 | orgstar keeps access to the folder across launches. Each folder appears as a section listing its =.org= files by their path inside the folder. Remove Folder at the end of a section removes it from orgstar; the files stay where they are. |
| 24 | 24 | |
| 25 | Swipe left on a file, or touch and hold it, to delete it. orgstar asks first. A file in iCloud Drive goes to Recently Deleted in the Files app; elsewhere it is removed. New File… and New Folder… at the end of a folder's section, or under + in a subfolder, make one there; a file name without an extension gets =.org=. Empty folders are listed too and delete the same way; a folder with anything in it other than hidden files can't be deleted from orgstar. | |
| 25 | Swipe left on a file, or touch and hold it, to delete it. orgstar asks first. A file in iCloud Drive goes to Recently Deleted in the Files app; elsewhere it is removed. New File… and New Folder… under + at the top right make one in the folder shown, or with several added folders, in the one you pick; a file name without an extension gets =.org=. Empty folders are listed too and delete the same way; a folder with anything in it other than hidden files can't be deleted from orgstar. | |
| 26 | 26 | |
| 27 | 27 | Files that iCloud hasn't downloaded to the device yet appear in grey with a cloud icon. orgstar asks iCloud to download them and lists them as files once they arrive. |
| 28 | 28 | |