Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Swift 3 Support. #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions MegaController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@
TargetAttributes = {
614991B91B9E3D9A005278F8 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0820;
};
614991D01B9E3D9A005278F8 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0820;
TestTargetID = 614991B91B9E3D9A005278F8;
};
};
Expand Down Expand Up @@ -413,6 +415,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.andymatuschak.MegaController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -424,6 +427,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.andymatuschak.MegaController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -438,6 +442,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "MegaControllerTests/MegaControllerTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MegaController.app/MegaController";
};
name = Debug;
Expand All @@ -452,6 +457,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.andymatuschak.MegaControllerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "MegaControllerTests/MegaControllerTests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MegaController.app/MegaController";
};
name = Release;
Expand Down
8 changes: 4 additions & 4 deletions MegaController/AddCompletionSegue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class AddCompletionSegue: UIStoryboardSegue {
return addViewController.taskTitle
}

var taskDueDate: NSDate {
return addViewController.taskDueDate
var taskDueDate: Date {
return addViewController.taskDueDate as Date
}

private var addViewController: AddViewController {
return sourceViewController as! AddViewController
fileprivate var addViewController: AddViewController {
return source as! AddViewController
}
}
26 changes: 13 additions & 13 deletions MegaController/AddPresentationSegue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ import UIKit
class AddPresentationSegue: UIStoryboardSegue, UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning {

override func perform() {
destinationViewController.modalPresentationStyle = .OverFullScreen
destinationViewController.transitioningDelegate = self
destination.modalPresentationStyle = .overFullScreen
destination.transitioningDelegate = self
super.perform()
}

func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return self
}

func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return self
}

func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
if transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) is AddViewController {
let addView = transitionContext.viewForKey(UITransitionContextToViewKey)
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
if transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) is AddViewController {
let addView = transitionContext.view(forKey: UITransitionContextViewKey.to)
addView!.alpha = 0
transitionContext.containerView()!.addSubview(addView!)
UIView.animateWithDuration(0.4, animations: {
transitionContext.containerView.addSubview(addView!)
UIView.animate(withDuration: 0.4, animations: {
addView!.alpha = 1.0
}, completion: { didComplete in
transitionContext.completeTransition(didComplete)
})
} else if transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) is AddViewController {
let addView = transitionContext.viewForKey(UITransitionContextFromViewKey)
UIView.animateWithDuration(0.4, animations: {
} else if transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) is AddViewController {
let addView = transitionContext.view(forKey: UITransitionContextViewKey.from)
UIView.animate(withDuration: 0.4, animations: {
addView!.alpha = 0.0
}, completion: { didComplete in
transitionContext.completeTransition(didComplete)
})
}
}

func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
}
}
10 changes: 5 additions & 5 deletions MegaController/AddViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class AddViewController: UIViewController {
return textField.text!
}

var taskDueDate: NSDate {
var taskDueDate: Date {
return datePicker.date
}

@IBOutlet private weak var textField: UITextField!
@IBOutlet private weak var datePicker: UIDatePicker!
@IBOutlet fileprivate weak var textField: UITextField!
@IBOutlet fileprivate weak var datePicker: UIDatePicker!

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
textField.becomeFirstResponder()
}
}
}
4 changes: 2 additions & 2 deletions MegaController/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

lazy var primaryViewController: ViewController = {
return UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("Primary") as! ViewController
return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Primary") as! ViewController
}()

func applicationDidFinishLaunching(application: UIApplication) {
func applicationDidFinishLaunching(_ application: UIApplication) {
primaryViewController.navigationThemeDidChangeHandler = { [weak self] theme in
if let navigationController = self?.navigationController {
navigationController.navigationBar.applyTheme(theme)
Expand Down
46 changes: 19 additions & 27 deletions MegaController/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8173.3" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="w3U-GZ-qt8">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="w3U-GZ-qt8">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8142"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Root View Controller-->
<scene sceneID="jDV-TZ-aVx">
<objects>
<tableViewController storyboardIdentifier="Primary" id="qco-Ga-9rX" customClass="ViewController" customModule="MegaController" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="5yl-Yw-pO6">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="30" sectionFooterHeight="22" id="5yl-Yw-pO6">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="IUn-Y6-yBy" detailTextLabel="UfP-s2-rcO" style="IBUITableViewCellStyleValue1" id="kpr-Lb-GAw" customClass="TaskTableViewCell" customModule="MegaController" customModuleProvider="target">
<rect key="frame" x="0.0" y="22" width="600" height="44"/>
<rect key="frame" x="0.0" y="30" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="kpr-Lb-GAw" id="flb-We-7Io">
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="IUn-Y6-yBy">
<rect key="frame" x="15" y="12" width="31.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="UfP-s2-rcO">
<rect key="frame" x="543.5" y="12" width="41.5" height="19.5"/>
<rect key="frame" x="318.5" y="12" width="41.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
</tableViewCellContentView>
<animations/>
</tableViewCell>
</prototypes>
<connections>
Expand Down Expand Up @@ -70,15 +69,14 @@
<viewControllerLayoutGuide type="bottom" id="dy6-Cj-WPF"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="qc4-5X-d2P">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1eB-XT-Mhu">
<rect key="frame" x="160" y="65" width="280" height="287"/>
<rect key="frame" x="47.5" y="65" width="280" height="287"/>
<subviews>
<navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FxY-k4-CaP">
<rect key="frame" x="0.0" y="0.0" width="280" height="44"/>
<animations/>
<items>
<navigationItem title="New Task" id="Htq-Ps-RSE">
<barButtonItem key="rightBarButtonItem" systemItem="done" id="vLx-9V-U8y">
Expand All @@ -91,13 +89,11 @@
</navigationBar>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Buy milk and eggs…" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="KIe-XQ-Qul">
<rect key="frame" x="8" y="57" width="264" height="17"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<datePicker contentMode="scaleToFill" verticalHuggingPriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" datePickerMode="date" minuteInterval="1" translatesAutoresizingMaskIntoConstraints="NO" id="DMQ-Ss-o0N">
<rect key="frame" x="0.0" y="87" width="280" height="200"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="200" id="vBc-QF-aP0"/>
</constraints>
Expand All @@ -107,15 +103,13 @@
</datePicker>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cZI-dg-RAn" userLabel="Hairline">
<rect key="frame" x="0.0" y="85" width="280" height="1"/>
<animations/>
<color key="backgroundColor" red="0.87566184997558594" green="0.87563550472259521" blue="0.87565046548843384" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.87566184997558594" green="0.87563550472259521" blue="0.87565046548843384" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="0.5" id="Lbg-t3-Aiz"/>
</constraints>
</view>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="DMQ-Ss-o0N" secondAttribute="trailing" id="2V3-yU-LGV"/>
<constraint firstAttribute="width" constant="280" id="2cg-dW-QHW"/>
Expand All @@ -134,8 +128,7 @@
</constraints>
</view>
</subviews>
<animations/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.16" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.16" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="1eB-XT-Mhu" firstAttribute="centerX" secondItem="qc4-5X-d2P" secondAttribute="centerX" id="Xge-DQ-E8r"/>
<constraint firstItem="1eB-XT-Mhu" firstAttribute="top" secondItem="CeM-Xi-Ztz" secondAttribute="bottom" constant="45" id="h0n-cX-vS8"/>
Expand All @@ -158,7 +151,6 @@
<navigationBar key="navigationBar" contentMode="scaleToFill" id="9Gx-EL-IWH">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
</navigationBar>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="j3a-2O-rJx" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
Loading