Unverified Commit 7f38b8b6 authored by Zach Knox's avatar Zach Knox
Browse files

Started changing around how cards display 'Open until...'

parent 4070e0e7
......@@ -188,6 +188,37 @@ class Utilities: NSObject {
}
return nil
}
static func openOrClosedUntil(_ facility: Facility) -> String? {
let viewingFormatter = DateFormatter.easternCoastTimeFormatForViewing
let startEnd = getStartEndDates(facility)
if facility.mainSchedule!.twentyFourHours {
return "Open all day"
}
if(Utilities.isOpen(facility: facility)) {
// Might be a better way of doing this, but for now, this works.
if(isMainSchedule(facility: facility)) {
if(!facility.mainSchedule!.openTimes.isEmpty) {
if startEnd != nil {
let time = viewingFormatter.string(from: startEnd!.endTime)
return "Open until \(time)"
}
}
//Eventually add more detailled text here, allowing for more custom
//messages as it gets closer to closing time
} else {
if startEnd != nil {
let time = viewingFormatter.string(from: startEnd!.startTime)
return "Closed until \(time)."
}
}
} else {
return "Closed"
}
return nil
}
static func getFormattedStartandEnd(_ openTime: OpenTimes) -> String? {
//Is it inelegant to go from string to date to string? maybe.
......
......@@ -118,13 +118,14 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "What's Open?"
if( traitCollection.forceTouchCapability == .available){
registerForPreviewing(with: self, sourceView: self.LocationsList!)
}
let searchController = UISearchController(searchResultsController: nil) //TODO: ADD SEARCH
if #available(iOS 11, *) {
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
......@@ -205,14 +206,15 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
cell.categoryLabel.text = facility.category?.categoryName.uppercased()
let open = Utilities.isOpen(facility: facility)
cell.openClosedLabel.text = Utilities.openOrClosedUntil(facility)
if(open == true) {
cell.openClosedLabel.text = "Open"
//cell.openClosedLabel.text = "Open"
cell.openClosedLabel.textColor = UIColor.black
cell.openClosedLabel.backgroundColor = UIColor.white
//cell.openClosedLabel.backgroundColor = UIColor(red:0.00, green:0.40, blue:0.20, alpha:1.0)
cell.backgroundColor = UIColor(red:0.00, green:0.40, blue:0.20, alpha:1.0)
} else {
cell.openClosedLabel.text = "Closed"
//cell.openClosedLabel.text = "Closed"
cell.openClosedLabel.textColor = UIColor.white
cell.openClosedLabel.backgroundColor = UIColor.black
//cell.openClosedLabel.backgroundColor = UIColor.red
......@@ -220,8 +222,10 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
cell.timeDescriptionLabel.text = Utilities.timeUntilFacility(facility)
cell.timeDescriptionLabel.text = facility.facilityLocation?.building
//TODO: FIX THIS
cell.accessibilityLabel = cell.nameLabel.text! + ", Currently " + cell.openClosedLabel.text! + "." + cell.timeDescriptionLabel.text!
cell.accessibilityHint = "Double Tap to view details"
......
......@@ -44,12 +44,13 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
let open = Utilities.isOpen(facility: facility)
OpenLabel.text = Utilities.openOrClosedUntil(facility)
OpenLabel.layer.cornerRadius = 4
OpenLabel.layer.masksToBounds = true
if(open) {
OpenLabel.text = "OPEN"
OpenLabel.backgroundColor = UIColor(red:0.00, green:0.40, blue:0.20, alpha:1.0)
}
else {
OpenLabel.text = "CLOSED"
OpenLabel.backgroundColor = UIColor.red
}
......
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