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

not done yet #7

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
29 changes: 28 additions & 1 deletion Seasonizer/AccessoryListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,37 @@ class AccessoryListViewController: UITableViewController {
}

*/


private var indexOfSelectedAccessory = 0

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "selectedAccessory" {
guard let indexPath = tableView.indexPathForSelectedRow else {return }
selectedAccessory = accessories![indexPath.row]
}
}
}


// MARK: - Table View Data Source

// TODO: Implement the `UITableViewDataSource` protocol.

extension AccessoryListViewController {

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return (accessories?.count)!
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("AccessoryCell", forIndexPath: indexPath) as UITableViewCell

cell.imageView!.image = accessories![indexPath.row].image
cell.textLabel!.text = accessories![indexPath.row].title
return cell
}
}
36 changes: 34 additions & 2 deletions Seasonizer/CanvasViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI
UIGraphicsEndImageContext()
return renderedPicture
}



private var selectedAccessory : Accessory?

// MARK: User Interaction

Expand Down Expand Up @@ -128,9 +130,39 @@ class CanvasViewController: UIViewController, UINavigationControllerDelegate, UI
}
*/


override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
switch segue.identifier! {
case "AccessoryView":
guard let accessoryListViewController = (segue.destinationViewController as? UINavigationController)?.topViewController as? AccessoryListViewController else {break}
accessoryListViewController.accessories = allAccessories
print(accessoryListViewController.accessories)

default:
break
}
}

// TODO: Implement an `@IBAction func unwindToCanvas(segue: UIStoryboardSegue)` Unwing Segue that the `AccessoryListViewController` can exit to.

@IBAction func unwindToCanvas (segue: UIStoryboardSegue) {
switch segue.identifier! {
case "selectedAccessory":
guard let accessoryListViewController = segue.sourceViewController as? AccessoryListViewController, selectedAccessory = accessoryListViewController.selectedAccessory else {
break
}
let accessoryView = AccessoryView(accessory: selectedAccessory)
accessoryView.center = accessoryOverlayView.convertPoint(accessoryOverlayView.center, fromView: accessoryOverlayView.superview)

addAccessoryView(accessoryView)

case "ExitFromButton":
print("buttonExitToCanvas fired")
default:
break
}
}


// TODO: For the "selectedAccessory" segue, obtain the selected accessory and add it to the canvas.
/*
HINTS:
Expand Down
100 changes: 97 additions & 3 deletions Seasonizer/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="A6u-BR-TcU">
<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="A6u-BR-TcU">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
Expand All @@ -15,15 +15,109 @@
<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"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jNW-tr-SmO">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
</imageView>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w4T-rG-lGH">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<color key="backgroundColor" white="1" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<toolbarItems/>
<navigationItem key="navigationItem" title="Seasonizer" id="6dS-Kq-rKs"/>
<toolbarItems>
<barButtonItem systemItem="trash" id="bjQ-B8-ZmT">
<connections>
<action selector="trashButtonPressed:" destination="BYZ-38-t0r" id="ww8-H7-9xf"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="f8I-6k-DAY"/>
<barButtonItem systemItem="camera" id="0mj-nL-XMG">
<connections>
<action selector="cameraButtonPressed:" destination="BYZ-38-t0r" id="Gr0-n9-kau"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="VL6-fY-Ann"/>
<barButtonItem title="Accessories" id="5fO-ot-e6c">
<connections>
<segue destination="LqA-uR-lOK" kind="presentation" id="phE-fv-E9I"/>
</connections>
</barButtonItem>
</toolbarItems>
<navigationItem key="navigationItem" title="Seasonizer" id="6dS-Kq-rKs">
<barButtonItem key="rightBarButtonItem" systemItem="action" id="lUa-fO-mFi">
<connections>
<action selector="actionButtonPressed:" destination="BYZ-38-t0r" id="fge-i0-e4B"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="accessoryOverlayView" destination="w4T-rG-lGH" id="UYw-ID-QiK"/>
<outlet property="photoImageView" destination="jNW-tr-SmO" id="YWr-Mt-feQ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1010" y="136"/>
</scene>
<!--Accessories-->
<scene sceneID="7Os-S5-7xP">
<objects>
<tableViewController title="Accessories" id="S6D-xH-r3H" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="od4-U7-HmN">
<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="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="X1m-Do-2ra">
<rect key="frame" x="0.0" y="92" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="X1m-Do-2ra" id="72k-Ty-JHr">
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="S6D-xH-r3H" id="Mv2-fS-stX"/>
<outlet property="delegate" destination="S6D-xH-r3H" id="lmA-Kb-2NF"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Accessories" id="c1K-Cg-mpz">
<barButtonItem key="rightBarButtonItem" title="Cancel" id="ZDl-8b-tfX">
<connections>
<segue destination="Mzv-F5-kQL" kind="unwind" unwindAction="unwindToCanvas:" id="Lec-zf-LPm"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="tpV-7O-HR2" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="Mzv-F5-kQL" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="2489" y="136"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="Nes-Bu-FNh">
<objects>
<navigationController toolbarHidden="NO" id="LqA-uR-lOK" sceneMemberID="viewController">
<navigationItem key="navigationItem" id="F1M-eg-odS"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="tvJ-3G-w5o">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="CFV-Kd-7zS">
<rect key="frame" x="0.0" y="556" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</toolbar>
<connections>
<segue destination="S6D-xH-r3H" kind="relationship" relationship="rootViewController" id="QO2-xu-6MU"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3P4-rh-lbc" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1745" y="136"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="WSz-3O-Obv">
<objects>
Expand Down