Fix swipe actions on iOS 13
This commit is contained in:
parent
2232bb8fb7
commit
940ba6d6cb
|
@ -133,18 +133,15 @@ class ConversationTableViewController: EnhancedTableViewController {
|
|||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -120,18 +120,15 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
|||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
@objc func refreshNotifications(_ sender: Any) {
|
||||
|
|
|
@ -206,18 +206,15 @@ class ProfileTableViewController: EnhancedTableViewController, PreferencesAdapti
|
|||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
@objc func refreshStatuses(_ sender: Any) {
|
||||
|
|
|
@ -124,18 +124,15 @@ class TimelineTableViewController: EnhancedTableViewController {
|
|||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
return nil
|
||||
return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
||||
}
|
||||
|
||||
@objc func refreshStatuses(_ sender: Any) {
|
||||
|
|
|
@ -257,19 +257,6 @@ class StatusTableViewCell: UITableViewCell, PreferencesAdaptive {
|
|||
|
||||
extension StatusTableViewCell: TableViewSwipeActionProvider {
|
||||
|
||||
static var favoriteActionImage: UIImage = UIGraphicsImageRenderer(size: CGSize(width: 30 * 137/131, height: 30)).image { _ in
|
||||
UIImage(named: "Favorite")!.draw(in: CGRect(x: 0, y: 0, width: 30 * 137/131, height: 30))
|
||||
}
|
||||
static var reblogActionImage: UIImage = UIGraphicsImageRenderer(size: CGSize(width: 30 * 927/558, height: 30)).image { _ in
|
||||
UIImage(named: "Reblog")!.draw(in: CGRect(x: 0, y: 0, width: 30 * 927/558, height: 30))
|
||||
}
|
||||
static var replyActionImage: UIImage = UIGraphicsImageRenderer(size: CGSize(width: 30 * 205/151, height: 30)).image { _ in
|
||||
UIImage(named: "Reply")!.draw(in: CGRect(x: 0, y: 0, width: 30 * 205/151, height: 30))
|
||||
}
|
||||
static var moreActionImage: UIImage = UIGraphicsImageRenderer(size: CGSize(width: 30 * 2/1, height: 30)).image { _ in
|
||||
UIImage(named: "More")!.draw(in: CGRect(x: 0, y: 0, width: 30 * 2/1, height: 30))
|
||||
}
|
||||
|
||||
func leadingSwipeActionsConfiguration() -> UISwipeActionsConfiguration? {
|
||||
guard let status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
|
||||
|
||||
|
@ -299,7 +286,7 @@ extension StatusTableViewCell: TableViewSwipeActionProvider {
|
|||
}
|
||||
})
|
||||
}
|
||||
favorite.image = StatusTableViewCell.favoriteActionImage
|
||||
favorite.image = UIImage(systemName: "star.fill")
|
||||
favorite.backgroundColor = favoriteColor
|
||||
|
||||
let reblogTitle: String
|
||||
|
@ -327,7 +314,7 @@ extension StatusTableViewCell: TableViewSwipeActionProvider {
|
|||
}
|
||||
})
|
||||
}
|
||||
reblog.image = StatusTableViewCell.reblogActionImage
|
||||
reblog.image = UIImage(systemName: "repeat")
|
||||
reblog.backgroundColor = reblogColor
|
||||
|
||||
return UISwipeActionsConfiguration(actions: [favorite, reblog])
|
||||
|
@ -338,13 +325,13 @@ extension StatusTableViewCell: TableViewSwipeActionProvider {
|
|||
completion(true)
|
||||
self.delegate?.reply(to: self.statusID)
|
||||
}
|
||||
reply.image = StatusTableViewCell.replyActionImage
|
||||
reply.image = UIImage(systemName: "arrowshape.turn.up.left.fill")
|
||||
reply.backgroundColor = tintColor
|
||||
let more = UIContextualAction(style: .normal, title: "More") { (action, view, completion) in
|
||||
completion(true)
|
||||
self.delegate?.showMoreOptions(forStatus: self.statusID)
|
||||
}
|
||||
more.image = StatusTableViewCell.moreActionImage
|
||||
more.image = UIImage(systemName: "ellipsis")
|
||||
more.backgroundColor = .gray
|
||||
return UISwipeActionsConfiguration(actions: [reply, more])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue