Fix swipe actions on iOS 13

This commit is contained in:
Shadowfacts 2019-06-13 19:31:36 -07:00
parent 2232bb8fb7
commit 940ba6d6cb
Signed by untrusted user: shadowfacts
GPG Key ID: 83FB3304046BADA4
5 changed files with 16 additions and 41 deletions

View File

@ -133,18 +133,15 @@ class ConversationTableViewController: EnhancedTableViewController {
} }
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider return true
return false
} }
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
return nil
} }
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
return nil
} }
} }

View File

@ -120,18 +120,15 @@ class NotificationsTableViewController: EnhancedTableViewController {
} }
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider return true
return false
} }
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
return nil
} }
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
return nil
} }
@objc func refreshNotifications(_ sender: Any) { @objc func refreshNotifications(_ sender: Any) {

View File

@ -206,18 +206,15 @@ class ProfileTableViewController: EnhancedTableViewController, PreferencesAdapti
} }
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider return true
return false
} }
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
return nil
} }
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
return nil
} }
@objc func refreshStatuses(_ sender: Any) { @objc func refreshStatuses(_ sender: Any) {

View File

@ -124,18 +124,15 @@ class TimelineTableViewController: EnhancedTableViewController {
} }
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// return tableView.cellForRow(at: indexPath) is TableViewSwipeActionProvider return true
return false
} }
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.leadingSwipeActionsConfiguration()
return nil
} }
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration() return (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
return nil
} }
@objc func refreshStatuses(_ sender: Any) { @objc func refreshStatuses(_ sender: Any) {

View File

@ -257,19 +257,6 @@ class StatusTableViewCell: UITableViewCell, PreferencesAdaptive {
extension StatusTableViewCell: TableViewSwipeActionProvider { 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? { func leadingSwipeActionsConfiguration() -> UISwipeActionsConfiguration? {
guard let status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") } 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 favorite.backgroundColor = favoriteColor
let reblogTitle: String let reblogTitle: String
@ -327,7 +314,7 @@ extension StatusTableViewCell: TableViewSwipeActionProvider {
} }
}) })
} }
reblog.image = StatusTableViewCell.reblogActionImage reblog.image = UIImage(systemName: "repeat")
reblog.backgroundColor = reblogColor reblog.backgroundColor = reblogColor
return UISwipeActionsConfiguration(actions: [favorite, reblog]) return UISwipeActionsConfiguration(actions: [favorite, reblog])
@ -338,13 +325,13 @@ extension StatusTableViewCell: TableViewSwipeActionProvider {
completion(true) completion(true)
self.delegate?.reply(to: self.statusID) self.delegate?.reply(to: self.statusID)
} }
reply.image = StatusTableViewCell.replyActionImage reply.image = UIImage(systemName: "arrowshape.turn.up.left.fill")
reply.backgroundColor = tintColor reply.backgroundColor = tintColor
let more = UIContextualAction(style: .normal, title: "More") { (action, view, completion) in let more = UIContextualAction(style: .normal, title: "More") { (action, view, completion) in
completion(true) completion(true)
self.delegate?.showMoreOptions(forStatus: self.statusID) self.delegate?.showMoreOptions(forStatus: self.statusID)
} }
more.image = StatusTableViewCell.moreActionImage more.image = UIImage(systemName: "ellipsis")
more.backgroundColor = .gray more.backgroundColor = .gray
return UISwipeActionsConfiguration(actions: [reply, more]) return UISwipeActionsConfiguration(actions: [reply, more])
} }