Skip to content

Add swipe actions for sharing, copying, and deleting entries #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Clip/History/HistoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,38 @@ extension HistoryViewController
{
self.showMenu(at: indexPath)
}

override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
let copyAction = UIContextualAction(style: .normal, title: "Copy") { (action, view, cb) in
let item = self.dataSource.item(at: indexPath)
self.selectedItem = item
self.copy(action)
cb(true)
}
copyAction.backgroundColor = .systemBlue
return UISwipeActionsConfiguration(actions: [
copyAction,
UIContextualAction(style: .normal, title: "Share…") { (action, view, cb) in
let item = self.dataSource.item(at: indexPath)
self.selectedItem = item
self._share(action)
cb(true)
}
])
}

override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
UISwipeActionsConfiguration(actions: [
UIContextualAction(style: .destructive, title: "Delete") { (action, view, cb) in
let item = self.dataSource.item(at: indexPath)
self.selectedItem = item
self.delete(action)
cb(true)
}
])
}
}

extension HistoryViewController: UIPopoverPresentationControllerDelegate
Expand Down