Skip to content

Commit 665f753

Browse files
committed
Add cell swipe for all actions
1 parent 149a78c commit 665f753

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,21 @@ extension OrderListViewController: UITableViewDelegate {
635635
func scrollViewDidScroll(_ scrollView: UIScrollView) {
636636
delegate?.orderListScrollViewDidScroll(scrollView)
637637
}
638+
639+
/// Provide an implementation to show cell swipe actions. Return `nil` to provide no action.
640+
///
641+
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
642+
643+
let markAsCompletedAction = UIContextualAction(style: .normal, title: Localization.markCompleted, handler: { _, _, completionHandler in
644+
print("Mark as completed triggered...")
645+
// TODO: Fire real action
646+
completionHandler(true) // Tells the table that the action was performed and forces it to go back to its original state (un-swiped)
647+
})
648+
markAsCompletedAction.backgroundColor = .brand
649+
markAsCompletedAction.image = .checkmarkImage
650+
651+
return UISwipeActionsConfiguration(actions: [markAsCompletedAction])
652+
}
638653
}
639654

640655
// MARK: - Finite State Machine Management
@@ -743,6 +758,8 @@ private extension OrderListViewController {
743758
comment: "Message for empty Orders filtered results. The %@ is a placeholder for the filters entered by the user.")
744759
static let clearButton = NSLocalizedString("Clear Filters",
745760
comment: "Action to remove filters orders on the placeholder overlay when no orders match the filter on the Order List")
761+
762+
static let markCompleted = NSLocalizedString("Mark Completed", comment: "Title for the swipe order action to mark it as completed")
746763
}
747764

748765
enum Settings {

0 commit comments

Comments
 (0)