Commit 06e2a4d5 authored by Zach Knox's avatar Zach Knox
Browse files

Favorites control works

Note: needs data, currently returns an empty array for favorites
parent 366dde17
......@@ -288,7 +288,6 @@
</constraints>
</view>
<navigationItem key="navigationItem" id="lS5-pu-Adr">
<nil key="title"/>
<barButtonItem key="leftBarButtonItem" title="Filter" id="v4j-oA-7Fa">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
......@@ -306,6 +305,9 @@
<segment title="Favorites"/>
</segments>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<action selector="favoritesControlChanges:" destination="aaB-Go-aWd" eventType="valueChanged" id="5Ij-Z9-Gsa"/>
</connections>
</segmentedControl>
<barButtonItem key="rightBarButtonItem" systemItem="search" id="vtX-VZ-RB4">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
......
......@@ -25,6 +25,20 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
@IBOutlet var LocationsListLayout: UICollectionViewFlowLayout!
@IBOutlet var favoritesControl: UISegmentedControl!
var showFavorites = false
@IBAction func favoritesControlChanges(_ sender: Any) {
switch (self.favoritesControl.selectedSegmentIndex)
{
case 0:
showFavorites = false
case 1:
showFavorites = true
default:
showFavorites = false
}
self.LocationsList.reloadData()
}
override func viewDidLoad() {
super.viewDidLoad()
......@@ -50,7 +64,8 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
let count = countForOpenAndClosedFacilities(facilitiesArray)
let count = countForOpenAndClosedFacilities(getLocationArray(facilitiesArray))
if(section == 1) {
return count.open
}
......@@ -83,6 +98,17 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
return cell
}
func getLocationArray(_ facilitiesArray: [Facility]) -> [Facility] {
if(!showFavorites) {
return placeOpenFacilitiesFirstInArray(facilitiesArray)
}
else {
return [] //TODO - INCOMPLETE
}
}
//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
......
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