diff --git a/HabitRPG/Storyboards/Base.lproj/Main.storyboard b/HabitRPG/Storyboards/Base.lproj/Main.storyboard
index 0e75e73f0..00d7e37c3 100644
--- a/HabitRPG/Storyboards/Base.lproj/Main.storyboard
+++ b/HabitRPG/Storyboards/Base.lproj/Main.storyboard
@@ -1632,104 +1632,104 @@
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
-
+
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
-
-
+
@@ -1743,7 +1743,6 @@
-
diff --git a/HabitRPG/TableViewDataSources/EquipmentViewDataSource.swift b/HabitRPG/TableViewDataSources/EquipmentViewDataSource.swift
index 322b7ab7d..d4881deed 100644
--- a/HabitRPG/TableViewDataSources/EquipmentViewDataSource.swift
+++ b/HabitRPG/TableViewDataSources/EquipmentViewDataSource.swift
@@ -30,7 +30,15 @@ class EquipmentViewDataSource: BaseReactiveTableViewDataSource {
private func buildGearSignalProducer(keys: [String], gearType: String, search: String?) -> SignalProducer, Never> {
let predicate: NSPredicate
if let search = search {
- predicate = NSPredicate(format: "key IN %@ && type == %@ && (text CONTAINS[cd] %@ || notes CONTAINS[cd] %@)", keys, gearType, search, search)
+ var predicateString = ""
+ for (index, word) in search.split(separator: " ").enumerated() {
+ if index != 0 {
+ predicateString.append(" || ")
+ }
+ predicateString.append("text CONTAINS[cd] \"\(word)\" || notes CONTAINS[cd] \"\(word)\"")
+ }
+
+ predicate = NSPredicate(format: "key IN %@ && type == %@ && (\(predicateString))", keys, gearType)
} else {
predicate = NSPredicate(format: "key IN %@ && type == %@", keys, gearType)
}
diff --git a/HabitRPG/TableviewCells/Inventory/EquipmentCell.swift b/HabitRPG/TableviewCells/Inventory/EquipmentCell.swift
index d9f8f41fa..5f8ad8210 100644
--- a/HabitRPG/TableviewCells/Inventory/EquipmentCell.swift
+++ b/HabitRPG/TableviewCells/Inventory/EquipmentCell.swift
@@ -14,7 +14,6 @@ class EquipmentCell: UITableViewCell {
@IBOutlet weak var gearImageView: NetworkImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var descriptionlabel: UILabel!
- @IBOutlet weak var twoHandedSpacing: NSLayoutConstraint!
@IBOutlet weak var twoHandedView: UIView!
@IBOutlet weak var twoHandedIconView: UIImageView!
@IBOutlet weak var twoHandedLabel: UILabel!
@@ -52,10 +51,8 @@ class EquipmentCell: UITableViewCell {
if gear.twoHanded {
twoHandedView.isHidden = false
- twoHandedSpacing.constant = 28
} else {
twoHandedView.isHidden = true
- twoHandedSpacing.constant = 4
}
strengthLabel.isHidden = true
diff --git a/HabitRPG/UI/Inventory/EquipmentDetailViewController.swift b/HabitRPG/UI/Inventory/EquipmentDetailViewController.swift
index 3cabbfba7..3ad4fd29b 100644
--- a/HabitRPG/UI/Inventory/EquipmentDetailViewController.swift
+++ b/HabitRPG/UI/Inventory/EquipmentDetailViewController.swift
@@ -33,18 +33,15 @@ class EquipmentDetailViewController: BaseTableViewController, UISearchResultsUpd
searchController.hidesNavigationBarDuringPresentation = false
navigationItem.backButtonDisplayMode = .minimal
navigationItem.backButtonTitle = nil
+ navigationItem.title = nil
if #available(iOS 16.0, *) {
self.navigationItem.preferredSearchBarPlacement = .inline
- searchController.scopeBarActivation = .onTextEntry
- searchController.searchSuggestions = [
- UISearchSuggestionItem(localizedSuggestion: "Spring Gear"),
- UISearchSuggestionItem(localizedSuggestion: "Summer Gear"),
- UISearchSuggestionItem(localizedSuggestion: "Autumn Gear"),
- UISearchSuggestionItem(localizedSuggestion: "Winter Gear"),
- UISearchSuggestionItem(localizedSuggestion: "Subscriber Item")
- ]
+ searchController.scopeBarActivation = .automatic
+ updateSearchSuggestions(withInput: nil)
}
+ searchController.searchBar.showsCancelButton = false
searchController.searchResultsUpdater = self
+ tableView.keyboardDismissMode = .onDrag
}
override func applyTheme(theme: any Theme) {
@@ -67,9 +64,30 @@ class EquipmentDetailViewController: BaseTableViewController, UISearchResultsUpd
} else {
datasource?.searchString = nil
}
+ updateSearchSuggestions(withInput: searchController.searchBar.text)
self.tableView.reloadData()
}
+ func updateSearchSuggestions(withInput input: String?) {
+ if #available(iOS 16.0, *) {
+ let allSuggestions = [
+ UISearchSuggestionItem(localizedSuggestion: "Spring Gear"),
+ UISearchSuggestionItem(localizedSuggestion: "Summer Gear"),
+ UISearchSuggestionItem(localizedSuggestion: "Autumn Gear"),
+ UISearchSuggestionItem(localizedSuggestion: "Winter Gear"),
+ UISearchSuggestionItem(localizedSuggestion: "Subscriber Item"),
+ UISearchSuggestionItem(localizedSuggestion: "Enchanted Armoire")
+ ]
+ if input?.isEmpty ?? true {
+ searchController.searchSuggestions = allSuggestions
+ } else {
+ searchController.searchSuggestions = allSuggestions.filter({ item in
+ return item.localizedSuggestion?.lowercased().contains(input?.lowercased() ?? "") != false
+ })
+ }
+ }
+ }
+
@available(iOS 16.0, *)
func updateSearchResults(for searchController: UISearchController, selecting searchSuggestion: any UISearchSuggestion) {
searchController.searchBar.text = searchSuggestion.localizedSuggestion