Commit 97e08667 authored by Zach Knox's avatar Zach Knox
Browse files

Added "Last Updated" label to bottom of screen like in Mail.app, as well as a...

Added "Last Updated" label to bottom of screen like in Mail.app, as well as a refresh button which does the same thing as pull to refresh
parent 2f869099
......@@ -235,11 +235,21 @@
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" barStyle="black" translatesAutoresizingMaskIntoConstraints="NO" id="8FA-yc-q3z">
<rect key="frame" x="0.0" y="559" width="375" height="44"/>
<items>
<barButtonItem title="Settings" id="MHZ-t0-Moj">
<barButtonItem title="S" id="MHZ-t0-Moj">
<connections>
<segue destination="Uxx-wt-GfY" kind="presentation" identifier="toSettings" modalPresentationStyle="pageSheet" id="3zr-0o-7IB"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="VZM-tF-lkq"/>
<barButtonItem title="Last Updated: never" style="plain" id="y4Z-i6-UYu">
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="NJ5-TN-F4n"/>
<barButtonItem systemItem="refresh" id="YxN-nx-PTc">
<connections>
<action selector="RefreshButton:" destination="aaB-Go-aWd" id="Kds-HJ-kNI"/>
</connections>
</barButtonItem>
</items>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</toolbar>
......@@ -284,6 +294,7 @@
</barButtonItem>
</navigationItem>
<connections>
<outlet property="LastUpdatedLabel" destination="y4Z-i6-UYu" id="zCz-7O-cP3"/>
<outlet property="LeftButton" destination="v4j-oA-7Fa" id="EdI-if-QoB"/>
<outlet property="LocationsList" destination="naC-sZ-bcy" id="Wk4-kY-TeR"/>
<outlet property="LocationsListLayout" destination="eqw-AF-DSB" id="kLH-bz-bdn"/>
......
......@@ -26,6 +26,8 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
@IBOutlet var favoritesControl: UISegmentedControl!
var showFavorites = false
@IBOutlet var LastUpdatedLabel: UIBarButtonItem!
@IBAction func favoritesControlChanges(_ sender: Any) {
switch (self.favoritesControl.selectedSegmentIndex)
{
......@@ -58,6 +60,14 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
}
@IBAction func RefreshButton(_ sender: Any) {
refresh(sender)
}
override func viewWillAppear(_ animated: Bool) {
LastUpdatedLabel.isEnabled = false
}
override func viewDidLoad() {
super.viewDidLoad()
......@@ -69,11 +79,14 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
LocationsList.addSubview(refreshControl)
LocationsList.alwaysBounceVertical = true
SRCTNetworkController.performDownload { (facilities) in
self.facilitiesArray = facilities
// print(self.facilitiesArray)
DispatchQueue.main.async {
self.LocationsList.reloadData()
let date = Date()
self.LastUpdatedLabel.title = "Updated: " + self.shortDateFormat(date)
}
}
}
......@@ -81,8 +94,19 @@ class LocationsListViewController: UIViewController, UICollectionViewDelegate, U
func refresh(_ sender: Any) {
refreshControl.beginRefreshing()
LocationsList.reloadData()
let date = Date()
LastUpdatedLabel.title = "Updated: " + shortDateFormat(date)
refreshControl.endRefreshing()
}
func shortDateFormat(_ date: Date) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .short
dateFormatter.timeStyle = .short
// US English Locale (en_US)
dateFormatter.locale = Locale(identifier: "en_US")
return dateFormatter.string(from: date)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
......
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