Showing
1 changed file
with
19 additions
and
11 deletions
| ... | @@ -22,6 +22,16 @@ import SwiftEventBus | ... | @@ -22,6 +22,16 @@ import SwiftEventBus |
| 22 | super.viewDidLoad() | 22 | super.viewDidLoad() |
| 23 | 23 | ||
| 24 | self.hidesBottomBarWhenPushed = true | 24 | self.hidesBottomBarWhenPushed = true |
| 25 | + | ||
| 26 | + SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in | ||
| 27 | + | ||
| 28 | + DispatchQueue.main.async { | ||
| 29 | + self.coupons = swiftApi().getCouponList() | ||
| 30 | + self.tableView.reloadData() | ||
| 31 | + | ||
| 32 | + self.handleEmptyView() | ||
| 33 | + } | ||
| 34 | + } | ||
| 25 | 35 | ||
| 26 | getCouponsRequest() | 36 | getCouponsRequest() |
| 27 | 37 | ||
| ... | @@ -50,6 +60,13 @@ import SwiftEventBus | ... | @@ -50,6 +60,13 @@ import SwiftEventBus |
| 50 | self.coupons = swiftApi().getCouponList() | 60 | self.coupons = swiftApi().getCouponList() |
| 51 | self.tableView.reloadData() | 61 | self.tableView.reloadData() |
| 52 | 62 | ||
| 63 | + self.handleEmptyView() | ||
| 64 | + | ||
| 65 | + self.navigationController?.hideHairline() | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + // MARK: - Functions | ||
| 69 | + func handleEmptyView() { | ||
| 53 | if (self.coupons.count == 0) { | 70 | if (self.coupons.count == 0) { |
| 54 | self.emptyView.isHidden = false | 71 | self.emptyView.isHidden = false |
| 55 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | 72 | self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height |
| ... | @@ -57,10 +74,7 @@ import SwiftEventBus | ... | @@ -57,10 +74,7 @@ import SwiftEventBus |
| 57 | self.emptyView.isHidden = true | 74 | self.emptyView.isHidden = true |
| 58 | self.emptyViewHeight.constant = 0 | 75 | self.emptyViewHeight.constant = 0 |
| 59 | } | 76 | } |
| 60 | - | ||
| 61 | - self.navigationController?.hideHairline() | ||
| 62 | } | 77 | } |
| 63 | - | ||
| 64 | 78 | ||
| 65 | // MARK: - API Functions | 79 | // MARK: - API Functions |
| 66 | func getCouponsRequest() { | 80 | func getCouponsRequest() { |
| ... | @@ -77,15 +91,9 @@ import SwiftEventBus | ... | @@ -77,15 +91,9 @@ import SwiftEventBus |
| 77 | 91 | ||
| 78 | DispatchQueue.main.async { | 92 | DispatchQueue.main.async { |
| 79 | SwiftEventBus.post("coupons_fetched") | 93 | SwiftEventBus.post("coupons_fetched") |
| 80 | - self.tableView.reloadData() | 94 | + // self.tableView.reloadData() |
| 81 | 95 | ||
| 82 | - if (self.coupons.count == 0) { | 96 | + // self.handleEmptyView() |
| 83 | - self.emptyView.isHidden = false | ||
| 84 | - self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | ||
| 85 | - } else { | ||
| 86 | - self.emptyView.isHidden = true | ||
| 87 | - self.emptyViewHeight.constant = 0 | ||
| 88 | - } | ||
| 89 | } | 97 | } |
| 90 | } else { | 98 | } else { |
| 91 | self.coupons = [] | 99 | self.coupons = [] | ... | ... |
-
Please register or login to post a comment