Commit 4b83b658 authored by Zach Knox's avatar Zach Knox
Browse files

Open items show up first

Not computationally the most efficient way, but it works!
parent 26ed1fa4
...@@ -46,12 +46,31 @@ class MainTableViewController: UITableViewController { ...@@ -46,12 +46,31 @@ class MainTableViewController: UITableViewController {
// #warning Incomplete implementation, return the number of rows // #warning Incomplete implementation, return the number of rows
return facilitiesArray.count return facilitiesArray.count
} }
//Returns an array which has the open locations listed first
//Could be improved in the future because currently this means you're checking
//open status twice per cell
func placeOpenFacilitiesFirstInArray(_ facilitiesArray: Array<Facility>) -> [Facility] {
var open = [Facility]()
var closed = [Facility]()
for i in facilitiesArray {
if(Utilities.isOpen(facility: i)) {
open.append(i)
}
else {
closed.append(i)
}
}
return open + closed
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! SRCTSimpleTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! SRCTSimpleTableViewCell
let facility = facilitiesArray[indexPath.row] let dataArray = placeOpenFacilitiesFirstInArray(facilitiesArray)
let facility = dataArray[indexPath.row]
cell.nameLabel.text = facility.name cell.nameLabel.text = facility.name
//TODO: Organize based on if a location is open. //TODO: Organize based on if a location is open.
let open = Utilities.isOpen(facility: facility); let open = Utilities.isOpen(facility: facility);
......
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