-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f0951f5
Showing
13 changed files
with
886 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// | ||
// AppDelegate.swift | ||
// Nomad Space 2 | ||
// | ||
// Created by Markith on 2/5/19. | ||
// Copyright © 2019 SwiftyMF. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import Moya | ||
import CoreLocation | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
var window: UIWindow? = UIWindow() // Default declaration | ||
//let window = UIWindow() // Tutorial declaration - Why did he change this? | ||
let locationService = LocationService() | ||
let storyboard = UIStoryboard(name: "Main", bundle: nil) | ||
let service = MoyaProvider<YelpService.BusinessesProvider>() | ||
let jsonDecoder = JSONDecoder() | ||
var navigationController: UINavigationController? | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
|
||
jsonDecoder.keyDecodingStrategy = .convertFromSnakeCase | ||
|
||
locationService.newLocation = { [weak self] result in | ||
switch result { | ||
case .success(let location): | ||
self?.loadBusinesses(with: location.coordinate) | ||
case .failure(let error): | ||
assertionFailure("Error getting user location \(error)") | ||
} | ||
} | ||
locationService.getLocation() | ||
return true | ||
} | ||
|
||
|
||
// private func loadDetails(viewController: UIViewController, withId id: String) { | ||
// service.request(.details(id: id)) { [weak self] (result) in | ||
// switch result { | ||
// case .success(let response): | ||
// guard let strongSelf = self else { return } | ||
// if let tableViewDetails = try? strongSelf.jsonDecoder.decode(Details.self, from: response.data) { | ||
// let tableViewModel = TableViewModel(tableViewDetails: tableViewDetails) | ||
// (viewController as? MapViewController)?.detailsViewModel = tableViewModel | ||
// print("loadDetails ran") | ||
// } | ||
// case .failure(let error): | ||
// print("Failed getting details: \(error)") | ||
// } | ||
// } | ||
// } | ||
|
||
// MARK: - See viewModels from Yelp | ||
private func loadBusinesses(with coordinate: CLLocationCoordinate2D) { | ||
service.request(.search(lat: coordinate.latitude, long: coordinate.longitude)) { [weak self] (result) in | ||
//private func loadBusinesses() { | ||
//service.request(.search(lat: 34.046418, long: -118.2426)) { (result) in | ||
guard let strongSelf = self else { return } | ||
switch result { | ||
case .success(let response): | ||
// guard let strongSelf = self else { return } | ||
let root = try? strongSelf.jsonDecoder.decode(Root.self, from: response.data) | ||
let viewModels = root?.businesses.compactMap(MapViewModel.init).sorted(by: {$0.distance < $1.distance} ) | ||
if let nav = strongSelf.window?.rootViewController as? UINavigationController, | ||
let mapViewController = nav.topViewController as? MapViewController { | ||
mapViewController.mapViewModels = viewModels ?? [] | ||
} | ||
if let nav = strongSelf.window?.rootViewController as? UINavigationController, | ||
let detailsViewController = nav.topViewController as? DetailsViewController { | ||
detailsViewController.mapViewModels = viewModels ?? [] | ||
} | ||
case .failure(let error): | ||
print("Error: \(error)") | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
//extension AppDelegate: /*LocationActions,*/ ListActions { | ||
// | ||
// func didTapAllow() { | ||
// locationService.requestLocationAuthorization() | ||
// } | ||
// | ||
// func didTapCell(_ viewController: UIViewController, viewModel: MapViewModel) { | ||
// loadDetails(viewController: viewController, withId: viewModel.id) | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "20x20", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "83.5x83.5", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ios-marketing", | ||
"size" : "1024x1024", | ||
"scale" : "1x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<scene sceneID="EHf-IW-A2E"> | ||
<objects> | ||
<viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | ||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
</view> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="53" y="375"/> | ||
</scene> | ||
</scenes> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="rQr-8c-ODc"> | ||
<device id="retina6_1" orientation="portrait"> | ||
<adaptation id="fullscreen"/> | ||
</device> | ||
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--Map--> | ||
<scene sceneID="tne-QT-ifu"> | ||
<objects> | ||
<viewController storyboardIdentifier="MapViewController" id="BYZ-38-t0r" customClass="MapViewController" customModule="Nomad_Space_2" customModuleProvider="target" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | ||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<subviews> | ||
<mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" showsUserLocation="YES" translatesAutoresizingMaskIntoConstraints="NO" id="q0m-YJ-Q8R"> | ||
<rect key="frame" x="0.0" y="-1" width="414" height="897"/> | ||
<connections> | ||
<outlet property="delegate" destination="BYZ-38-t0r" id="5cq-cQ-KwN"/> | ||
</connections> | ||
</mapView> | ||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xea-wh-mlL"> | ||
<rect key="frame" x="167.5" y="757" width="79" height="30"/> | ||
<state key="normal" title="My location"/> | ||
<connections> | ||
<action selector="myLocationAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="pgh-Q2-gI8"/> | ||
</connections> | ||
</button> | ||
</subviews> | ||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | ||
<constraints> | ||
<constraint firstItem="q0m-YJ-Q8R" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" constant="-1" id="SFO-w9-ZVj"/> | ||
<constraint firstItem="q0m-YJ-Q8R" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="dXP-xV-LhM"/> | ||
<constraint firstItem="q0m-YJ-Q8R" firstAttribute="trailing" secondItem="6Tk-OE-BBY" secondAttribute="trailing" id="h9r-xC-8Lc"/> | ||
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="xea-wh-mlL" secondAttribute="bottom" constant="75" id="s9o-QY-oBw"/> | ||
<constraint firstItem="q0m-YJ-Q8R" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" constant="34" id="uop-KI-vos"/> | ||
<constraint firstItem="xea-wh-mlL" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="ysC-Wp-59y"/> | ||
</constraints> | ||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
</view> | ||
<navigationItem key="navigationItem" title="Map" id="L60-2M-UYj"/> | ||
<connections> | ||
<outlet property="mapView" destination="q0m-YJ-Q8R" id="ogE-Ln-4yr"/> | ||
<segue destination="nAA-sT-I7N" kind="show" identifier="DetailViewSegue" id="1gg-Ct-8bX"/> | ||
</connections> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="1046.376811594203" y="132.58928571428572"/> | ||
</scene> | ||
<!--Business Name--> | ||
<scene sceneID="JQR-bf-UMw"> | ||
<objects> | ||
<viewController storyboardIdentifier="detailsVC" title="Business Name" id="nAA-sT-I7N" customClass="DetailsViewController" customModule="Nomad_Space_2" customModuleProvider="target" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="FSk-PO-kwt"> | ||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<subviews> | ||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="GLv-y4-bj5"> | ||
<rect key="frame" x="132" y="381" width="150" height="134.5"/> | ||
<subviews> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Price" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="y65-wq-ZHn"> | ||
<rect key="frame" x="0.0" y="0.0" width="150" height="20.5"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Distance" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="goZ-uh-gRQ"> | ||
<rect key="frame" x="0.0" y="28.5" width="150" height="20.5"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="isClosed" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dco-GH-rkp"> | ||
<rect key="frame" x="0.0" y="57" width="150" height="20.5"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Rating" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="svo-Tg-zXd"> | ||
<rect key="frame" x="0.0" y="85.5" width="150" height="20.5"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Photos" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6cW-hp-8wx"> | ||
<rect key="frame" x="0.0" y="114" width="150" height="20.5"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
</subviews> | ||
<constraints> | ||
<constraint firstAttribute="width" constant="150" id="s40-Vp-KlG"/> | ||
</constraints> | ||
</stackView> | ||
</subviews> | ||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
<constraints> | ||
<constraint firstItem="GLv-y4-bj5" firstAttribute="centerY" secondItem="FSk-PO-kwt" secondAttribute="centerY" id="DQp-Hv-IaG"/> | ||
<constraint firstItem="GLv-y4-bj5" firstAttribute="centerX" secondItem="FSk-PO-kwt" secondAttribute="centerX" id="Ix4-sO-icZ"/> | ||
</constraints> | ||
<viewLayoutGuide key="safeArea" id="6ex-iw-SfV"/> | ||
</view> | ||
<connections> | ||
<outlet property="distanceLabel" destination="goZ-uh-gRQ" id="jHl-00-8wr"/> | ||
<outlet property="isClosedLabel" destination="dco-GH-rkp" id="ePp-pr-H2n"/> | ||
<outlet property="photosLabel" destination="6cW-hp-8wx" id="0Lh-JI-pce"/> | ||
<outlet property="priceLabel" destination="y65-wq-ZHn" id="2RK-YD-aHk"/> | ||
<outlet property="ratingLabel" destination="svo-Tg-zXd" id="SnX-io-6ab"/> | ||
</connections> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="a8M-RM-d3S" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="1923.1884057971015" y="133.92857142857142"/> | ||
</scene> | ||
<!--Navigation Controller--> | ||
<scene sceneID="XBB-X9-Wb0"> | ||
<objects> | ||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="rQr-8c-ODc" sceneMemberID="viewController"> | ||
<toolbarItems/> | ||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="RBj-uI-oIh"> | ||
<rect key="frame" x="0.0" y="44" width="414" height="96"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
<textAttributes key="largeTitleTextAttributes"> | ||
<fontDescription key="fontDescription" name="AvenirNext-Bold" family="Avenir Next" pointSize="35"/> | ||
<color key="textColor" red="1" green="0.14913141730000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | ||
<color key="textShadowColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
</textAttributes> | ||
</navigationBar> | ||
<nil name="viewControllers"/> | ||
<connections> | ||
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="aQO-bb-a7M"/> | ||
</connections> | ||
</navigationController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="qOH-wl-CcK" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="136.23188405797103" y="132.58928571428572"/> | ||
</scene> | ||
</scenes> | ||
</document> |
Oops, something went wrong.