Skip to content

Commit

Permalink
shop improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Jun 25, 2024
1 parent 66e84a8 commit 7efc47b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
3 changes: 2 additions & 1 deletion HabitRPG/Storyboards/Base.lproj/BuyModal.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<device id="retina6_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -212,6 +212,7 @@
<outlet property="buttonSeparatorView" destination="fqA-Gf-Y0Z" id="7hi-Wq-ccF"/>
<outlet property="buyButton" destination="e3z-QN-KcI" id="85Z-iK-947"/>
<outlet property="buyLabel" destination="j5D-EL-LRQ" id="IV9-ti-otW"/>
<outlet property="centerConstraint" destination="99Z-Bp-NiO" id="twd-eL-g4k"/>
<outlet property="closableShopModal" destination="di7-JQ-KmH" id="hna-9x-zD3"/>
<outlet property="closeButton" destination="TiK-yj-cOf" id="fuP-3h-sg6"/>
<outlet property="currencyCountView" destination="few-vN-72G" id="eqo-2s-TW3"/>
Expand Down
20 changes: 10 additions & 10 deletions HabitRPG/TableViewDataSources/ItemsViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class ItemsViewDataSource: BaseReactiveTableViewDataSource<ItemProtocol> {
var itemType: String? {
didSet {
if itemType != nil {
sections.forEach { section in
section.isHidden = section.key != itemType
}
sections.forEach { section in
section.isHidden = section.key != itemType
}
} else {
sections.forEach { section in
section.isHidden = false
Expand Down Expand Up @@ -154,11 +154,11 @@ class ItemsViewDataSource: BaseReactiveTableViewDataSource<ItemProtocol> {
}

override func numberOfSections(in tableView: UITableView) -> Int {
return sections.count
return visibleSections.count
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var count = sections[section].items.count
var count = visibleSections[section].items.count
// swiftlint:disable:next empty_count
if count == 0 {
count = 1
Expand All @@ -167,10 +167,10 @@ class ItemsViewDataSource: BaseReactiveTableViewDataSource<ItemProtocol> {
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if sections.isEmpty {
if visibleSections.isEmpty {
return nil
}
return sections[section].title
return visibleSections[section].title
}

override func item(at indexPath: IndexPath?) -> ItemProtocol? {
Expand All @@ -180,9 +180,9 @@ class ItemsViewDataSource: BaseReactiveTableViewDataSource<ItemProtocol> {
if indexPath.item < 0 || indexPath.section < 0 {
return nil
}
if indexPath.section < sections.count {
if indexPath.item < sections[indexPath.section].items.count {
return sections[indexPath.section].items[indexPath.item]
if indexPath.section < visibleSections.count {
if indexPath.item < visibleSections[indexPath.section].items.count {
return visibleSections[indexPath.section].items[indexPath.item]
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TimeTravelersCollectionViewDataSource: ShopCollectionViewDataSource {
let newItem = inventoryRepository.getNewInAppReward()
let key = item.category?.identifier ?? ""
newItem.text = item.category?.text
newItem.notes = item.category?.notes ?? item.notes
newItem.key = key
newItem.pinType = item.pinType ?? "mystery_set"
newItem.purchaseType = newItem.pinType
Expand Down
13 changes: 2 additions & 11 deletions HabitRPG/UI/General/MainMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MenuItem {
MenuItem(key: .market, title: L10n.Locations.market, segue: StoryboardSegue.Main.showMarketSegue.rawValue),
MenuItem(key: .questShop, title: L10n.Menu.questShop, segue: StoryboardSegue.Main.showQuestShopSegue.rawValue),
MenuItem(key: .seasonalShop, title: L10n.Locations.seasonalShop, segue: StoryboardSegue.Main.showSeasonalShopSegue.rawValue),
MenuItem(key: .customizationShop, title: L10n.Locations.customizations, segue: StoryboardSegue.Main.showCustomizationShopSegue.rawValue, isHidden: true),
MenuItem(key: .customizationShop, title: L10n.Locations.customizations, segue: StoryboardSegue.Main.showCustomizationShopSegue.rawValue),
MenuItem(key: .timeTravelersShop, title: L10n.Locations.timeTravelersShop, segue: StoryboardSegue.Main.showTimeTravelersSegue.rawValue),
MenuItem(key: .customizeAvatar, title: L10n.Menu.customizeAvatar, vcInstantiator: StoryboardScene.Main.avatarOverviewViewController.instantiate),
MenuItem(key: .equipment, title: L10n.Titles.equipment, vcInstantiator: StoryboardScene.Main.equipmentOverviewViewController.instantiate),
Expand Down Expand Up @@ -388,11 +388,6 @@ class MainMenuViewController: BaseTableViewController {
self?.updatePromoCells()
})
}

if configRepository.bool(variable: .enableCustomizationShop) {
menuItem(withKey: .customizationShop).isHidden = false
tableView.reloadData()
}
}

private func updatePromoCells() {
Expand Down Expand Up @@ -434,11 +429,7 @@ class MainMenuViewController: BaseTableViewController {
case "fall":
seasonText = L10n.fall
default:
if configRepository.bool(variable: .enableCustomizationShop) {
seasonText = L10n.isOpen
} else {
seasonText = L10n.isClosed
}
seasonText = L10n.isOpen
}
menuItem(withKey: .seasonalShop).pillText = seasonText
tableView.reloadData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import ReactiveSwift

public class SyncUserStatsCall: ResponseObjectCall<UserProtocol, APIUser> {
public init() {
super.init(httpMethod: .GET, endpoint: "user/stat-sync")
super.init(httpMethod: .POST, endpoint: "user/stat-sync")
}
}

0 comments on commit 7efc47b

Please sign in to comment.