Skip to content

Commit

Permalink
Enable long-press in search
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Nov 3, 2023
1 parent 9ef392b commit b6317e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe
}

func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
guard indexPath.section == Section.pages.rawValue else { return nil }
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
guard let self else { return nil }
let page = self.pages[indexPath.row]
let cell = self.tableView.cellForRow(at: indexPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ final class PostSearchViewController: UIViewController, UITableViewDelegate, UIS
}
}

func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
guard indexPath.section == SectionID.posts.rawValue else { return nil }
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in
guard let self, let delegate = self.delegate else { return nil }
let post = self.viewModel.posts[indexPath.row]
let cell = self.tableView.cellForRow(at: indexPath)
return AbstractPostHelper.makeContextMenu(for: post, presentingView: cell, delegate: delegate)
}
}

func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
guard let delegate, indexPath.section == SectionID.posts.rawValue else { return nil }
let actions = AbstractPostHelper.makeLeadingContextualActions(for: viewModel.posts[indexPath.row], delegate: delegate)
Expand Down

0 comments on commit b6317e7

Please sign in to comment.