Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions APIClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,31 @@

/* Begin PBXBuildFile section */
872A275C1CF0D87100A988C4 /* APIResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 872A275B1CF0D87100A988C4 /* APIResource.swift */; };
8744AA581CF2199F001B0470 /* SWViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8744AA571CF2199F001B0470 /* SWViewController.swift */; };
874D06591CEF295E009A494D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874D06581CEF295E009A494D /* AppDelegate.swift */; };
874D065E1CEF295E009A494D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 874D065C1CEF295E009A494D /* Main.storyboard */; };
874D06601CEF295E009A494D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 874D065F1CEF295E009A494D /* Assets.xcassets */; };
874D06631CEF295E009A494D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 874D06611CEF295E009A494D /* LaunchScreen.storyboard */; };
874D066B1CEF2BC0009A494D /* SWAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874D066A1CEF2BC0009A494D /* SWAPI.swift */; };
A526FDEE5BF2D1BC3C97B9FA /* Pods_APIClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD8A5B3E1266D5298CABE44A /* Pods_APIClient.framework */; };
DCE5C8C61CFB621C0025C611 /* StarWars.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE5C8C51CFB621C0025C611 /* StarWars.swift */; };
DCE5C8C81CFB66320025C611 /* SWView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE5C8C71CFB66320025C611 /* SWView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
872A275B1CF0D87100A988C4 /* APIResource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = APIResource.swift; sourceTree = "<group>"; };
8744AA571CF2199F001B0470 /* SWViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SWViewController.swift; sourceTree = "<group>"; };
874D06551CEF295E009A494D /* APIClient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = APIClient.app; sourceTree = BUILT_PRODUCTS_DIR; };
874D06581CEF295E009A494D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
874D065D1CEF295E009A494D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
874D065F1CEF295E009A494D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
874D06621CEF295E009A494D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
874D06641CEF295E009A494D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
874D066A1CEF2BC0009A494D /* SWAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SWAPI.swift; sourceTree = "<group>"; };
93EFAB13AE62F1B6FB2683B2 /* Pods-APIClient.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIClient.debug.xcconfig"; path = "Pods/Target Support Files/Pods-APIClient/Pods-APIClient.debug.xcconfig"; sourceTree = "<group>"; };
BD8A5B3E1266D5298CABE44A /* Pods_APIClient.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_APIClient.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DCE5C8C51CFB621C0025C611 /* StarWars.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarWars.swift; sourceTree = "<group>"; };
DCE5C8C71CFB66320025C611 /* SWView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SWView.swift; sourceTree = "<group>"; };
FFE13D543A95D28F27CFBDA4 /* Pods-APIClient.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIClient.release.xcconfig"; path = "Pods/Target Support Files/Pods-APIClient/Pods-APIClient.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -43,20 +51,24 @@
872A27571CF0D4E200A988C4 /* View Controller */ = {
isa = PBXGroup;
children = (
8744AA571CF2199F001B0470 /* SWViewController.swift */,
);
name = "View Controller";
sourceTree = "<group>";
};
872A27581CF0D4EB00A988C4 /* View */ = {
isa = PBXGroup;
children = (
DCE5C8C71CFB66320025C611 /* SWView.swift */,
);
name = View;
sourceTree = "<group>";
};
872A27591CF0D64A00A988C4 /* Model */ = {
isa = PBXGroup;
children = (
874D066A1CEF2BC0009A494D /* SWAPI.swift */,
DCE5C8C51CFB621C0025C611 /* StarWars.swift */,
872A275B1CF0D87100A988C4 /* APIResource.swift */,
);
name = Model;
Expand Down Expand Up @@ -242,8 +254,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
874D066B1CEF2BC0009A494D /* SWAPI.swift in Sources */,
872A275C1CF0D87100A988C4 /* APIResource.swift in Sources */,
874D06591CEF295E009A494D /* AppDelegate.swift in Sources */,
8744AA581CF2199F001B0470 /* SWViewController.swift in Sources */,
DCE5C8C81CFB66320025C611 /* SWView.swift in Sources */,
DCE5C8C61CFB621C0025C611 /* StarWars.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions APIClient/APIResource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import AwesomeCache
You are free to use this utility or implement your own way to keep track of loaded and not loaded resources.

- seealso: MoyaProvider.request<Resource: Freddy.JSONDecodable>(_:completion:)
*/
*/
enum APIResource<Target: Moya.TargetType, Resource: Freddy.JSONDecodable where Target: Cacheable> {

case notLoaded(Target)
Expand Down Expand Up @@ -91,4 +91,4 @@ protocol Cacheable {
/// A key used for identification in a cache
var cacheIdentifier: String { get }

}
}
10 changes: 8 additions & 2 deletions APIClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
//

import UIKit
import Moya

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


/// The SWAPI Provider representing the Server
let swAPI = MoyaProvider<SWAPI>()


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

(window!.rootViewController as! SWViewController).swAPI = swAPI

return true
}

}

109 changes: 83 additions & 26 deletions APIClient/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,44 +1,101 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="E10-YL-lxp">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="CcT-OA-9Mc">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="Xrb-yS-kMZ">
<!--SWViewController-->
<scene sceneID="B3E-29-EzH">
<objects>
<navigationController id="E10-YL-lxp" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="amJ-5H-qs5">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="rPr-Fp-ALE" kind="relationship" relationship="rootViewController" id="g8j-CJ-uaE"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="hfS-9i-aMM" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-658" y="301"/>
</scene>
<!--View Controller-->
<scene sceneID="adh-8k-Iuh">
<objects>
<viewController id="rPr-Fp-ALE" sceneMemberID="viewController">
<viewController title="SWViewController" id="CcT-OA-9Mc" customClass="SWViewController" customModule="APIClient" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="pj8-zF-1z6"/>
<viewControllerLayoutGuide type="bottom" id="kt2-9S-3TK"/>
<viewControllerLayoutGuide type="top" id="lXK-50-2dH"/>
<viewControllerLayoutGuide type="bottom" id="Vhg-TZ-pGa"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="rEB-Za-Zhx">
<view key="view" contentMode="scaleToFill" id="Zef-dV-XDA">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="Efm-Ym-uWA">
<rect key="frame" x="29" y="58" width="551" height="84"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VZb-Mv-ZwB">
<rect key="frame" x="0.0" y="0.0" width="551" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ypa-jp-Fzc">
<rect key="frame" x="0.0" y="21" width="551" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ePa-z8-ZaZ">
<rect key="frame" x="0.0" y="42" width="551" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="N5M-p3-Nnd">
<rect key="frame" x="0.0" y="63" width="551" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dJk-S3-h4M">
<rect key="frame" x="20" y="20" width="560" height="30"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="p7o-zO-NLv">
<rect key="frame" x="0.0" y="0.0" width="48" height="30"/>
<state key="normal" title="Search"/>
<connections>
<action selector="Search:" destination="CcT-OA-9Mc" eventType="touchUpInside" id="Bd2-Ph-tjQ"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="nK3-qN-Brx">
<rect key="frame" x="48" y="0.0" width="492" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="CcT-OA-9Mc" id="7Tp-TT-N6A"/>
</connections>
</textField>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="iHy-6d-5Sx">
<rect key="frame" x="540" y="0.0" width="20" height="30"/>
</activityIndicatorView>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailingMargin" secondItem="Efm-Ym-uWA" secondAttribute="trailing" id="DPb-7h-3u2"/>
<constraint firstItem="Efm-Ym-uWA" firstAttribute="leading" secondItem="Zef-dV-XDA" secondAttribute="leadingMargin" constant="9" id="G21-tG-Oc5"/>
<constraint firstAttribute="trailingMargin" secondItem="dJk-S3-h4M" secondAttribute="trailing" id="J0z-7u-zVj"/>
<constraint firstItem="Efm-Ym-uWA" firstAttribute="top" secondItem="dJk-S3-h4M" secondAttribute="bottom" constant="8" id="chE-gW-lv5"/>
<constraint firstItem="dJk-S3-h4M" firstAttribute="leading" secondItem="Zef-dV-XDA" secondAttribute="leadingMargin" id="q9M-hY-wKz"/>
<constraint firstItem="Vhg-TZ-pGa" firstAttribute="top" relation="greaterThanOrEqual" secondItem="Efm-Ym-uWA" secondAttribute="bottom" id="qCB-tM-1sZ"/>
<constraint firstItem="dJk-S3-h4M" firstAttribute="top" secondItem="lXK-50-2dH" secondAttribute="bottom" id="zeN-Cq-ur8"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="CZR-l9-xMg"/>
<toolbarItems/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="diameterLabel" destination="Ypa-jp-Fzc" id="qK7-ZS-HgF"/>
<outlet property="gravityLabel" destination="VZb-Mv-ZwB" id="b88-Ua-Ygh"/>
<outlet property="loadingIndicator" destination="iHy-6d-5Sx" id="rtY-P2-Q0B"/>
<outlet property="orbital_periodLabel" destination="N5M-p3-Nnd" id="r9Z-CW-fR1"/>
<outlet property="rotation_periodLabel" destination="ePa-z8-ZaZ" id="g5W-xt-JVB"/>
<outlet property="searchTextfield" destination="nK3-qN-Brx" id="S0Y-Vu-DGq"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="OaC-W5-AeM" userLabel="First Responder" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="lZ6-hT-HfN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="65" y="301"/>
<point key="canvasLocation" x="284" y="206"/>
</scene>
</scenes>
</document>
11 changes: 11 additions & 0 deletions APIClient/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>swapi.co</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
Loading