Skip to content

Commit

Permalink
add pull to refresh to shops
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed May 6, 2024
1 parent da51dcb commit 1b71a0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion HabitRPG/UI/General/MainMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class MainMenuViewController: BaseTableViewController {
seasonText = L10n.isOpen
}
menuItem(withKey: .seasonalShop).pillText = seasonText
tableView.reloadSections(IndexSet(integer: 1), with: .none)
tableView.reloadData()
}

override func applyTheme(theme: Theme) {
Expand Down
12 changes: 11 additions & 1 deletion HabitRPG/UI/Inventory/ShopViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class ShopViewController: BaseCollectionViewController, ShopCollectionViewDataSo
private var gemView = CurrencyCountView(currency: .gem)
private var goldView = CurrencyCountView(currency: .gold)

var refresher:UIRefreshControl!


override func viewDidLoad() {
super.viewDidLoad()
topHeaderCoordinator?.alternativeHeader = bannerView
Expand All @@ -76,6 +79,10 @@ class ShopViewController: BaseCollectionViewController, ShopCollectionViewDataSo
refresh()

HabiticaAnalytics.shared.logNavigationEvent("navigated \(shopIdentifier ?? "") screen")

refresher = HabiticaRefresControl()
refresher.addTarget(self, action: #selector(refresh), for: .valueChanged)
collectionView.addSubview(refresher)
}

private var isSubscribed: Bool?
Expand Down Expand Up @@ -143,8 +150,11 @@ class ShopViewController: BaseCollectionViewController, ShopCollectionViewDataSo
dataSource?.dispose()
}

@objc
private func refresh() {
dataSource?.retrieveShopInventory(nil)
dataSource?.retrieveShopInventory({
self.refresher.endRefreshing()
})
}

func didSelectItem(_ item: InAppRewardProtocol?) {
Expand Down

0 comments on commit 1b71a0c

Please sign in to comment.