Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mriddle committed Apr 29, 2016
1 parent a3c034b commit 5bdc47d
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 4 deletions.
47 changes: 47 additions & 0 deletions AllListsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import UIKit

class AllListsViewController: UITableViewController {

var lists = [
Checklist(name: "Birthdays"),
Checklist(name: "Groceries"),
Checklist(name: "Cool Apps"),
Checklist(name: "To Do")
]

override func viewDidLoad() {
super.viewDidLoad()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

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

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = cellForTableView(tableView)

let checklist = lists[indexPath.row]
cell.textLabel!.text = checklist.name
cell.accessoryType = .DetailDisclosureButton

return cell
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let checklist = lists[indexPath.row]
performSegueWithIdentifier("ShowChecklist", sender: checklist)
}

func cellForTableView(tableView: UITableView) -> UITableViewCell {
let cellIdentifier = "Cell"
if let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) {
return cell
} else {
return UITableViewCell(style: .Default, reuseIdentifier: cellIdentifier)
}
}
}
8 changes: 8 additions & 0 deletions Checklists.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
A81172CF1CD0660F00BA3196 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A81172CD1CD0660F00BA3196 /* LaunchScreen.storyboard */; };
A81172D91CD0859800BA3196 /* ChecklistItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172D81CD0859800BA3196 /* ChecklistItem.swift */; };
A8961D4F1CD19E87006AFAF4 /* ItemDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8961D4E1CD19E87006AFAF4 /* ItemDetailViewController.swift */; };
A8961D541CD309B0006AFAF4 /* AllListsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8961D531CD309B0006AFAF4 /* AllListsViewController.swift */; };
A8961D561CD31108006AFAF4 /* Checklist.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8961D551CD31108006AFAF4 /* Checklist.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -26,6 +28,8 @@
A81172D01CD0660F00BA3196 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A81172D81CD0859800BA3196 /* ChecklistItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChecklistItem.swift; sourceTree = "<group>"; };
A8961D4E1CD19E87006AFAF4 /* ItemDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ItemDetailViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
A8961D531CD309B0006AFAF4 /* AllListsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AllListsViewController.swift; path = ../AllListsViewController.swift; sourceTree = "<group>"; };
A8961D551CD31108006AFAF4 /* Checklist.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Checklist.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -58,13 +62,15 @@
A81172C31CD0660E00BA3196 /* Checklists */ = {
isa = PBXGroup;
children = (
A8961D531CD309B0006AFAF4 /* AllListsViewController.swift */,
A81172C41CD0660E00BA3196 /* AppDelegate.swift */,
A81172C61CD0660E00BA3196 /* ChecklistViewController.swift */,
A81172C81CD0660E00BA3196 /* Main.storyboard */,
A81172CB1CD0660F00BA3196 /* Assets.xcassets */,
A81172CD1CD0660F00BA3196 /* LaunchScreen.storyboard */,
A81172D01CD0660F00BA3196 /* Info.plist */,
A81172D81CD0859800BA3196 /* ChecklistItem.swift */,
A8961D551CD31108006AFAF4 /* Checklist.swift */,
A8961D4E1CD19E87006AFAF4 /* ItemDetailViewController.swift */,
);
path = Checklists;
Expand Down Expand Up @@ -144,7 +150,9 @@
files = (
A81172C71CD0660E00BA3196 /* ChecklistViewController.swift in Sources */,
A8961D4F1CD19E87006AFAF4 /* ItemDetailViewController.swift in Sources */,
A8961D561CD31108006AFAF4 /* Checklist.swift in Sources */,
A81172D91CD0859800BA3196 /* ChecklistItem.swift in Sources */,
A8961D541CD309B0006AFAF4 /* AllListsViewController.swift in Sources */,
A81172C51CD0660E00BA3196 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
28 changes: 25 additions & 3 deletions Checklists/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@
</dependencies>
<scenes>
<!--Checklists-->
<scene sceneID="m7b-3S-MsN">
<objects>
<tableViewController id="i4d-ru-O2O" customClass="AllListsViewController" customModule="Checklists" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="wXp-Qf-kcf">
<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"/>
<connections>
<outlet property="dataSource" destination="i4d-ru-O2O" id="zcz-8c-k2t"/>
<outlet property="delegate" destination="i4d-ru-O2O" id="iOt-sU-b1P"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Checklists" id="JLT-i1-af1"/>
<connections>
<segue destination="0EI-kG-L1l" kind="show" identifier="ShowChecklist" id="PpX-bR-tnW"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="CTC-Rv-1W7" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="853" y="923"/>
</scene>
<!--(Name of the Checklist)-->
<scene sceneID="VS5-Ai-0gM">
<objects>
<tableViewController id="0EI-kG-L1l" customClass="ChecklistViewController" customModule="Checklists" customModuleProvider="target" sceneMemberID="viewController">
Expand Down Expand Up @@ -45,7 +67,7 @@
<outlet property="delegate" destination="0EI-kG-L1l" id="Ogo-Fc-Jim"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Checklists" id="sOD-Qq-F4w">
<navigationItem key="navigationItem" title="(Name of the Checklist)" id="sOD-Qq-F4w">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="ohf-8e-nXL">
<connections>
<segue destination="d35-fu-ixk" kind="presentation" identifier="AddItem" id="7MH-Zf-ncI"/>
Expand Down Expand Up @@ -127,12 +149,12 @@
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="0EI-kG-L1l" kind="relationship" relationship="rootViewController" id="J1P-vA-EXl"/>
<segue destination="i4d-ru-O2O" kind="relationship" relationship="rootViewController" id="ter-X5-2yu"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="fx2-OR-nQN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="182" y="223"/>
<point key="canvasLocation" x="853" y="222"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="9WR-cb-PLh">
Expand Down
10 changes: 10 additions & 0 deletions Checklists/Checklist.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import UIKit

class Checklist: NSObject {
var name: String

init(name: String) {
self.name = name
super.init()
}
}
1 change: 1 addition & 0 deletions Checklists/ChecklistItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ChecklistItem: NSObject, NSCoding {
required init?(coder aDecoder: NSCoder) {
text = aDecoder.decodeObjectForKey("Text") as! String
checked = aDecoder.decodeBoolForKey("Checked")

super.init()
}

Expand Down
4 changes: 3 additions & 1 deletion Checklists/ChecklistViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ChecklistViewController: UITableViewController, ItemDetailViewControllerDe
ChecklistItem(text: "Eat ice cream", checked: false)
]

var checklist: Checklist!

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
loadChecklistItems()
Expand All @@ -41,7 +43,7 @@ class ChecklistViewController: UITableViewController, ItemDetailViewControllerDe

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
title = checklist.name
}

override func didReceiveMemoryWarning() {
Expand Down

0 comments on commit 5bdc47d

Please sign in to comment.