| author | |
| committer | |
| log | e402bcaea68f6837c079a7176a870a9d6dbdfb65 |
| tree | 2053683d98f4a05074574168c55c760677f366c2 |
| parent | b383ce36c80b1570d513606e5c304576c3da3232 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Deleting on iOS gave no hint where things went. A notebook's menu now opens its
Recycle Bin, OneNote 2010's, listing deleted pages and sections; Restore To puts
a page in a section and a section in a folder the reader picks, the page
keeping its content and identity. The bin records no original place, so the
reader chooses rather than an Undo that would guess.
- The notebook menu's Notebook Recycle Bin lists deleted pages and sections, each with Restore To.
- Deleting a page says it moved to the Recycle Bin; tapping the note opens it.
- Sections and section groups can be deleted to the Recycle Bin, from their menu or Edit.
- Deleting a notebook says it moved to Recently Deleted in Files.
Fixes #133
Assisted-by: claude-opus-5.54 files changed, 256 insertions(+), 10 deletions(-)
apps/ios/Snowbound/Lists.swift+79-4| ... | @@ -388,6 +388,11 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke | ... | @@ -388,6 +388,11 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke |
| 388 | } | 388 | } |
| 389 | })) | 389 | })) |
| 390 | } | 390 | } |
| 391 | if notebook.hasRecycleBin { | ||
| 392 | actions.append(UIAction(title: "Delete", image: UIImage(systemName: "trash"), attributes: .destructive) { [weak self] _ in | ||
| 393 | self?.confirmRecycling(paths, of: notebook) | ||
| 394 | }) | ||
| 395 | } | ||
| 391 | } | 396 | } |
| 392 | let action = UIBarButtonItem(title: "Actions", image: UIImage(systemName: "ellipsis.circle"), menu: UIMenu(children: actions)) | 397 | let action = UIBarButtonItem(title: "Actions", image: UIImage(systemName: "ellipsis.circle"), menu: UIMenu(children: actions)) |
| 393 | action.isEnabled = !actions.isEmpty | 398 | action.isEnabled = !actions.isEmpty |
| ... | @@ -398,7 +403,10 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke | ... | @@ -398,7 +403,10 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke |
| 398 | private func delete(_ notebooks: [Notebook]) { | 403 | private func delete(_ notebooks: [Notebook]) { |
| 399 | let alert = UIAlertController( | 404 | let alert = UIAlertController( |
| 400 | title: notebooks.count == 1 ? "Delete Notebook?" : "Delete \(notebooks.count) Notebooks?", | 405 | title: notebooks.count == 1 ? "Delete Notebook?" : "Delete \(notebooks.count) Notebooks?", |
| 401 | message: "Notebooks that can’t be moved to Recently Deleted will be deleted permanently.", preferredStyle: .alert) | 406 | message: notebooks.count == 1 |
| 407 | ? "It moves to Recently Deleted in Files. If it can’t, it’s deleted permanently." | ||
| 408 | : "They move to Recently Deleted in Files. Any that can’t are deleted permanently.", | ||
| 409 | preferredStyle: .alert) | ||
| 402 | alert.addAction(UIAlertAction(title: "Cancel", style: .cancel)) | 410 | alert.addAction(UIAlertAction(title: "Cancel", style: .cancel)) |
| 403 | alert.addAction(UIAlertAction(title: "Delete", style: .destructive) { [weak self] _ in | 411 | alert.addAction(UIAlertAction(title: "Delete", style: .destructive) { [weak self] _ in |
| 404 | guard let self, let release = Arranging.reserve() else { return } | 412 | guard let self, let release = Arranging.reserve() else { return } |
| ... | @@ -533,7 +541,7 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke | ... | @@ -533,7 +541,7 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke |
| 533 | } | 541 | } |
| 534 | return [UIMenu(options: .displayInline, children: [details, now])] | 542 | return [UIMenu(options: .displayInline, children: [details, now])] |
| 535 | } ?? [] | 543 | } ?? [] |
| 536 | let actions = [ | 544 | var actions = [ |
| 537 | UIAction(title: "New Section", image: UIImage(systemName: "plus.rectangle.portrait")) { | 545 | UIAction(title: "New Section", image: UIImage(systemName: "plus.rectangle.portrait")) { |
| 538 | [weak self] _ in self?.newSection(in: notebook) | 546 | [weak self] _ in self?.newSection(in: notebook) |
| 539 | }, | 547 | }, |
| ... | @@ -542,6 +550,12 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke | ... | @@ -542,6 +550,12 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke |
| 542 | (view.window?.windowScene?.delegate as? SceneDelegate)?.showTags(of: notebook, from: self) | 550 | (view.window?.windowScene?.delegate as? SceneDelegate)?.showTags(of: notebook, from: self) |
| 543 | }, | 551 | }, |
| 544 | ] | 552 | ] |
| 553 | if notebook.hasRecycleBin { | ||
| 554 | actions.append( | ||
| 555 | UIAction(title: "Notebook Recycle Bin", image: UIImage(systemName: "trash")) { [weak self] _ in | ||
| 556 | RecycleBinViewController.present(notebook, in: self?.view.window) | ||
| 557 | }) | ||
| 558 | } | ||
| 545 | // A notebook On My iPhone is its folder there, handled as Files handles a folder. | 559 | // A notebook On My iPhone is its folder there, handled as Files handles a folder. |
| 546 | guard let folder = folder(of: notebook) else { | 560 | guard let folder = folder(of: notebook) else { |
| 547 | let image = UIImage(systemName: "xmark.circle") | 561 | let image = UIImage(systemName: "xmark.circle") |
| ... | @@ -722,6 +736,16 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke | ... | @@ -722,6 +736,16 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke |
| 722 | 736 | ||
| 723 | private func remove(_ folder: URL, of notebook: Notebook) { | 737 | private func remove(_ folder: URL, of notebook: Notebook) { |
| 724 | if (try? FileManager.default.trashItem(at: folder, resultingItemURL: nil)) != nil { | 738 | if (try? FileManager.default.trashItem(at: folder, resultingItemURL: nil)) != nil { |
| 739 | if let window = view.window { | ||
| 740 | SyncToast.show( | ||
| 741 | "“\(notebook.name)” Deleted", "Restore it from Recently Deleted in Files", symbol: "trash", | ||
| 742 | hint: "Opens Files", in: window | ||
| 743 | ) { | ||
| 744 | if let files = URL(string: "shareddocuments://" + folder.deletingLastPathComponent().path) { | ||
| 745 | UIApplication.shared.open(files) | ||
| 746 | } | ||
| 747 | } | ||
| 748 | } | ||
| 725 | return rescan() | 749 | return rescan() |
| 726 | } | 750 | } |
| 727 | let name = folder.deletingPathExtension().lastPathComponent | 751 | let name = folder.deletingPathExtension().lastPathComponent |
| ... | @@ -747,14 +771,65 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke | ... | @@ -747,14 +771,65 @@ final class NotebooksViewController: UICollectionViewController, UIDocumentPicke |
| 747 | ) -> UIContextMenuConfiguration? { | 771 | ) -> UIContextMenuConfiguration? { |
| 748 | guard !isEditing, indexPaths.count == 1, let item = dataSource.itemIdentifier(for: indexPaths[0]) else { return nil } | 772 | guard !isEditing, indexPaths.count == 1, let item = dataSource.itemIdentifier(for: indexPaths[0]) else { return nil } |
| 749 | guard case .notebook(let id) = item, let notebook = notebook(id) else { | 773 | guard case .notebook(let id) = item, let notebook = notebook(id) else { |
| 750 | let moves = arrangeMenu(item) | 774 | let actions = arrangeMenu(item) + deleteAction(item) |
| 751 | return moves.isEmpty ? nil : UIContextMenuConfiguration(actionProvider: { _ in UIMenu(children: moves) }) | 775 | return actions.isEmpty ? nil : UIContextMenuConfiguration(actionProvider: { _ in UIMenu(children: actions) }) |
| 752 | } | 776 | } |
| 753 | return UIContextMenuConfiguration(actionProvider: { [weak self] _ in | 777 | return UIContextMenuConfiguration(actionProvider: { [weak self] _ in |
| 754 | UIMenu(children: (self?.menu(for: notebook).children ?? []) + (self?.arrangeMenu(item) ?? [])) | 778 | UIMenu(children: (self?.menu(for: notebook).children ?? []) + (self?.arrangeMenu(item) ?? [])) |
| 755 | }) | 779 | }) |
| 756 | } | 780 | } |
| 757 | 781 | ||
| 782 | /// Delete for a section or group. | ||
| 783 | private func deleteAction(_ item: Item) -> [UIMenuElement] { | ||
| 784 | switch item { | ||
| 785 | case .section(let id, let path), .group(let id, let path): | ||
| 786 | guard let notebook = notebook(id), notebook.hasRecycleBin else { return [] } | ||
| 787 | return [ | ||
| 788 | UIAction(title: "Delete", image: UIImage(systemName: "trash"), attributes: .destructive) { [weak self] _ in | ||
| 789 | self?.confirmRecycling([path], of: notebook) | ||
| 790 | } | ||
| 791 | ] | ||
| 792 | default: return [] | ||
| 793 | } | ||
| 794 | } | ||
| 795 | |||
| 796 | /// Moves the sections and groups at `paths` to the notebook's recycle bin once confirmed. | ||
| 797 | private func confirmRecycling(_ paths: [String], of notebook: Notebook) { | ||
| 798 | let path = paths[0] | ||
| 799 | let tab = notebook.tabs.first { $0.path == path } | ||
| 800 | let title = paths.count > 1 | ||
| 801 | ? "Delete \(paths.count) Items?" : "Delete “\(tab?.name ?? path.split(separator: "/").last.map(String.init) ?? path)”?" | ||
| 802 | let message = | ||
| 803 | paths.count > 1 ? "They move to this notebook’s Recycle Bin." | ||
| 804 | : tab == nil ? "Its sections move to this notebook’s Recycle Bin." : "It moves to this notebook’s Recycle Bin." | ||
| 805 | let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) | ||
| 806 | alert.addAction(UIAlertAction(title: "Cancel", style: .cancel)) | ||
| 807 | alert.addAction(UIAlertAction(title: "Delete", style: .destructive) { [weak self] _ in | ||
| 808 | self?.setEditing(false, animated: true) | ||
| 809 | self?.recycle(paths[...], of: notebook) | ||
| 810 | }) | ||
| 811 | present(alert, animated: true) | ||
| 812 | } | ||
| 813 | |||
| 814 | private func recycle(_ paths: ArraySlice<String>, of notebook: Notebook) { | ||
| 815 | guard let path = paths.first, let library = notebook.handle, let release = Arranging.reserve() else { return } | ||
| 816 | for scene in UIApplication.shared.connectedScenes { | ||
| 817 | _ = (scene.delegate as? SceneDelegate)?.release(path, of: notebook) | ||
| 818 | } | ||
| 819 | let pointer = Int(bitPattern: library) | ||
| 820 | background({ sb_library_delete(OpaquePointer(bitPattern: pointer), path) }) { [weak self] deleted in | ||
| 821 | notebook.reload { | ||
| 822 | release() | ||
| 823 | NotificationCenter.default.post(name: Notebook.listed, object: notebook) | ||
| 824 | guard deleted else { | ||
| 825 | self?.alert("Can’t Delete", "Check that the notebook can be reached, then try again.") | ||
| 826 | return | ||
| 827 | } | ||
| 828 | self?.recycle(paths.dropFirst(), of: notebook) | ||
| 829 | } | ||
| 830 | } | ||
| 831 | } | ||
| 832 | |||
| 758 | override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { | 833 | override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { |
| 759 | guard let item = dataSource.itemIdentifier(for: indexPath) else { return false } | 834 | guard let item = dataSource.itemIdentifier(for: indexPath) else { return false } |
| 760 | if isEditing { | 835 | if isEditing { |
apps/ios/Snowbound/Notebooks.swift+13-3| ... | @@ -762,8 +762,11 @@ final class Section { | ... | @@ -762,8 +762,11 @@ final class Section { |
| 762 | return id | 762 | return id |
| 763 | } | 763 | } |
| 764 | 764 | ||
| 765 | /// Deletes pages, conflict pages for good and the rest to the recycle bin, which a toast | ||
| 766 | /// then offers. | ||
| 765 | func delete(_ ids: [String], done: @escaping () -> Void = {}) { | 767 | func delete(_ ids: [String], done: @escaping () -> Void = {}) { |
| 766 | guard let release = Arranging.reserve() else { return } | 768 | guard let release = Arranging.reserve() else { return } |
| 769 | let recycled = notebook.hasRecycleBin ? ids.filter { row(of: $0)?.version == nil }.count : 0 | ||
| 767 | let (date, time) = titleDate() | 770 | let (date, time) = titleDate() |
| 768 | let pointer = Int(bitPattern: handle) | 771 | let pointer = Int(bitPattern: handle) |
| 769 | background({ | 772 | background({ |
| ... | @@ -774,10 +777,17 @@ final class Section { | ... | @@ -774,10 +777,17 @@ final class Section { |
| 774 | }) { [self] deleted in | 777 | }) { [self] deleted in |
| 775 | refreshRows { | 778 | refreshRows { |
| 776 | release() | 779 | release() |
| 777 | if deleted { done() } | 780 | let window = UIApplication.shared.connectedScenes.lazy.compactMap { ($0 as? UIWindowScene)?.keyWindow }.first |
| 778 | else { | 781 | guard deleted else { |
| 779 | let window = UIApplication.shared.connectedScenes.lazy.compactMap { ($0 as? UIWindowScene)?.keyWindow }.first | ||
| 780 | window?.rootViewController?.alert("Can’t Delete", "Some pages couldn’t be deleted. Try again.") | 782 | window?.rootViewController?.alert("Can’t Delete", "Some pages couldn’t be deleted. Try again.") |
| 783 | return | ||
| 784 | } | ||
| 785 | done() | ||
| 786 | if recycled > 0, let window { | ||
| 787 | let title = recycled == 1 ? "Page Moved to Recycle Bin" : "\(recycled) Pages Moved to Recycle Bin" | ||
| 788 | SyncToast.show(title, "Tap to restore", symbol: "trash", hint: "Opens the Recycle Bin", in: window) { | ||
| 789 | [notebook = self.notebook] in RecycleBinViewController.present(notebook, in: window) | ||
| 790 | } | ||
| 781 | } | 791 | } |
| 782 | } | 792 | } |
| 783 | } | 793 | } |
apps/ios/Snowbound/Recycle.swift created+158| ... | @@ -0,0 +1,158 @@ | ||
| 1 | import UIKit | ||
| 2 | |||
| 3 | extension Notebook { | ||
| 4 | /// Whether the notebook keeps a recycle bin: a folder does, a lone section doesn't. | ||
| 5 | var hasRecycleBin: Bool { tabs.contains { !$0.path.isEmpty && !$0.path.hasPrefix("/") } } | ||
| 6 | } | ||
| 7 | |||
| 8 | /// OneNote's Notebook Recycle Bin: the pages and sections deleted from a notebook, each | ||
| 9 | /// restored to a section or folder the reader picks. | ||
| 10 | final class RecycleBinViewController: UITableViewController { | ||
| 11 | private static let deletedPages = "OneNote_RecycleBin/OneNote_DeletedPages.one" | ||
| 12 | |||
| 13 | private let notebook: Notebook | ||
| 14 | /// Deleted Pages, open while the bin shows. | ||
| 15 | private var deleted: Section? | ||
| 16 | private var sections: [Tab] = [] | ||
| 17 | |||
| 18 | /// Shows `notebook`'s bin as a sheet over the controller on top of `window`. | ||
| 19 | static func present(_ notebook: Notebook, in window: UIWindow?) { | ||
| 20 | var top = window?.rootViewController | ||
| 21 | while let presented = top?.presentedViewController { top = presented } | ||
| 22 | let navigation = UINavigationController(rootViewController: RecycleBinViewController(notebook: notebook)) | ||
| 23 | navigation.sheetPresentationController?.detents = [.medium(), .large()] | ||
| 24 | navigation.sheetPresentationController?.prefersGrabberVisible = true | ||
| 25 | top?.present(navigation, animated: true) | ||
| 26 | } | ||
| 27 | |||
| 28 | private init(notebook: Notebook) { | ||
| 29 | self.notebook = notebook | ||
| 30 | super.init(style: .insetGrouped) | ||
| 31 | title = "Recycle Bin" | ||
| 32 | } | ||
| 33 | |||
| 34 | required init?(coder: NSCoder) { fatalError() } | ||
| 35 | |||
| 36 | override func viewDidLoad() { | ||
| 37 | super.viewDidLoad() | ||
| 38 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: "binned") | ||
| 39 | navigationItem.rightBarButtonItem = UIBarButtonItem( | ||
| 40 | systemItem: .done, primaryAction: UIAction { [weak self] _ in self?.dismiss(animated: true) }) | ||
| 41 | NotificationCenter.default.addObserver(forName: Section.changed, object: nil, queue: .main) { [weak self] note in | ||
| 42 | if let self, note.object as AnyObject? === deleted { show() } | ||
| 43 | } | ||
| 44 | NotificationCenter.default.addObserver(forName: Notebook.listed, object: notebook, queue: .main) { [weak self] _ in | ||
| 45 | self?.reload() | ||
| 46 | } | ||
| 47 | var loading = UIContentUnavailableConfiguration.loading() | ||
| 48 | loading.text = "Opening…" | ||
| 49 | contentUnavailableConfiguration = loading | ||
| 50 | reload() | ||
| 51 | } | ||
| 52 | |||
| 53 | private var pages: [Row] { deleted?.rows ?? [] } | ||
| 54 | |||
| 55 | private func reload() { | ||
| 56 | guard let library = notebook.handle else { return } | ||
| 57 | let pointer = Int(bitPattern: library) | ||
| 58 | background({ decode([Tab].self, sb_library_recycle_bin(OpaquePointer(bitPattern: pointer))) }) { [weak self] tabs in | ||
| 59 | guard let self else { return } | ||
| 60 | guard let tabs else { | ||
| 61 | var failed = UIContentUnavailableConfiguration.empty() | ||
| 62 | failed.text = "Can’t Open Recycle Bin" | ||
| 63 | failed.secondaryText = "Check that the notebook can be reached, then try again." | ||
| 64 | contentUnavailableConfiguration = failed | ||
| 65 | return | ||
| 66 | } | ||
| 67 | sections = tabs.filter { $0.path != Self.deletedPages } | ||
| 68 | guard deleted == nil, let tab = tabs.first(where: { $0.path == Self.deletedPages }) else { return show() } | ||
| 69 | Section.open(tab, of: notebook) { [weak self] section, _ in | ||
| 70 | self?.deleted = section | ||
| 71 | self?.show() | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | private func show() { | ||
| 77 | tableView.reloadData() | ||
| 78 | var empty = UIContentUnavailableConfiguration.empty() | ||
| 79 | empty.image = UIImage(systemName: "trash") | ||
| 80 | empty.text = "No Deleted Pages or Sections" | ||
| 81 | empty.secondaryText = "Pages and sections you delete appear here." | ||
| 82 | contentUnavailableConfiguration = pages.isEmpty && sections.isEmpty ? empty : nil | ||
| 83 | } | ||
| 84 | |||
| 85 | /// The table's groups: Deleted Pages, then Deleted Sections, each where it has rows. | ||
| 86 | private var groups: [Int] { [0, 1].filter { $0 == 0 ? !pages.isEmpty : !sections.isEmpty } } | ||
| 87 | |||
| 88 | override func numberOfSections(in tableView: UITableView) -> Int { groups.count } | ||
| 89 | |||
| 90 | override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | ||
| 91 | groups[section] == 0 ? "Deleted Pages" : "Deleted Sections" | ||
| 92 | } | ||
| 93 | |||
| 94 | override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { | ||
| 95 | section == groups.count - 1 ? "Content here is deleted after 60 days." : nil | ||
| 96 | } | ||
| 97 | |||
| 98 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| 99 | groups[section] == 0 ? pages.count : sections.count | ||
| 100 | } | ||
| 101 | |||
| 102 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| 103 | let cell = tableView.dequeueReusableCell(withIdentifier: "binned", for: indexPath) | ||
| 104 | var content = cell.defaultContentConfiguration() | ||
| 105 | if groups[indexPath.section] == 0 { | ||
| 106 | let page = pages[indexPath.row] | ||
| 107 | content.text = page.title.isEmpty ? "Untitled Page" : page.title | ||
| 108 | content.image = UIImage(systemName: "doc.text") | ||
| 109 | } else { | ||
| 110 | let tab = sections[indexPath.row] | ||
| 111 | content.text = tab.name | ||
| 112 | content.image = UIImage(systemName: "rectangle.portrait.fill") | ||
| 113 | content.imageProperties.tintColor = tab.uiColor | ||
| 114 | } | ||
| 115 | cell.contentConfiguration = content | ||
| 116 | cell.selectionStyle = .none | ||
| 117 | var restore = UIButton.Configuration.plain() | ||
| 118 | restore.title = "Restore" | ||
| 119 | let button = UIButton(configuration: restore) | ||
| 120 | button.menu = menu(at: indexPath) | ||
| 121 | button.showsMenuAsPrimaryAction = true | ||
| 122 | button.sizeToFit() | ||
| 123 | cell.accessoryView = button | ||
| 124 | return cell | ||
| 125 | } | ||
| 126 | |||
| 127 | override func tableView( | ||
| 128 | _ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint | ||
| 129 | ) -> UIContextMenuConfiguration? { | ||
| 130 | let menu = menu(at: indexPath) | ||
| 131 | return UIContextMenuConfiguration(actionProvider: { _ in menu }) | ||
| 132 | } | ||
| 133 | |||
| 134 | /// Restore To: the notebook's sections for a page, its folders for a section, as the | ||
| 135 | /// desktop's Restore To offers them. | ||
| 136 | private func menu(at indexPath: IndexPath) -> UIMenu { | ||
| 137 | let place = { (path: String) in path.split(separator: "/").joined(separator: " › ") } | ||
| 138 | guard groups[indexPath.section] == 1 else { | ||
| 139 | let page = pages[indexPath.row].id | ||
| 140 | let choices = notebook.sections(besides: Self.deletedPages).map { tab in | ||
| 141 | UIAction(title: place(tab.group.isEmpty ? tab.name : tab.group + "/" + tab.name)) { [notebook] _ in | ||
| 142 | Arranging.move(page: page, of: notebook, from: Self.deletedPages, to: tab.path) | ||
| 143 | } | ||
| 144 | } | ||
| 145 | return UIMenu(title: "Restore To", children: choices) | ||
| 146 | } | ||
| 147 | let path = sections[indexPath.row].path | ||
| 148 | let file = path.split(separator: "/").last.map(String.init) ?? path | ||
| 149 | let choices = ([""] + notebook.groups).map { folder in | ||
| 150 | // A section of the same file name there would refuse it. | ||
| 151 | let taken = notebook.entries(in: folder).contains { $0.split(separator: "/").last.map(String.init) == file } | ||
| 152 | return UIAction(title: folder.isEmpty ? notebook.name : place(folder), attributes: taken ? .disabled : []) { | ||
| 153 | [notebook] _ in Arranging.place(path, of: notebook, in: folder) | ||
| 154 | } | ||
| 155 | } | ||
| 156 | return UIMenu(title: "Restore To", children: choices) | ||
| 157 | } | ||
| 158 | } | ||
apps/ios/Snowbound/Sync.swift+6-3| ... | @@ -136,7 +136,10 @@ enum Sync { | ... | @@ -136,7 +136,10 @@ enum Sync { |
| 136 | /// A passing note at the top of `window` that opens `details` when tapped, for a change the | 136 | /// A passing note at the top of `window` that opens `details` when tapped, for a change the |
| 137 | /// reader would otherwise miss. | 137 | /// reader would otherwise miss. |
| 138 | enum SyncToast { | 138 | enum SyncToast { |
| 139 | static func show(_ title: String, _ detail: String, in window: UIWindow, details: @escaping () -> Void) { | 139 | static func show( |
| 140 | _ title: String, _ detail: String, symbol: String = "exclamationmark.icloud", hint: String = "Shows sync status", | ||
| 141 | in window: UIWindow, details: @escaping () -> Void | ||
| 142 | ) { | ||
| 140 | var configuration: UIButton.Configuration | 143 | var configuration: UIButton.Configuration |
| 141 | if #available(iOS 26, *) { | 144 | if #available(iOS 26, *) { |
| 142 | configuration = .glass() | 145 | configuration = .glass() |
| ... | @@ -146,12 +149,12 @@ enum SyncToast { | ... | @@ -146,12 +149,12 @@ enum SyncToast { |
| 146 | } | 149 | } |
| 147 | configuration.title = title | 150 | configuration.title = title |
| 148 | configuration.subtitle = detail | 151 | configuration.subtitle = detail |
| 149 | configuration.image = UIImage(systemName: "exclamationmark.icloud") | 152 | configuration.image = UIImage(systemName: symbol) |
| 150 | configuration.imagePadding = 10 | 153 | configuration.imagePadding = 10 |
| 151 | configuration.titleLineBreakMode = .byTruncatingMiddle | 154 | configuration.titleLineBreakMode = .byTruncatingMiddle |
| 152 | configuration.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 16, bottom: 10, trailing: 20) | 155 | configuration.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 16, bottom: 10, trailing: 20) |
| 153 | let toast = UIButton(configuration: configuration) | 156 | let toast = UIButton(configuration: configuration) |
| 154 | toast.accessibilityHint = "Shows sync status" | 157 | toast.accessibilityHint = hint |
| 155 | toast.translatesAutoresizingMaskIntoConstraints = false | 158 | toast.translatesAutoresizingMaskIntoConstraints = false |
| 156 | toast.alpha = 0 | 159 | toast.alpha = 0 |
| 157 | let dismiss = { [weak toast] in | 160 | let dismiss = { [weak toast] in |