Skip to content

Commit 6f053e5

Browse files
committed
Add refresh control to coupon list
1 parent c2e7194 commit 6f053e5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

WooCommerce/Classes/ViewRelated/Coupons/CouponListViewController.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ final class CouponListViewController: UIViewController {
1010
///
1111
private var emptyStateViewController: UIViewController?
1212

13+
/// Pull To Refresh Support.
14+
///
15+
private lazy var refreshControl: UIRefreshControl = {
16+
let refreshControl = UIRefreshControl()
17+
refreshControl.addTarget(self, action: #selector(refreshCouponList), for: .valueChanged)
18+
return refreshControl
19+
}()
20+
1321
private var subscriptions: Set<AnyCancellable> = []
1422

1523
init(siteID: Int64) {
@@ -53,6 +61,13 @@ final class CouponListViewController: UIViewController {
5361
}
5462
}
5563

64+
// MARK: - Actions
65+
private extension CouponListViewController {
66+
@objc func refreshCouponList() {
67+
viewModel.refreshCoupons()
68+
}
69+
}
70+
5671

5772
// MARK: - View Configuration
5873
//
@@ -66,6 +81,7 @@ private extension CouponListViewController {
6681
tableView.dataSource = self
6782
tableView.estimatedRowHeight = Constants.estimatedRowHeight
6883
tableView.rowHeight = UITableView.automaticDimension
84+
tableView.addSubview(refreshControl)
6985
}
7086

7187
func registerTableViewCells() {

0 commit comments

Comments
 (0)