Commit 00756a75 authored by Zac Wood's avatar Zac Wood
Browse files

Fixes filters on iPad

parent 61c04940
...@@ -812,6 +812,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate, ...@@ -812,6 +812,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let filterView = destination.topViewController as! FiltersTableViewController let filterView = destination.topViewController as! FiltersTableViewController
filterView.facilities = self.facilitiesArray filterView.facilities = self.facilitiesArray
filterView.filters = self.filters filterView.filters = self.filters
filterView.updateFacilities = reloadWithFilters
} }
// Pass the selected object to the new view controller. // Pass the selected object to the new view controller.
......
...@@ -14,6 +14,7 @@ class FilterSelectionTableViewController: UITableViewController { ...@@ -14,6 +14,7 @@ class FilterSelectionTableViewController: UITableViewController {
var getFunc: (() -> [String: Bool])! var getFunc: (() -> [String: Bool])!
var selectFunc: ((String, Bool) -> Bool)! var selectFunc: ((String, Bool) -> Bool)!
var selectAllFunc: (() -> Bool)! var selectAllFunc: (() -> Bool)!
var updateFacilities: (() -> Void)!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -96,6 +97,7 @@ class FilterSelectionTableViewController: UITableViewController { ...@@ -96,6 +97,7 @@ class FilterSelectionTableViewController: UITableViewController {
_ = selectFunc((tableCell?.textLabel?.text)!.lowercased(), res) _ = selectFunc((tableCell?.textLabel?.text)!.lowercased(), res)
tableView.reloadData() tableView.reloadData()
} }
updateFacilities()
} }
......
...@@ -11,6 +11,8 @@ import RealmSwift ...@@ -11,6 +11,8 @@ import RealmSwift
class FiltersTableViewController: UITableViewController { class FiltersTableViewController: UITableViewController {
var updateFacilities: (() -> Void)!
override var preferredStatusBarStyle: UIStatusBarStyle { override var preferredStatusBarStyle: UIStatusBarStyle {
return .default return .default
} }
...@@ -35,6 +37,7 @@ class FiltersTableViewController: UITableViewController { ...@@ -35,6 +37,7 @@ class FiltersTableViewController: UITableViewController {
filters.onlyFromCategories = c filters.onlyFromCategories = c
filters.onlyFromLocations = l filters.onlyFromLocations = l
tableView.reloadData() tableView.reloadData()
updateFacilities()
} }
var filters: Filters! var filters: Filters!
var facilities: List<Facility>! var facilities: List<Facility>!
...@@ -72,6 +75,10 @@ class FiltersTableViewController: UITableViewController { ...@@ -72,6 +75,10 @@ class FiltersTableViewController: UITableViewController {
// self.navigationItem.rightBarButtonItem = self.editButtonItem() // self.navigationItem.rightBarButtonItem = self.editButtonItem()
} }
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
updateFacilities?()
}
override func didReceiveMemoryWarning() { override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning() super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
...@@ -242,6 +249,7 @@ class FiltersTableViewController: UITableViewController { ...@@ -242,6 +249,7 @@ class FiltersTableViewController: UITableViewController {
let cell = tableView.cellForRow(at: indexPath) let cell = tableView.cellForRow(at: indexPath)
cell?.isSelected = false cell?.isSelected = false
updateFacilities()
//nothing is selected forever //nothing is selected forever
} }
...@@ -307,11 +315,12 @@ class FiltersTableViewController: UITableViewController { ...@@ -307,11 +315,12 @@ class FiltersTableViewController: UITableViewController {
if(segue.identifier == "toFilters") { if(segue.identifier == "toFilters") {
let destination = segue.destination as! FacilitiesListViewController let destination = segue.destination as! FacilitiesListViewController
destination.filters = self.filters destination.filters = self.filters
updateFacilities()
} }
else if(segue.identifier == "toSelection") { else if(segue.identifier == "toSelection") {
let destination = segue.destination as! FilterSelectionTableViewController let destination = segue.destination as! FilterSelectionTableViewController
destination.navigationItem.title = (sender as! UITableViewCell).textLabel?.text! destination.navigationItem.title = (sender as! UITableViewCell).textLabel?.text!
destination.updateFacilities = updateFacilities
func get() -> [String: Bool] { func get() -> [String: Bool] {
if((sender as! UITableViewCell).textLabel?.text! == "Categories") { if((sender as! UITableViewCell).textLabel?.text! == "Categories") {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment