Unverified Commit 13580a7d authored by Zach Knox's avatar Zach Knox
Browse files

View in Maps button

parent dda271ce
......@@ -5,6 +5,7 @@
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Alignment constraints to the first baseline" minToolsVersion="6.0"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
......@@ -616,7 +617,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="OPEN" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LmU-tN-3Nq">
<rect key="frame" x="8" y="117.5" width="359" height="38"/>
<rect key="frame" x="8" y="118" width="359" height="38"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="38" id="9W6-hU-MSZ"/>
......@@ -626,13 +627,13 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Johnson Center" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2ce-lS-NfW">
<rect key="frame" x="8" y="82" width="359" height="27.5"/>
<rect key="frame" x="8" y="82" width="359" height="28"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="23"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="RESTAURANT" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SCx-pT-eVq">
<rect key="frame" x="8" y="22" width="359" height="19.5"/>
<rect key="frame" x="8" y="22" width="359" height="20"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="16"/>
<color key="textColor" white="0.13039822049999999" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
......@@ -644,7 +645,7 @@
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="EFr-sK-Oua">
<rect key="frame" x="0.0" y="163.5" width="375" height="432.5"/>
<rect key="frame" x="0.0" y="164" width="375" height="373"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="LocationDetailCell" textLabel="ZON-E8-nep" detailTextLabel="mCu-om-Ac6" style="IBUITableViewCellStyleValue1" id="7ju-Kj-S2Y">
......@@ -691,30 +692,62 @@
<action selector="setFavButton:" destination="40z-Tl-yYT" eventType="touchUpInside" id="bOT-kV-nhh"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="x1k-8h-a45" userLabel="Directions Button">
<rect key="frame" x="16" y="545" width="266" height="51"/>
<color key="backgroundColor" red="0.0" green="0.47934520244598389" blue="0.99908632040023804" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="266" id="91y-4v-zGH"/>
<constraint firstAttribute="height" constant="51" id="c2j-rB-cTK"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="19"/>
<state key="normal" title="Button">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="getDirections:" destination="40z-Tl-yYT" eventType="touchUpInside" id="E0t-VO-unA"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QR7-u9-Lw1" userLabel="Share Button">
<rect key="frame" x="290" y="545" width="69" height="51"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="19"/>
<state key="normal" title="Button">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="shareFacility:" destination="40z-Tl-yYT" eventType="touchUpInside" id="SSJ-rl-saS"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="QR7-u9-Lw1" firstAttribute="firstBaseline" secondItem="x1k-8h-a45" secondAttribute="baseline" id="0d8-Hh-KTR"/>
<constraint firstItem="wYH-df-pb5" firstAttribute="leading" secondItem="0iA-yA-TUz" secondAttribute="leading" constant="16" id="4qH-Qs-2Nu"/>
<constraint firstItem="SCx-pT-eVq" firstAttribute="top" secondItem="0iA-yA-TUz" secondAttribute="top" constant="2" id="7tl-O1-iS3"/>
<constraint firstItem="x1k-8h-a45" firstAttribute="top" secondItem="EFr-sK-Oua" secondAttribute="bottom" constant="8" symbolic="YES" id="8hI-3o-eer"/>
<constraint firstItem="SCx-pT-eVq" firstAttribute="centerX" secondItem="0iA-yA-TUz" secondAttribute="centerX" id="Akz-sy-WAt"/>
<constraint firstItem="QR7-u9-Lw1" firstAttribute="top" secondItem="x1k-8h-a45" secondAttribute="top" id="BGf-1R-2P5"/>
<constraint firstItem="LmU-tN-3Nq" firstAttribute="width" secondItem="hPi-Bj-D4L" secondAttribute="width" id="DUR-R6-939"/>
<constraint firstItem="EFr-sK-Oua" firstAttribute="centerX" secondItem="0iA-yA-TUz" secondAttribute="centerX" id="Ezv-za-EcD"/>
<constraint firstItem="EFr-sK-Oua" firstAttribute="top" secondItem="LmU-tN-3Nq" secondAttribute="bottom" constant="8" id="H5o-yK-bUj"/>
<constraint firstItem="EFr-sK-Oua" firstAttribute="width" secondItem="vOM-a7-AE3" secondAttribute="width" id="HPb-Hd-ULg"/>
<constraint firstItem="wYH-df-pb5" firstAttribute="top" secondItem="x1k-8h-a45" secondAttribute="bottom" constant="8" symbolic="YES" id="ID4-Ld-Mg1"/>
<constraint firstItem="LmU-tN-3Nq" firstAttribute="centerX" secondItem="0iA-yA-TUz" secondAttribute="centerX" id="MAY-TR-6W9"/>
<constraint firstItem="hPi-Bj-D4L" firstAttribute="centerX" secondItem="0iA-yA-TUz" secondAttribute="centerX" id="NV5-11-lY8"/>
<constraint firstItem="2ce-lS-NfW" firstAttribute="top" secondItem="hPi-Bj-D4L" secondAttribute="bottom" constant="-4" id="SIh-tP-Vwb"/>
<constraint firstItem="x1k-8h-a45" firstAttribute="leading" secondItem="wYH-df-pb5" secondAttribute="leading" id="UUx-Sp-bhy"/>
<constraint firstItem="hPi-Bj-D4L" firstAttribute="leading" secondItem="0iA-yA-TUz" secondAttribute="leading" constant="8" id="XdB-Nv-hr4"/>
<constraint firstItem="wYH-df-pb5" firstAttribute="centerX" secondItem="0iA-yA-TUz" secondAttribute="centerX" id="Zrf-ek-B8e"/>
<constraint firstItem="wYH-df-pb5" firstAttribute="top" secondItem="EFr-sK-Oua" secondAttribute="bottom" constant="8" id="aZn-qA-7kZ"/>
<constraint firstItem="hPi-Bj-D4L" firstAttribute="top" secondItem="SCx-pT-eVq" secondAttribute="bottom" constant="-4.5" id="arY-iF-Gnx"/>
<constraint firstItem="2ce-lS-NfW" firstAttribute="width" secondItem="hPi-Bj-D4L" secondAttribute="width" id="ceM-fT-kDM"/>
<constraint firstItem="0iA-yA-TUz" firstAttribute="bottom" secondItem="wYH-df-pb5" secondAttribute="bottom" constant="12" id="e47-BL-fWF"/>
<constraint firstItem="SCx-pT-eVq" firstAttribute="width" secondItem="hPi-Bj-D4L" secondAttribute="width" id="exI-g2-Tec"/>
<constraint firstItem="LmU-tN-3Nq" firstAttribute="top" secondItem="2ce-lS-NfW" secondAttribute="bottom" constant="8" id="fSq-dp-y4o"/>
<constraint firstItem="QR7-u9-Lw1" firstAttribute="leading" secondItem="x1k-8h-a45" secondAttribute="trailing" constant="8" symbolic="YES" id="fc7-zd-F8t"/>
<constraint firstItem="0iA-yA-TUz" firstAttribute="trailing" secondItem="hPi-Bj-D4L" secondAttribute="trailing" constant="8" id="fuT-qT-1IL"/>
<constraint firstItem="0iA-yA-TUz" firstAttribute="trailing" secondItem="wYH-df-pb5" secondAttribute="trailing" constant="16" id="okf-v7-GSs"/>
<constraint firstItem="2ce-lS-NfW" firstAttribute="centerX" secondItem="0iA-yA-TUz" secondAttribute="centerX" id="wwG-8O-tQ7"/>
<constraint firstItem="QR7-u9-Lw1" firstAttribute="trailing" secondItem="wYH-df-pb5" secondAttribute="trailing" id="xIa-4K-ECo"/>
</constraints>
<viewLayoutGuide key="safeArea" id="0iA-yA-TUz"/>
</view>
......@@ -724,7 +757,9 @@
<outlet property="OpenLabel" destination="LmU-tN-3Nq" id="3i1-Xg-FtQ"/>
<outlet property="OpenTimesList" destination="EFr-sK-Oua" id="uTF-US-Oh4"/>
<outlet property="PlaceLabel" destination="2ce-lS-NfW" id="rkF-DE-fAD"/>
<outlet property="directionsButton" destination="x1k-8h-a45" id="JoP-Yp-4Ky"/>
<outlet property="favoritesButton" destination="wYH-df-pb5" id="7oH-Qd-dEg"/>
<outlet property="shareButton" destination="QR7-u9-Lw1" id="9ym-ZZ-QDl"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Hze-Fg-ydT" userLabel="First Responder" sceneMemberID="firstResponder"/>
......
......@@ -63,6 +63,7 @@ class Locations: Object, Mappable {
@objc dynamic var campus = ""
@objc dynamic var onCampus = false
@objc dynamic var abbreviation = ""
@objc dynamic var coordinates: Coordinates? = Coordinates()
required convenience init?(map: Map){
self.init()
......@@ -77,6 +78,7 @@ class Locations: Object, Mappable {
campus <- map["campus_region"]
onCampus <- map["on_campus"]
abbreviation <- map["friendly_building"]
coordinates <- map["coordinate_location"]
}
func equals(_ another: Locations) -> Bool {
......@@ -93,6 +95,20 @@ class Locations: Object, Mappable {
}
class Coordinates: Object, Mappable {
var coords: List<Double>? = List<Double>()
@objc dynamic var type = ""
required convenience init?(map: Map){
self.init()
}
func mapping(map: Map) {
coords <- (map["coordinates"], CoordTransform())
type <- map["type"]
}
}
class Categories: Object, Mappable {
@objc dynamic var id = 0
@objc dynamic var created = ""
......@@ -273,6 +289,34 @@ class TagTransform : TransformType {
}
}
class CoordTransform: TransformType {
typealias Object = List<Double>
typealias JSON = [String]
func transformFromJSON(_ value: Any?) -> List<Double>? {
let result = List<Double>()
if let tempArr = value as! [Double]? {
var count = 0
for entry in tempArr {
result.insert(entry, at: count)
count += 1
}
}
return result
}
func transformToJSON(_ value: List<Double>?) -> [String]? {
if (value!.count > 0) {
var result = [String]()
for entry in value! {
result.append("\(entry)")
}
return result
}
return nil
}
}
/**struct OpenTimes: CreatableFromJSON { // TODO: Rename this struct
......
......@@ -8,6 +8,7 @@
import UIKit
import StoreKit
import MapKit
class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
......@@ -17,7 +18,9 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
@IBOutlet var CategoryLabel: UILabel!
@IBOutlet var OpenTimesList: UITableView!
@IBOutlet var favoritesButton: UIButton!
@IBOutlet var directionsButton: UIButton!
@IBOutlet var shareButton: UIButton!
var facility: Facility!
override var previewActionItems: [UIPreviewActionItem] {
......@@ -48,7 +51,27 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
setFavoriteButtonText()
}
/**
@IBAction func getDirections(_ sender: Any) {
let regionDistance:CLLocationDistance = 100
print("Lat: \(String(describing: facility.facilityLocation?.coordinates?.coords?.first)) Long: \(String(describing: facility.facilityLocation?.coordinates?.coords?.last))")
let coordinates = CLLocationCoordinate2DMake((facility.facilityLocation?.coordinates?.coords?.last)!, (facility.facilityLocation?.coordinates?.coords?.first)!)
dump(coordinates)
let regionSpan = MKCoordinateRegionMakeWithDistance(coordinates, regionDistance, regionDistance)
let options = [
MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center),
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span)
]
let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = facility.facilityName
mapItem.openInMaps(launchOptions: options)
}
@IBAction func shareFacility(_ sender: Any) {
}
/**
Change the favorite button text depending on if the facility is a favorite
*/
func setFavoriteButtonText() {
......@@ -112,6 +135,10 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
favoritesButton.tintColor = UIColor.white
favoritesButton.backgroundColor = UIColor(red:0.00, green:0.40, blue:0.20, alpha:1.0)
favoritesButton.layer.cornerRadius = 10
directionsButton.tintColor = UIColor.white
directionsButton.backgroundColor = #colorLiteral(red: 0, green: 0.4793452024, blue: 0.9990863204, alpha: 1)
directionsButton.layer.cornerRadius = 10
directionsButton.setTitle("View in Maps", for: .normal)
OpenTimesList.bounces = false
......
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