Commit 6386ca1b authored by Zac Wood's avatar Zac Wood
Browse files

Fixes toggles and retain cycles

parent 00756a75
...@@ -404,11 +404,10 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate, ...@@ -404,11 +404,10 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
} }
} }
updateFiltersLists() updateFiltersLists()
reloadWithFilters() reloadWithFilters()
refreshControl.endRefreshing() refreshControl.endRefreshing()
} }
...@@ -812,7 +811,9 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate, ...@@ -812,7 +811,9 @@ 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 filterView.updateFacilities = { [weak self] in
self?.reloadWithFilters()
}
} }
// Pass the selected object to the new view controller. // Pass the selected object to the new view controller.
......
...@@ -55,6 +55,7 @@ class FiltersTableViewController: UITableViewController { ...@@ -55,6 +55,7 @@ class FiltersTableViewController: UITableViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
tableView.estimatedRowHeight = 50 tableView.estimatedRowHeight = 50
tableView.rowHeight = UITableViewAutomaticDimension tableView.rowHeight = UITableViewAutomaticDimension
/* /*
...@@ -129,13 +130,21 @@ class FiltersTableViewController: UITableViewController { ...@@ -129,13 +130,21 @@ class FiltersTableViewController: UITableViewController {
cell = tableView.dequeueReusableCell(withIdentifier: "Switching", for: indexPath) as! SwitchingTableViewCell cell = tableView.dequeueReusableCell(withIdentifier: "Switching", for: indexPath) as! SwitchingTableViewCell
cell.textLabel!.text = "Show Open Locations" cell.textLabel!.text = "Show Open Locations"
cell.switchControl.isOn = filters.showOpen cell.switchControl.isOn = filters.showOpen
cell.toggleFunc = updateOpenFirstEnabledState cell.toggleFunc = { [unowned self] isOn in
let result = self.updateOpenFirstEnabledState(isOn)
self.updateFacilities()
return result
}
//self.showOpen = cell //self.showOpen = cell
case 1: case 1:
cell = tableView.dequeueReusableCell(withIdentifier: "Switching", for: indexPath) as! SwitchingTableViewCell cell = tableView.dequeueReusableCell(withIdentifier: "Switching", for: indexPath) as! SwitchingTableViewCell
cell.textLabel!.text = "Show Closed Locations" cell.textLabel!.text = "Show Closed Locations"
cell.switchControl.isOn = filters.showClosed cell.switchControl.isOn = filters.showClosed
cell.toggleFunc = filters.setShowClosed cell.toggleFunc = { [unowned self] isOn in
let result = self.filters.setShowClosed(isOn)
self.updateFacilities()
return result
}
//self.showClosed = cell //self.showClosed = cell
default: default:
cell = UITableViewCell() as! SwitchingTableViewCell //this is bad don't let this happen cell = UITableViewCell() as! SwitchingTableViewCell //this is bad don't let this happen
...@@ -146,7 +155,11 @@ class FiltersTableViewController: UITableViewController { ...@@ -146,7 +155,11 @@ class FiltersTableViewController: UITableViewController {
cell.textLabel!.text = "Show Open Facilities First" cell.textLabel!.text = "Show Open Facilities First"
cell.switchControl.isEnabled = filters.showOpen cell.switchControl.isEnabled = filters.showOpen
cell.switchControl.isOn = filters.openFirst cell.switchControl.isOn = filters.openFirst
cell.toggleFunc = filters.setOpenFirst cell.toggleFunc = { [unowned self] isOn in
let result = self.filters.setOpenFirst(isOn)
self.updateFacilities()
return result
}
return cell return cell
case 2: case 2:
let method: SortMethod let method: SortMethod
......
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