Skip to content
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
4 changes: 4 additions & 0 deletions Lifetime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
17467B2B1CE1EF44009EBC6B /* LifetimeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17467B2A1CE1EF44009EBC6B /* LifetimeCell.swift */; };
870312411CD4EDBC00A48B90 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8703123F1CD4EDBC00A48B90 /* LaunchScreen.storyboard */; };
870312421CD4EDBC00A48B90 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 870312401CD4EDBC00A48B90 /* Main.storyboard */; };
871045011CD4ED800091710A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 871044F21CD4ED800091710A /* AppDelegate.swift */; };
Expand All @@ -17,6 +18,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
17467B2A1CE1EF44009EBC6B /* LifetimeCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LifetimeCell.swift; path = Lifetime/LifetimeCell.swift; sourceTree = SOURCE_ROOT; };
8703123F1CD4EDBC00A48B90 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = Lifetime/LaunchScreen.storyboard; sourceTree = SOURCE_ROOT; };
870312401CD4EDBC00A48B90 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Lifetime/Main.storyboard; sourceTree = SOURCE_ROOT; };
871044D91CD3C9860091710A /* Lifetime.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Lifetime.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -69,6 +71,7 @@
870312481CD4EECD00A48B90 /* View */ = {
isa = PBXGroup;
children = (
17467B2A1CE1EF44009EBC6B /* LifetimeCell.swift */,
);
name = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -177,6 +180,7 @@
8710450A1CD4ED800091710A /* Lifetime.swift in Sources */,
871045071CD4ED800091710A /* ContactDetailViewController.swift in Sources */,
871045011CD4ED800091710A /* AppDelegate.swift in Sources */,
17467B2B1CE1EF44009EBC6B /* LifetimeCell.swift in Sources */,
871045081CD4ED800091710A /* ContactListViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
33 changes: 32 additions & 1 deletion Lifetime/ContactListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,39 @@ class ContactListViewController: UITableViewController {

// MARK: - Table View Datasource

// TODO: implement UITableViewDatasource protocol
// TODO: implement UITableViewDatasource protocol -done

extension ContactListViewController {

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1 // zeigt kontakte zunächst in einer einzelnen Section an

}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return contacts.count // jeder kontankt soll eine neue zeile bekommen
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

//View komponente: Frage die TableView nach einer wiederverwendbaren Zelle
let cell = tableView.dequeueReusableCellWithIdentifier("LifetimeCell", forIndexPath: indexPath) as! LifetimeCell

// MODEL-Komponente: Bestimme den Kontakt für diese → Zeile

let contact = contacts[indexPath.row]
cell.configureForContact(contact)
if contact.lifetime != nil {
cell.selectionStyle = .Default
cell.accessoryType = .DisclosureIndicator
}
else {
cell.selectionStyle = .None
cell.accessoryType = .None
}
return cell
}
}

// MARK: - Search Results Updating

Expand Down
6 changes: 3 additions & 3 deletions Lifetime/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -15,7 +16,6 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
Expand Down
27 changes: 27 additions & 0 deletions Lifetime/LifetimeCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// LifetimeCell.swift
// Lifetime
//
// Created by Florian M. on 10/05/16.
// Copyright © 2016 iOS Dev Kurs Universität Heidelberg. All rights reserved.
//

import Foundation
import UIKit
import Contacts

class LifetimeCell: UITableViewCell {

func configureForContact(contact: CNContact) {
textLabel?.text = CNContactFormatter.stringFromContact(contact, style: .FullName)
if let lifetime = contact.lifetime {
let lifetimeFormatter = NSDateComponentsFormatter()
lifetimeFormatter.allowedUnits = .Day
lifetimeFormatter.unitsStyle = .Full
detailTextLabel?.text = lifetimeFormatter.stringFromTimeInterval(lifetime)

} else {
detailTextLabel?.text = nil
}
}
}
33 changes: 31 additions & 2 deletions Lifetime/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="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="RMx-3f-FxP">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="RMx-3f-FxP">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
Expand Down Expand Up @@ -78,6 +78,35 @@
<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" reuseIdentifier="LifetimeCell" textLabel="KOV-Q4-Wqw" detailTextLabel="NRn-f9-QkI" style="IBUITableViewCellStyleValue1" id="ZAL-QO-AO5" customClass="LifetimeCell" customModule="Lifetime" customModuleProvider="target">
<rect key="frame" x="0.0" y="86" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ZAL-QO-AO5" id="yJ3-JS-SNG">
<rect key="frame" x="0.0" y="0.0" width="600" 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="KOV-Q4-Wqw">
<rect key="frame" x="15" y="12" width="31.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="NRn-f9-QkI">
<rect key="frame" x="543.5" y="12" width="41.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="JEX-9P-axG" kind="show" id="sAi-Zf-IJG"/>
</connections>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="7bK-jq-Zjz" id="Gho-Na-rnu"/>
Expand All @@ -88,7 +117,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="709" y="-630"/>
<point key="canvasLocation" x="713" y="-630"/>
</scene>
</scenes>
</document>