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

Google Maps and Waze support for maps button

If you have either of the other apps installed, you can set them as your preferred mapping app in the app settings
parent fac09534
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
92182EC01E95BD2C00192ABA /* FacilitiesListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92182EBF1E95BD2C00192ABA /* FacilitiesListViewController.swift */; }; 92182EC01E95BD2C00192ABA /* FacilitiesListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92182EBF1E95BD2C00192ABA /* FacilitiesListViewController.swift */; };
92182EC41E95C38400192ABA /* FacilityDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92182EC31E95C38400192ABA /* FacilityDetailViewController.swift */; }; 92182EC41E95C38400192ABA /* FacilityDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92182EC31E95C38400192ABA /* FacilityDetailViewController.swift */; };
924840F81EA915F200DBFF4E /* FacilityCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924840F71EA915F200DBFF4E /* FacilityCollectionViewCell.swift */; }; 924840F81EA915F200DBFF4E /* FacilityCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 924840F71EA915F200DBFF4E /* FacilityCollectionViewCell.swift */; };
9259134520784D66002E50B1 /* SelectOneDefaultTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9259134420784D66002E50B1 /* SelectOneDefaultTableViewController.swift */; };
9265F3A11F2969E500A54A21 /* SettingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9265F3A01F2969E500A54A21 /* SettingTableViewCell.swift */; }; 9265F3A11F2969E500A54A21 /* SettingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9265F3A01F2969E500A54A21 /* SettingTableViewCell.swift */; };
9265F3A31F2C0B1500A54A21 /* AboutScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9265F3A21F2C0B1500A54A21 /* AboutScreenViewController.swift */; }; 9265F3A31F2C0B1500A54A21 /* AboutScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9265F3A21F2C0B1500A54A21 /* AboutScreenViewController.swift */; };
9270A4DB1EB5565400DFBDA3 /* SwitchingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9270A4DA1EB5565400DFBDA3 /* SwitchingTableViewCell.swift */; }; 9270A4DB1EB5565400DFBDA3 /* SwitchingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9270A4DA1EB5565400DFBDA3 /* SwitchingTableViewCell.swift */; };
...@@ -93,6 +94,7 @@ ...@@ -93,6 +94,7 @@
92182EBF1E95BD2C00192ABA /* FacilitiesListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FacilitiesListViewController.swift; sourceTree = "<group>"; }; 92182EBF1E95BD2C00192ABA /* FacilitiesListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FacilitiesListViewController.swift; sourceTree = "<group>"; };
92182EC31E95C38400192ABA /* FacilityDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FacilityDetailViewController.swift; sourceTree = "<group>"; }; 92182EC31E95C38400192ABA /* FacilityDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FacilityDetailViewController.swift; sourceTree = "<group>"; };
924840F71EA915F200DBFF4E /* FacilityCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FacilityCollectionViewCell.swift; sourceTree = "<group>"; }; 924840F71EA915F200DBFF4E /* FacilityCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FacilityCollectionViewCell.swift; sourceTree = "<group>"; };
9259134420784D66002E50B1 /* SelectOneDefaultTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectOneDefaultTableViewController.swift; sourceTree = "<group>"; };
9265F3A01F2969E500A54A21 /* SettingTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingTableViewCell.swift; sourceTree = "<group>"; }; 9265F3A01F2969E500A54A21 /* SettingTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingTableViewCell.swift; sourceTree = "<group>"; };
9265F3A21F2C0B1500A54A21 /* AboutScreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutScreenViewController.swift; sourceTree = "<group>"; }; 9265F3A21F2C0B1500A54A21 /* AboutScreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutScreenViewController.swift; sourceTree = "<group>"; };
9270A4DA1EB5565400DFBDA3 /* SwitchingTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwitchingTableViewCell.swift; sourceTree = "<group>"; }; 9270A4DA1EB5565400DFBDA3 /* SwitchingTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwitchingTableViewCell.swift; sourceTree = "<group>"; };
...@@ -178,6 +180,7 @@ ...@@ -178,6 +180,7 @@
927C80D91EB02566009079AD /* SettingsTableViewController.swift */, 927C80D91EB02566009079AD /* SettingsTableViewController.swift */,
927C80DB1EB18B89009079AD /* FiltersTableViewController.swift */, 927C80DB1EB18B89009079AD /* FiltersTableViewController.swift */,
92B2D2FE1FF8599500349E90 /* FilterSelectionTableViewController.swift */, 92B2D2FE1FF8599500349E90 /* FilterSelectionTableViewController.swift */,
9259134420784D66002E50B1 /* SelectOneDefaultTableViewController.swift */,
92182EBF1E95BD2C00192ABA /* FacilitiesListViewController.swift */, 92182EBF1E95BD2C00192ABA /* FacilitiesListViewController.swift */,
); );
path = Views; path = Views;
...@@ -673,6 +676,7 @@ ...@@ -673,6 +676,7 @@
927C80DC1EB18B89009079AD /* FiltersTableViewController.swift in Sources */, 927C80DC1EB18B89009079AD /* FiltersTableViewController.swift in Sources */,
92B89E302009444E00928284 /* PullingViewController.swift in Sources */, 92B89E302009444E00928284 /* PullingViewController.swift in Sources */,
CD763A7E1DE253B900ADFD6B /* SRCTUtilities.swift in Sources */, CD763A7E1DE253B900ADFD6B /* SRCTUtilities.swift in Sources */,
9259134520784D66002E50B1 /* SelectOneDefaultTableViewController.swift in Sources */,
927C80DA1EB02566009079AD /* SettingsTableViewController.swift in Sources */, 927C80DA1EB02566009079AD /* SettingsTableViewController.swift in Sources */,
CD3C97491DC18AB300A84434 /* SRCTNetworkController.swift in Sources */, CD3C97491DC18AB300A84434 /* SRCTNetworkController.swift in Sources */,
CD763A7C1DE251C400ADFD6B /* SRCTSimpleTableViewCell.swift in Sources */, CD763A7C1DE251C400ADFD6B /* SRCTSimpleTableViewCell.swift in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
...@@ -28,6 +28,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -28,6 +28,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let defaults = UserDefaults.standard let defaults = UserDefaults.standard
initAlerts(defaults) initAlerts(defaults)
initCampuses(defaults) initCampuses(defaults)
if defaults.value(forKey: "mapsApp") == nil {
defaults.set("Apple Maps", forKey: "mapsApp")
}
return true return true
} }
......
...@@ -138,6 +138,35 @@ ...@@ -138,6 +138,35 @@
</objects> </objects>
<point key="canvasLocation" x="-8153" y="448"/> <point key="canvasLocation" x="-8153" y="448"/>
</scene> </scene>
<!--Select One Default Table View Controller-->
<scene sceneID="XVT-Zz-bv3">
<objects>
<tableViewController id="irm-NL-2LQ" customClass="SelectOneDefaultTableViewController" customModule="WhatsOpen" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="OEx-Rt-9S3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="thereCanOnlyBeOne" id="Hzs-zq-KNQ">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Hzs-zq-KNQ" id="U3O-ey-kO0">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="irm-NL-2LQ" id="TS4-il-abg"/>
<outlet property="delegate" destination="irm-NL-2LQ" id="8zp-cD-0dG"/>
</connections>
</tableView>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="v6f-sy-cSe" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-7343" y="448"/>
</scene>
<!--What's Open--> <!--What's Open-->
<scene sceneID="w5e-Fb-rsR"> <scene sceneID="w5e-Fb-rsR">
<objects> <objects>
...@@ -394,6 +423,33 @@ ...@@ -394,6 +423,33 @@
<segue destination="yIT-AR-gdn" kind="show" identifier="settingSelection" id="FRf-a6-Dgs"/> <segue destination="yIT-AR-gdn" kind="show" identifier="settingSelection" id="FRf-a6-Dgs"/>
</connections> </connections>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="settingDefaultCell" textLabel="thC-fo-X1p" detailTextLabel="yaK-Xw-Fsi" style="IBUITableViewCellStyleValue1" id="EKX-GL-oCV">
<rect key="frame" x="0.0" y="143.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="EKX-GL-oCV" id="b50-wo-rdD">
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="thC-fo-X1p">
<rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="yaK-Xw-Fsi">
<rect key="frame" x="296" y="12" width="44" height="20.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="irm-NL-2LQ" kind="show" identifier="settingDefault" id="wTS-KZ-Irl"/>
</connections>
</tableViewCell>
</prototypes> </prototypes>
<connections> <connections>
<outlet property="dataSource" destination="Lhp-lE-ieb" id="B56-3p-ltP"/> <outlet property="dataSource" destination="Lhp-lE-ieb" id="B56-3p-ltP"/>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>What's Open</string> <string>What&apos;s Open</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIcons</key> <key>CFBundleIcons</key>
...@@ -63,5 +63,10 @@ ...@@ -63,5 +63,10 @@
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<true/> <true/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
<string>waze</string>
</array>
</dict> </dict>
</plist> </plist>
...@@ -52,19 +52,32 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab ...@@ -52,19 +52,32 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
} }
@IBAction func getDirections(_ sender: Any) { @IBAction func getDirections(_ sender: Any) {
let regionDistance:CLLocationDistance = 100 let appToUse = UserDefaults.standard.value(forKey: "mapsApp") as? String
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)!) if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
dump(coordinates) if let url = URL(string: "comgooglemaps://?q=\((facility.facilityLocation?.coordinates?.coords?.last)!)),\((facility.facilityLocation?.coordinates?.coords?.first)!)") {
let regionSpan = MKCoordinateRegionMakeWithDistance(coordinates, regionDistance, regionDistance) UIApplication.shared.open(url, options: [:], completionHandler: nil)
let options = [ }
MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center), }
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span) else if appToUse == "Waze" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
] if let url = URL(string: "https://waze.com/ul?ll=\((facility.facilityLocation?.coordinates?.coords?.last)!)),\((facility.facilityLocation?.coordinates?.coords?.first)!))") {
let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil) UIApplication.shared.open(url, options: [:], completionHandler: nil)
let mapItem = MKMapItem(placemark: placemark) }
mapItem.name = facility.facilityName }
mapItem.openInMaps(launchOptions: options) else {
let regionDistance:CLLocationDistance = 100
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)
}
} }
...@@ -142,7 +155,17 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab ...@@ -142,7 +155,17 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
directionsButton.tintColor = UIColor.white directionsButton.tintColor = UIColor.white
directionsButton.backgroundColor = #colorLiteral(red: 0, green: 0.4793452024, blue: 0.9990863204, alpha: 1) directionsButton.backgroundColor = #colorLiteral(red: 0, green: 0.4793452024, blue: 0.9990863204, alpha: 1)
directionsButton.layer.cornerRadius = 10 directionsButton.layer.cornerRadius = 10
directionsButton.setTitle("View in Maps", for: .normal)
let appToUse = UserDefaults.standard.value(forKey: "mapsApp") as? String
if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
directionsButton.setTitle("View in Google Maps", for: .normal)
}
else if appToUse == "Waze" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
directionsButton.setTitle("View in Waze", for: .normal)
}
else {
directionsButton.setTitle("View in Maps", for: .normal)
}
shareButton.tintColor = UIColor.white shareButton.tintColor = UIColor.white
shareButton.backgroundColor = UIColor.orange shareButton.backgroundColor = UIColor.orange
shareButton.layer.cornerRadius = 10 shareButton.layer.cornerRadius = 10
......
...@@ -15,6 +15,7 @@ class FilterSelectionTableViewController: UITableViewController { ...@@ -15,6 +15,7 @@ class FilterSelectionTableViewController: UITableViewController {
var selectFunc: ((String, Bool) -> Bool)! var selectFunc: ((String, Bool) -> Bool)!
var selectAllFunc: (() -> Bool)! var selectAllFunc: (() -> Bool)!
var updateFacilities: (() -> Void)! var updateFacilities: (() -> Void)!
var canSelectAll = true
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -39,8 +40,10 @@ class FilterSelectionTableViewController: UITableViewController { ...@@ -39,8 +40,10 @@ class FilterSelectionTableViewController: UITableViewController {
} }
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows if canSelectAll {
return 1 + getFunc().count return 1 + getFunc().count
}
return getFunc().count
} }
...@@ -49,12 +52,18 @@ class FilterSelectionTableViewController: UITableViewController { ...@@ -49,12 +52,18 @@ class FilterSelectionTableViewController: UITableViewController {
let values = getFunc() let values = getFunc()
// Configure the cell... // Configure the cell...
if(indexPath.row == 0) { if(indexPath.row == 0 && canSelectAll) {
cell.textLabel?.text = "Select All/None" cell.textLabel?.text = "Select All/None"
cell.accessoryType = .none cell.accessoryType = .none
} }
else { else {
var i = 1 var i: Int
if canSelectAll {
i = 1
}
else {
i = 0
}
for v in values { for v in values {
if i == indexPath.row { if i == indexPath.row {
cell.textLabel?.text = v.key.capitalized cell.textLabel?.text = v.key.capitalized
...@@ -77,6 +86,9 @@ class FilterSelectionTableViewController: UITableViewController { ...@@ -77,6 +86,9 @@ class FilterSelectionTableViewController: UITableViewController {
if navigationItem.title == "Show Alerts" { if navigationItem.title == "Show Alerts" {
return "Emergency Alerts are always enabled in the app for your safety. We will never send a notification to your device without your consent." return "Emergency Alerts are always enabled in the app for your safety. We will never send a notification to your device without your consent."
} }
else if navigationItem.title == "Select Maps App" {
return "The app selected here will be used when opening a map from a facility's detail page."
}
return nil return nil
} }
......
//
// SelectOneDefaultTableViewController.swift
// WhatsOpen
//
// Created by Zach Knox on 4/6/18.
// Copyright © 2018 SRCT. All rights reserved.
//
import UIKit
class SelectOneDefaultTableViewController: UITableViewController {
// Passing functions rather than direct objects to make this class reusable
var options: [String]!
var defaultKey: String!
let defaults = UserDefaults.standard
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return options.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "thereCanOnlyBeOne", for: indexPath)
cell.textLabel?.text = options[indexPath.row]
if defaults.value(forKey: defaultKey) as! String == options[indexPath.row] {
cell.accessoryType = .checkmark
}
else {
cell.accessoryType = .none
}
return cell
}
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
if navigationItem.title == "Select Maps App" {
return "The app selected here will be used when opening a map from a facility's detail page."
}
return nil
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
defaults.set(tableView.cellForRow(at: indexPath)?.textLabel?.text, forKey: defaultKey)
tableView.reloadData()
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if(segue.identifier == "toSelection") {
let destination = segue.destination as! FiltersTableViewController
destination.tableView.reloadData()
}
}
}
...@@ -55,7 +55,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr ...@@ -55,7 +55,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
return 1 return 1
} }
else if(section == 1) { else if(section == 1) {
return 1 return 2
} }
else if(section == 2) { else if(section == 2) {
return 2 return 2
...@@ -76,10 +76,22 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr ...@@ -76,10 +76,22 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
cell.textLabel!.text = "Are Our Hours Wrong?" cell.textLabel!.text = "Are Our Hours Wrong?"
return cell return cell
case 1: case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "Setting", for: indexPath) as! SettingTableViewCell if indexPath.row == 0 {
cell.textLabel!.text = "Select App Icon" let cell = tableView.dequeueReusableCell(withIdentifier: "Setting", for: indexPath) as! SettingTableViewCell
cell.accessoryType = .disclosureIndicator cell.textLabel!.text = "Select App Icon"
return cell cell.accessoryType = .disclosureIndicator
return cell
}
else if indexPath.row == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: "settingDefaultCell", for: indexPath)
cell.textLabel!.text = "Select Maps App"
cell.textLabel?.font = UIFont.preferredFont(forTextStyle: .body)
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .footnote)
cell.detailTextLabel?.text = UserDefaults.standard.value(forKey: "mapsApp") as? String
cell.accessoryType = .disclosureIndicator
return cell
}
case 2: case 2:
let cell = tableView.dequeueReusableCell(withIdentifier: "settingSelection", for: indexPath) let cell = tableView.dequeueReusableCell(withIdentifier: "settingSelection", for: indexPath)
cell.accessoryType = .disclosureIndicator cell.accessoryType = .disclosureIndicator
...@@ -281,6 +293,21 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr ...@@ -281,6 +293,21 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
destination.updateFacilities = updateFacilities destination.updateFacilities = updateFacilities
} }
} }
else if segue.identifier == "settingDefault" {
if (sender as! UITableViewCell).textLabel?.text == "Select Maps App" {
let destination = segue.destination as! SelectOneDefaultTableViewController
destination.navigationItem.title = "Select Maps App"
destination.defaultKey = "mapsApp"
var options = ["Apple Maps"]
if UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
options.append("Google Maps")
}
if UIApplication.shared.canOpenURL(URL(string:"waze://")!) {
options.append("Waze")
}
destination.options = options
}
}
} }
......
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