@@ -0,0 +1,65 @@
//
// GoalDetailsViewController.swift
// Goalie
//
// Created by Gregory Klein on 12/4/15.
// Copyright © 2015 Incipia. All rights reserved.
//
import UIKit
import CoreData

class GoalDetailsViewController: UIViewController, ManagedObjectContextSettable
{
@IBOutlet private weak var _titleTextField: UITextField!
@IBOutlet private weak var _summaryTextField: UITextField!
@IBOutlet private weak var _navigationItem: UINavigationItem!

var goal: Goal?
var managedObjectContext: NSManagedObjectContext!

convenience init()
{
self.init(nibName: nil, bundle: nil)
}

override func viewWillAppear(animated: Bool)
{
super.viewWillAppear(animated)

_titleTextField.text = goal?.title
_summaryTextField.text = goal?.summary

_navigationItem.title = goal != nil ? "Details" : "Create"
}

func configureWithGoal(goal: Goal)
{
self.goal = goal
}

@IBAction func doneButtonPressed()
{
// if we don't have a goal, then we want to createa new one
if goal == nil
{
managedObjectContext.performChanges { () -> () in
let title = self._titleTextField.text ?? "No Title Set"
let summary = self._summaryTextField.text ?? "No Summary Set"
Goal.insertIntoContext(self.managedObjectContext, withTitle: title, summary: summary)
}
}
dismissSelf()
}

@IBAction func cancelButtonPressed()
{
dismissSelf()
}

private func dismissSelf()
{
goal = nil
self.dismissViewControllerAnimated(true, completion: nil)
}
}
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="GoalDetailsViewController" customModule="Goalie" customModuleProvider="target">
<connections>
<outlet property="_navigationItem" destination="2fw-hC-wAB" id="i98-Qb-Yre"/>
<outlet property="_summaryTextField" destination="j09-vY-uVB" id="mbE-Ar-wrd"/>
<outlet property="_titleTextField" destination="QCo-ef-ybM" id="PxT-FK-sk3"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="97a-LG-zcC" customClass="GoalieNavigationBar" customModule="Goalie" customModuleProvider="target">
<rect key="frame" x="0.0" y="20" width="320" height="44"/>
<animations/>
<items>
<navigationItem title="Create Goal" id="2fw-hC-wAB">
<barButtonItem key="leftBarButtonItem" image="icn-x" id="HOp-xh-4Y1">
<connections>
<action selector="cancelButtonPressed" destination="-1" id="xXu-xA-ljt"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" image="icn-standby" id="z2a-ji-7Ce">
<connections>
<action selector="doneButtonPressed" destination="-1" id="Yld-EO-iZf"/>
</connections>
</barButtonItem>
</navigationItem>
</items>
</navigationBar>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ogF-Kx-Bl3">
<rect key="frame" x="8" y="458.5" width="304" height="101.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Month Selector" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e3l-no-l7g">
<rect key="frame" x="83" y="40" width="138" height="22"/>
<animations/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="18"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" red="0.66658060158169441" green="1" blue="0.95179470605725747" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="e3l-no-l7g" firstAttribute="centerX" secondItem="ogF-Kx-Bl3" secondAttribute="centerX" id="8hD-58-Oea"/>
<constraint firstItem="e3l-no-l7g" firstAttribute="centerY" secondItem="ogF-Kx-Bl3" secondAttribute="centerY" id="Ans-7B-EKc"/>
<constraint firstAttribute="width" secondItem="ogF-Kx-Bl3" secondAttribute="height" multiplier="3:1" id="frL-Qn-Gln"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zmA-IL-LLW">
<rect key="frame" x="8" y="170" width="304" height="280"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Subgoals" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iGs-gK-26P">
<rect key="frame" x="110" y="129" width="84" height="22"/>
<animations/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="18"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" red="0.52136980700123092" green="0.67401266671676741" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="iGs-gK-26P" firstAttribute="centerY" secondItem="zmA-IL-LLW" secondAttribute="centerY" id="EJc-w5-I8q"/>
<constraint firstItem="iGs-gK-26P" firstAttribute="centerX" secondItem="zmA-IL-LLW" secondAttribute="centerX" id="Rux-Yt-4a1"/>
</constraints>
</view>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Title" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="QCo-ef-ybM">
<rect key="frame" x="8" y="94" width="304" height="30"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Summary" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="j09-vY-uVB">
<rect key="frame" x="8" y="132" width="304" height="30"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="QCo-ef-ybM" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="2G6-gC-agU"/>
<constraint firstAttribute="bottom" secondItem="ogF-Kx-Bl3" secondAttribute="bottom" constant="8" id="5WQ-nF-Uce"/>
<constraint firstItem="97a-LG-zcC" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="8G6-jk-Kxe"/>
<constraint firstItem="j09-vY-uVB" firstAttribute="top" secondItem="QCo-ef-ybM" secondAttribute="bottom" constant="8" id="Dh9-L4-RBO"/>
<constraint firstItem="QCo-ef-ybM" firstAttribute="top" secondItem="97a-LG-zcC" secondAttribute="bottom" constant="30" id="FdF-T0-r7l"/>
<constraint firstItem="ogF-Kx-Bl3" firstAttribute="top" secondItem="zmA-IL-LLW" secondAttribute="bottom" constant="8" id="IBS-Dw-eLz"/>
<constraint firstItem="zmA-IL-LLW" firstAttribute="top" secondItem="j09-vY-uVB" secondAttribute="bottom" constant="8" id="IvW-lK-uLj"/>
<constraint firstAttribute="trailing" secondItem="zmA-IL-LLW" secondAttribute="trailing" constant="8" id="UaK-fq-xUy"/>
<constraint firstItem="zmA-IL-LLW" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="V0j-X2-YBD"/>
<constraint firstAttribute="trailing" secondItem="ogF-Kx-Bl3" secondAttribute="trailing" constant="8" id="VL7-hj-lQK"/>
<constraint firstAttribute="trailing" secondItem="QCo-ef-ybM" secondAttribute="trailing" constant="8" id="aqg-zO-d0W"/>
<constraint firstAttribute="trailing" secondItem="97a-LG-zcC" secondAttribute="trailing" id="big-RY-I4d"/>
<constraint firstItem="j09-vY-uVB" firstAttribute="width" secondItem="QCo-ef-ybM" secondAttribute="width" id="evy-yd-PHE"/>
<constraint firstItem="97a-LG-zcC" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="20" id="fow-Os-5NO"/>
<constraint firstItem="j09-vY-uVB" firstAttribute="centerX" secondItem="QCo-ef-ybM" secondAttribute="centerX" id="xp5-d4-E1I"/>
<constraint firstItem="ogF-Kx-Bl3" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="yGu-db-JlH"/>
</constraints>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<point key="canvasLocation" x="234" y="362"/>
</view>
</objects>
<resources>
<image name="icn-standby" width="24" height="24"/>
<image name="icn-x" width="22" height="22"/>
</resources>
</document>