Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rechsteiner committed Mar 27, 2016
0 parents commit 0ad346e
Show file tree
Hide file tree
Showing 30 changed files with 1,511 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

Carthage/Checkouts
Carthage/Build
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "robb/Cartography"
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "robb/Cartography" "0.6.0"
5 changes: 5 additions & 0 deletions Error.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

enum Error: String {
case InitCoder = "init(coder:) has not been implemented"
}
6 changes: 6 additions & 0 deletions Example/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
}
68 changes: 68 additions & 0 deletions Example/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"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" : "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"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
27 changes: 27 additions & 0 deletions Example/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</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>
26 changes: 26 additions & 0 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
30 changes: 30 additions & 0 deletions Example/ExampleViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import UIKit
import Cartography

class ExampleViewController: UIViewController {

init(index: Int) {
super.init(nibName: nil, bundle: nil)
title = "View \(index)"
label.text = "\(index)"
label.sizeToFit()
view.addSubview(label)
view.backgroundColor = UIColor.whiteColor()
constrain(view, label) { view, label in
label.centerX == view.centerX
label.centerY == view.centerY
}
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private lazy var label: UILabel = {
let label = UILabel(frame: .zero)
label.font = UIFont(name: "HelveticaNeue-Thin", size: 70)
label.textColor = UIColor.lightGrayColor()
return label
}()

}
47 changes: 47 additions & 0 deletions Example/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
23 changes: 23 additions & 0 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import UIKit
import Parchment
import Cartography

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

let pagingViewController = PagingViewController(viewControllers: (0...10).map {
return ExampleViewController(index: $0)
})

addChildViewController(pagingViewController)
view.addSubview(pagingViewController.view)
pagingViewController.didMoveToParentViewController(self)

constrain(view, pagingViewController.view) { view, pagingView in
view.edges == pagingView.edges
}
}

}
18 changes: 18 additions & 0 deletions PagingDirection.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation

enum PagingDirection {
case Reverse, Forward
}

extension PagingDirection {

var pageViewControllerNavigationDirection: UIPageViewControllerNavigationDirection {
switch self {
case .Forward:
return .Forward
case .Reverse:
return .Reverse
}
}

}
50 changes: 50 additions & 0 deletions PagingState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Foundation

enum PagingState {

case Previous(Int, Int, CGFloat)
case Current(Int, PagingDirection)
case Next(Int, Int, CGFloat)

var offset: CGFloat {
switch self {
case let .Previous(_, _, offset):
return offset
case let .Next(_, _,offset):
return offset
case .Current:
return 0
}
}

var currentIndex: Int {
switch self {
case let .Previous(index, _, _):
return index
case let .Next(index, _, _):
return index
case let .Current(index, _):
return index
}
}

var upcomingIndex: Int? {
switch self {
case let .Previous(_, index, _):
return index
case let .Next(_, index, _):
return index
case .Current:
return nil
}
}

func directionForUpcomingIndex(index: Int) -> PagingDirection {
if self.currentIndex > index {
return .Reverse
} else {
return .Forward
}
}

}
Loading

0 comments on commit 0ad346e

Please sign in to comment.