Unverified Commit c1196b6e authored by Zach Knox's avatar Zach Knox
Browse files

Added button to add/remove a favorite

Still needs better colors though
parent 8f58e445
......@@ -17,8 +17,6 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
@IBOutlet var OpenTimesList: UITableView!
@IBOutlet var detailStackView: UIStackView!
override var previewActionItems: [UIPreviewActionItem] {
var title: String
if(Utilities.isFavoriteFacility(facility)) {
......@@ -31,6 +29,27 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
return [favoritePreviewItem]
}
@IBOutlet var favoritesButton: UIButton!
@IBAction func setFavButton(_ sender: Any) {
if(Utilities.isFavoriteFacility(facility)) {
Utilities.removeFavoriteFacility(facility)
}
else {
Utilities.addFavoriteFacility(facility)
}
setFavoriteButtonText()
}
func setFavoriteButtonText() {
if(Utilities.isFavoriteFacility(facility)) {
favoritesButton.setTitle("Remove from Favorites", for: .normal)
favoritesButton.titleLabel?.text = "Remove from Favorites"
}
else {
favoritesButton.setTitle("Add to Favorites", for: .normal)
favoritesButton.titleLabel?.text = "Add to Favorites"
}
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
......@@ -61,6 +80,12 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
OpenLabel.backgroundColor = UIColor.red
}
setFavoriteButtonText()
favoritesButton.backgroundColor = UIColor.green
favoritesButton.titleLabel?.textColor = UIColor.white
favoritesButton.layer.cornerRadius = 8
if #available(iOS 11.0, *) {
navigationItem.largeTitleDisplayMode = .never
}
......
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