Commit d73ebf28 authored by Zach Knox's avatar Zach Knox
Browse files

Added pull to refresh

parent 06e2a4d5
......@@ -109,10 +109,10 @@
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="ShowOpen" id="2Dt-e5-bMw">
<rect key="frame" x="0.0" y="56" width="375" height="44"/>
<rect key="frame" x="0.0" y="55" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2Dt-e5-bMw" id="SM7-SZ-S5h">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KxM-rM-vzf">
......@@ -129,10 +129,10 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="ShowClosed" id="Zt7-lA-Klh">
<rect key="frame" x="0.0" y="100" width="375" height="44"/>
<rect key="frame" x="0.0" y="99" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Zt7-lA-Klh" id="1tH-zY-hLb">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="I0H-wK-NZE">
......@@ -149,7 +149,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="checkmark" indentationWidth="10" reuseIdentifier="Checkbox Filter" textLabel="rYu-5q-2u8" style="IBUITableViewCellStyleDefault" id="x5H-BH-cVX">
<rect key="frame" x="0.0" y="144" width="375" height="44"/>
<rect key="frame" x="0.0" y="143" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="x5H-BH-cVX" id="xf1-yc-ynP">
<rect key="frame" x="0.0" y="0.0" width="336" height="43.5"/>
......@@ -338,10 +338,10 @@
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="uHy-SO-4Zr">
<rect key="frame" x="0.0" y="56" width="375" height="44"/>
<rect key="frame" x="0.0" y="55" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="uHy-SO-4Zr" id="fwy-U7-SfD">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
......
......@@ -40,11 +40,17 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
self.LocationsList.reloadData()
}
let refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
LocationsListLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10)
refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
LocationsList.addSubview(refreshControl)
LocationsList.alwaysBounceVertical = true
SRCTNetworkController.performDownload { (facilities) in
self.facilitiesArray = facilities
// print(self.facilitiesArray)
......@@ -53,7 +59,13 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
}
}
}
func refresh(_ sender: Any) {
refreshControl.beginRefreshing()
LocationsList.reloadData()
refreshControl.endRefreshing()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
......@@ -64,7 +76,7 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
let count = countForOpenAndClosedFacilities(getLocationArray(facilitiesArray))
let count = countForOpenAndClosedFacilities(getLocationArray(facilitiesArray)) //TODO could be better optimized
if(section == 1) {
return count.open
......
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