mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-14 15:26:40 +10:00
tapLocationAction in Feeds
This commit is contained in:
@@ -2673,6 +2673,10 @@ struct DiscoveredFeed: Hashable {
|
||||
let latitude: CLLocationDegrees
|
||||
let longitude: CLLocationDegrees
|
||||
|
||||
var coordinate: CLLocationCoordinate2D {
|
||||
return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
|
||||
}
|
||||
|
||||
static func fromJSONDictionary(json: JSONDictionary) -> LocationInfo? {
|
||||
guard let
|
||||
name = json["place"] as? String,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import UIKit
|
||||
import RealmSwift
|
||||
import AVFoundation
|
||||
import MapKit
|
||||
|
||||
class FeedsViewController: BaseViewController {
|
||||
|
||||
@@ -899,6 +900,14 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
cell.tapLocationAction = { locationName, locationCoordinate in
|
||||
|
||||
let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: locationCoordinate, addressDictionary: nil))
|
||||
mapItem.name = locationName
|
||||
|
||||
mapItem.openInMapsWithLaunchOptions(nil)
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
guard let cell = cell as? FeedCell else {
|
||||
|
||||
@@ -62,6 +62,7 @@ class FeedSocialWorkCell: FeedBasicCell {
|
||||
var tapGithubRepoLinkAction: (NSURL -> Void)?
|
||||
var tapDribbbleShotLinkAction: (NSURL -> Void)?
|
||||
var tapDribbbleShotMediaAction: ((transitionView: UIView, image: UIImage?, imageURL: NSURL, linkURL: NSURL) -> Void)?
|
||||
var tapLocationAction: ((locationName: String, locationCoordinate: CLLocationCoordinate2D) -> Void)?
|
||||
|
||||
var audioPlaying: Bool = false {
|
||||
willSet {
|
||||
@@ -134,6 +135,9 @@ class FeedSocialWorkCell: FeedBasicCell {
|
||||
|
||||
let tapGithubLink = UITapGestureRecognizer(target: self, action: "tapGithubLink:")
|
||||
githubRepoContainerView.addGestureRecognizer(tapGithubLink)
|
||||
|
||||
let tapLocation = UITapGestureRecognizer(target: self, action: "tapLocation:")
|
||||
locationContainerView.addGestureRecognizer(tapLocation)
|
||||
}
|
||||
|
||||
override func setSelected(selected: Bool, animated: Bool) {
|
||||
@@ -406,5 +410,18 @@ class FeedSocialWorkCell: FeedBasicCell {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func tapLocation(sender: UITapGestureRecognizer) {
|
||||
|
||||
guard let feed = feed, attachment = feed.attachment else {
|
||||
return
|
||||
}
|
||||
|
||||
if case .Location = feed.kind {
|
||||
if case let .Location(locationInfo) = attachment {
|
||||
tapLocationAction?(locationName: locationInfo.name, locationCoordinate: locationInfo.coordinate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user