Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Fixed Issue #201. Hides Facebook button when there is no link. Also p…
Browse files Browse the repository at this point in the history
…artially fixed issue #202.
  • Loading branch information
cstock123 committed Oct 9, 2018
1 parent 3f54800 commit 0bef86e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CruCentralCoast/Events/EventDetailsVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class EventDetailsVC: UIViewController {
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var locationButton: UIButton!
@IBOutlet weak var facebookButton: CruButton!

@IBOutlet weak var topConstraint: NSLayoutConstraint!

private var currentImageLink: String?
private var locationButtonTitle: String = ""

override var prefersStatusBarHidden: Bool { return true }

Expand All @@ -33,7 +35,7 @@ class EventDetailsVC: UIViewController {
self.titleLabel.text = self.event?.title
self.dateLabel.text = self.event?.startDate.toString(dateStyle: .medium, timeStyle: .none).uppercased()
self.descriptionLabel.text = self.event?.summary
self.locationButton.setTitle(self.event?.location?.street, for: .normal)
self.locationButton.setTitle(self.locationButtonTitle + "\(self.event?.location?.street)" + " , \(self.event?.location?.city)", for: .normal)
self.currentImageLink = self.event?.imageLink
if let imageLink = self.event?.imageLink {
ImageManager.instance.fetch(imageLink) { [weak self] image in
Expand All @@ -44,6 +46,11 @@ class EventDetailsVC: UIViewController {
}
}
}

// gray out the facebook button if there is no link
if ((self.event?.facebookUrl) == "") {
self.facebookButton.isHidden = true
}
}

@IBAction func dismissDetail(_ sender: Any) {
Expand Down Expand Up @@ -89,11 +96,14 @@ class EventDetailsVC: UIViewController {
guard let facebookURL = event?.facebookUrl else { return }

if let url = URL(string: facebookURL) {
self.facebookButton.backgroundColor = UIColor(red: 59, green: 89, blue: 153, alpha: 1)
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = true

let vc = SFSafariViewController(url: url, configuration: config)
self.present(vc, animated: true)
} else {
self.presentAlert(title: "No Event", message: "No facebook event available")
}
}

Expand Down
1 change: 1 addition & 0 deletions CruCentralCoast/Events/Events.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
<outlet property="closeButton" destination="OXe-05-0Hx" id="82Z-W6-hKo"/>
<outlet property="dateLabel" destination="Odd-9O-O3u" id="tKu-c6-WSm"/>
<outlet property="descriptionLabel" destination="3lv-CQ-HAd" id="HL2-Vy-gvP"/>
<outlet property="facebookButton" destination="IJy-Si-BSE" id="n8y-tE-dRz"/>
<outlet property="imageView" destination="UYN-ct-CuI" id="BB6-ny-EKf"/>
<outlet property="locationButton" destination="7k4-Tz-JY1" id="OX7-IW-7yv"/>
<outlet property="titleLabel" destination="LkD-pk-Jlf" id="Jih-Ss-FeQ"/>
Expand Down

0 comments on commit 0bef86e

Please sign in to comment.