Skip to content

Commit

Permalink
Simple list
Browse files Browse the repository at this point in the history
  • Loading branch information
mriddle committed Apr 27, 2016
1 parent 4a5378b commit fc9be48
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 45 deletions.
12 changes: 8 additions & 4 deletions Checklists.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@

/* Begin PBXBuildFile section */
A81172C51CD0660E00BA3196 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172C41CD0660E00BA3196 /* AppDelegate.swift */; };
A81172C71CD0660E00BA3196 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172C61CD0660E00BA3196 /* ViewController.swift */; };
A81172C71CD0660E00BA3196 /* ChecklistViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172C61CD0660E00BA3196 /* ChecklistViewController.swift */; };
A81172CA1CD0660E00BA3196 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A81172C81CD0660E00BA3196 /* Main.storyboard */; };
A81172CC1CD0660F00BA3196 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A81172CB1CD0660F00BA3196 /* Assets.xcassets */; };
A81172CF1CD0660F00BA3196 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A81172CD1CD0660F00BA3196 /* LaunchScreen.storyboard */; };
A81172D91CD0859800BA3196 /* ChecklistItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172D81CD0859800BA3196 /* ChecklistItem.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
A81172C11CD0660E00BA3196 /* Checklists.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Checklists.app; sourceTree = BUILT_PRODUCTS_DIR; };
A81172C41CD0660E00BA3196 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A81172C61CD0660E00BA3196 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
A81172C61CD0660E00BA3196 /* ChecklistViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChecklistViewController.swift; sourceTree = "<group>"; };
A81172C91CD0660E00BA3196 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
A81172CB1CD0660F00BA3196 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A81172CE1CD0660F00BA3196 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
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>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -55,11 +57,12 @@
isa = PBXGroup;
children = (
A81172C41CD0660E00BA3196 /* AppDelegate.swift */,
A81172C61CD0660E00BA3196 /* ViewController.swift */,
A81172C61CD0660E00BA3196 /* ChecklistViewController.swift */,
A81172C81CD0660E00BA3196 /* Main.storyboard */,
A81172CB1CD0660F00BA3196 /* Assets.xcassets */,
A81172CD1CD0660F00BA3196 /* LaunchScreen.storyboard */,
A81172D01CD0660F00BA3196 /* Info.plist */,
A81172D81CD0859800BA3196 /* ChecklistItem.swift */,
);
path = Checklists;
sourceTree = "<group>";
Expand Down Expand Up @@ -136,7 +139,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A81172C71CD0660E00BA3196 /* ViewController.swift in Sources */,
A81172C71CD0660E00BA3196 /* ChecklistViewController.swift in Sources */,
A81172D91CD0859800BA3196 /* ChecklistItem.swift in Sources */,
A81172C51CD0660E00BA3196 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Checklists/ChecklistItem.swift"
timestampString = "483431778.647364"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
landmarkName = "init(text:checked:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Checklists/ChecklistViewController.swift"
timestampString = "483431293.296945"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "40"
endingLineNumber = "40"
landmarkName = "tableView(_:cellForRowAtIndexPath:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A81172C01CD0660E00BA3196"
BuildableName = "Checklists.app"
BlueprintName = "Checklists"
ReferencedContainer = "container:Checklists.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
Expand All @@ -13,6 +29,15 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A81172C01CD0660E00BA3196"
BuildableName = "Checklists.app"
BlueprintName = "Checklists"
ReferencedContainer = "container:Checklists.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
Expand All @@ -26,6 +51,16 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A81172C01CD0660E00BA3196"
BuildableName = "Checklists.app"
BlueprintName = "Checklists"
ReferencedContainer = "container:Checklists.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -35,6 +70,16 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A81172C01CD0660E00BA3196"
BuildableName = "Checklists.app"
BlueprintName = "Checklists"
ReferencedContainer = "container:Checklists.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
48 changes: 34 additions & 14 deletions Checklists/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="0EI-kG-L1l">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<!--Checklist View Controller-->
<scene sceneID="VS5-Ai-0gM">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" 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">
<tableViewController id="0EI-kG-L1l" customClass="ChecklistViewController" 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="l5t-lE-Kti">
<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"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="checkmark" indentationWidth="10" reuseIdentifier="ChecklistItem" id="pcY-ab-PJf">
<rect key="frame" x="0.0" y="28" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="pcY-ab-PJf" id="Yyu-oC-sqR">
<rect key="frame" x="0.0" y="0.0" width="561" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1000" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7UG-qx-RTx">
<rect key="frame" x="8" y="11" width="553" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="0EI-kG-L1l" id="tKA-1S-Rzv"/>
<outlet property="delegate" destination="0EI-kG-L1l" id="Ogo-Fc-Jim"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="mBe-6g-oHr" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="169" y="603"/>
</scene>
</scenes>
</document>
21 changes: 21 additions & 0 deletions Checklists/ChecklistItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// ChecklistItem.swift
// Checklists
//
// Created by Matthew Riddle on 27/04/2016.
// Copyright © 2016 Matthew Riddle. All rights reserved.
//

import Foundation

class ChecklistItem {
var text: String
var checked: Bool

init(text: String, checked: Bool) {
self.text = text
self.checked = checked
}


}
75 changes: 75 additions & 0 deletions Checklists/ChecklistViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// ViewController.swift
// Checklists
//
// Created by Matthew Riddle on 27/04/2016.
// Copyright © 2016 Matthew Riddle. All rights reserved.
//

import UIKit

class ChecklistViewController: UITableViewController {
var items: Array = [
ChecklistItem(text: "Walk the dog", checked: false),
ChecklistItem(text: "Brush teeth", checked: false),
ChecklistItem(text: "Learn iOS development", checked: false),
ChecklistItem(text: "Soccer practice", checked: false),
ChecklistItem(text: "Eat ice cream", checked: false)
]


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

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

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

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

let label = cell.viewWithTag(1000) as! UILabel

if indexPath.row < items.count {
label.text = items[indexPath.row].text
}
configureCheckmarkForCell(cell, atIndexPath: indexPath)
return cell
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

if let cell = tableView.cellForRowAtIndexPath(indexPath) {
if indexPath.row < items.count {
let item = items[indexPath.row]
item.checked = !item.checked
}

configureCheckmarkForCell(cell, atIndexPath: indexPath)
}

tableView.deselectRowAtIndexPath(indexPath, animated: true)
}

func configureCheckmarkForCell(cell: UITableViewCell, atIndexPath: NSIndexPath) {
if atIndexPath.row < items.count {
let item = items[atIndexPath.row]

if item.checked {
cell.accessoryType = .Checkmark
} else {
cell.accessoryType = .None
}
}
}


}

2 changes: 0 additions & 2 deletions Checklists/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
25 changes: 0 additions & 25 deletions Checklists/ViewController.swift

This file was deleted.

0 comments on commit fc9be48

Please sign in to comment.