Skip to content

Commit 5ad05ce

Browse files
committed
1 parent 927fd1b commit 5ad05ce

File tree

6 files changed

+144
-8
lines changed

6 files changed

+144
-8
lines changed
451 KB
Loading

Xcode/PaintCodeTests.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
071D1DC021FE217200A096F0 /* CircleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 071D1DBF21FE217200A096F0 /* CircleView.swift */; };
1313
071D1DC221FE218300A096F0 /* CircleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 071D1DC121FE218300A096F0 /* CircleViewController.swift */; };
1414
073DC50621FE290E009B6ECE /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 073DC50521FE290E009B6ECE /* README.md */; };
15+
ED29A579222C44DB00493720 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED29A578222C44DB00493720 /* TableViewController.swift */; };
16+
ED29A57B222C474C00493720 /* CustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED29A57A222C474C00493720 /* CustomCell.swift */; };
1517
ED2E0C3F213DD8110029BC7D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED2E0C3E213DD8110029BC7D /* AppDelegate.swift */; };
1618
ED2E0C46213DD8140029BC7D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ED2E0C45213DD8140029BC7D /* Assets.xcassets */; };
1719
ED2E0C59213DD8E20029BC7D /* ClockHandViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED2E0C56213DD8E20029BC7D /* ClockHandViewController.swift */; };
@@ -30,6 +32,8 @@
3032
071D1DBF21FE217200A096F0 /* CircleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleView.swift; sourceTree = "<group>"; };
3133
071D1DC121FE218300A096F0 /* CircleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleViewController.swift; sourceTree = "<group>"; };
3234
073DC50521FE290E009B6ECE /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
35+
ED29A578222C44DB00493720 /* TableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; };
36+
ED29A57A222C474C00493720 /* CustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCell.swift; sourceTree = "<group>"; };
3337
ED2E0C3B213DD8110029BC7D /* PaintCodeTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PaintCodeTests.app; sourceTree = BUILT_PRODUCTS_DIR; };
3438
ED2E0C3E213DD8110029BC7D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3539
ED2E0C45213DD8140029BC7D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -96,6 +100,7 @@
96100
children = (
97101
071D1DBF21FE217200A096F0 /* CircleView.swift */,
98102
ED2E0C5E213DD8F60029BC7D /* ClockHandView.swift */,
103+
ED29A57A222C474C00493720 /* CustomCell.swift */,
99104
071D1DBB21FE1C4400A096F0 /* StarView.swift */,
100105
ED2E0C5D213DD8F60029BC7D /* TextButton.swift */,
101106
ED2E0C5C213DD8F60029BC7D /* TreeView.swift */,
@@ -110,6 +115,7 @@
110115
ED2E0C56213DD8E20029BC7D /* ClockHandViewController.swift */,
111116
ED2E0C58213DD8E20029BC7D /* MainViewController.swift */,
112117
071D1DBD21FE1C5100A096F0 /* StarViewController.swift */,
118+
ED29A578222C44DB00493720 /* TableViewController.swift */,
113119
ED2E0C57213DD8E20029BC7D /* TreeViewController.swift */,
114120
);
115121
path = Controller;
@@ -208,6 +214,7 @@
208214
files = (
209215
ED2E0C67213DD9100029BC7D /* StyleKit.swift in Sources */,
210216
ED2E0C60213DD8F70029BC7D /* TextButton.swift in Sources */,
217+
ED29A579222C44DB00493720 /* TableViewController.swift in Sources */,
211218
071D1DC221FE218300A096F0 /* CircleViewController.swift in Sources */,
212219
ED2E0C5F213DD8F70029BC7D /* TreeView.swift in Sources */,
213220
ED2E0C59213DD8E20029BC7D /* ClockHandViewController.swift in Sources */,
@@ -217,6 +224,7 @@
217224
ED2E0C5A213DD8E20029BC7D /* TreeViewController.swift in Sources */,
218225
ED2E0C3F213DD8110029BC7D /* AppDelegate.swift in Sources */,
219226
071D1DBC21FE1C4400A096F0 /* StarView.swift in Sources */,
227+
ED29A57B222C474C00493720 /* CustomCell.swift in Sources */,
220228
ED2E0C5B213DD8E20029BC7D /* MainViewController.swift in Sources */,
221229
);
222230
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// TableViewController.swift
3+
// PaintCodeTests
4+
//
5+
// Created by Fernando Fernandes on 03.03.19.
6+
// Copyright © 2019 backslash-f. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class TableViewController: UITableViewController {
12+
13+
// MARK: - Table view data source
14+
15+
override func numberOfSections(in tableView: UITableView) -> Int {
16+
return 1
17+
}
18+
19+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
20+
return 40
21+
}
22+
23+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
24+
var cell = UITableViewCell()
25+
26+
if let customCell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath) as? CustomCell {
27+
cell = customCell
28+
29+
// Icon from PaintCode. In this example I'll be using two different icons, that's why I first create this
30+
// placeholder `UIView`.
31+
var icon = UIView(frame: customCell.iconView.frame)
32+
33+
if indexPath.row < 20 {
34+
icon = StarView(frame: icon.frame)
35+
customCell.label.text = "Star"
36+
37+
} else {
38+
icon = TreeView(frame: icon.frame)
39+
customCell.label.text = "Tree"
40+
}
41+
42+
customCell.iconView.addSubview(icon)
43+
}
44+
45+
return cell
46+
}
47+
}

Xcode/PaintCodeTests/Storyboard/Main.storyboard

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,50 @@
2222
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2323
<subviews>
2424
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="u7B-jc-ZcQ">
25-
<rect key="frame" x="100" y="218.5" width="175" height="230"/>
25+
<rect key="frame" x="82.5" y="193.5" width="210" height="280"/>
2626
<subviews>
2727
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="God-qr-vyq">
28-
<rect key="frame" x="42" y="0.0" width="91" height="30"/>
28+
<rect key="frame" x="59.5" y="0.0" width="91" height="30"/>
2929
<state key="normal" title="Test Collision"/>
3030
<connections>
3131
<segue destination="3o9-9N-m9o" kind="show" id="IOS-ev-5Bc"/>
3232
</connections>
3333
</button>
3434
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4c0-ea-c0S">
35-
<rect key="frame" x="17" y="50" width="141" height="30"/>
35+
<rect key="frame" x="34.5" y="50" width="141" height="30"/>
3636
<state key="normal" title="Test Dynamic Colors"/>
3737
<connections>
3838
<segue destination="du8-3p-Jqr" kind="show" id="g8w-IC-W2P"/>
3939
</connections>
4040
</button>
4141
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="S8B-IS-yMB" userLabel="Test Button Text">
42-
<rect key="frame" x="31.5" y="100" width="112" height="30"/>
42+
<rect key="frame" x="49" y="100" width="112" height="30"/>
4343
<state key="normal" title="Test Button Text"/>
4444
<connections>
4545
<segue destination="raa-v1-uIT" kind="show" id="9f3-lb-kYd"/>
4646
</connections>
4747
</button>
4848
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AAB-GF-idZ" userLabel="Test Dynamic Stroke">
49-
<rect key="frame" x="17" y="150" width="141" height="30"/>
49+
<rect key="frame" x="34.5" y="150" width="141" height="30"/>
5050
<state key="normal" title="Test Dynamic Stroke"/>
5151
<connections>
5252
<segue destination="aVr-dL-ZLL" kind="show" id="a7m-yb-h9X"/>
5353
</connections>
5454
</button>
5555
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xzB-Xq-X3N" userLabel="Test Clockwise Animation">
56-
<rect key="frame" x="0.0" y="200" width="175" height="30"/>
56+
<rect key="frame" x="17.5" y="200" width="175" height="30"/>
5757
<state key="normal" title="Test Clockwise Animation"/>
5858
<connections>
5959
<segue destination="thN-Zr-RuG" kind="show" id="n0q-TJ-gBF"/>
6060
</connections>
6161
</button>
62+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LOh-O9-da8">
63+
<rect key="frame" x="0.0" y="250" width="210" height="30"/>
64+
<state key="normal" title="Test Custom Cell in Table View"/>
65+
<connections>
66+
<segue destination="gkV-ZT-87H" kind="show" id="Jsw-La-eaV"/>
67+
</connections>
68+
</button>
6269
</subviews>
6370
</stackView>
6471
</subviews>
@@ -99,7 +106,7 @@
99106
</viewController>
100107
<placeholder placeholderIdentifier="IBFirstResponder" id="6L5-us-mKN" userLabel="First Responder" sceneMemberID="firstResponder"/>
101108
</objects>
102-
<point key="canvasLocation" x="3598" y="334"/>
109+
<point key="canvasLocation" x="3588" y="-199"/>
103110
</scene>
104111
<!--Star View Controller-->
105112
<scene sceneID="MVv-sm-We0">
@@ -162,6 +169,63 @@
162169
</objects>
163170
<point key="canvasLocation" x="2665" y="922"/>
164171
</scene>
172+
<!--Table View Controller-->
173+
<scene sceneID="bNs-BX-GeT">
174+
<objects>
175+
<tableViewController id="gkV-ZT-87H" customClass="TableViewController" customModule="PaintCodeTests" customModuleProvider="target" sceneMemberID="viewController">
176+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="mtp-vd-3Tj">
177+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
178+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
179+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
180+
<prototypes>
181+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="customCell" id="3bu-ol-apd" customClass="CustomCell" customModule="PaintCodeTests" customModuleProvider="target">
182+
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
183+
<autoresizingMask key="autoresizingMask"/>
184+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="3bu-ol-apd" id="eTE-bj-GCn">
185+
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
186+
<autoresizingMask key="autoresizingMask"/>
187+
<subviews>
188+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="x8Z-o1-aJn">
189+
<rect key="frame" x="10" y="2" width="40" height="40"/>
190+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
191+
<constraints>
192+
<constraint firstAttribute="width" constant="40" id="2T4-tw-W5R"/>
193+
<constraint firstAttribute="height" constant="40" id="6P5-57-gJC"/>
194+
</constraints>
195+
</view>
196+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="G2I-Km-kja">
197+
<rect key="frame" x="70" y="13" width="279" height="20.5"/>
198+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
199+
<nil key="textColor"/>
200+
<nil key="highlightedColor"/>
201+
</label>
202+
</subviews>
203+
<constraints>
204+
<constraint firstItem="x8Z-o1-aJn" firstAttribute="leading" secondItem="eTE-bj-GCn" secondAttribute="leading" constant="10" id="45S-gp-5Du"/>
205+
<constraint firstItem="G2I-Km-kja" firstAttribute="top" secondItem="eTE-bj-GCn" secondAttribute="topMargin" constant="2" id="At3-3a-UDn"/>
206+
<constraint firstItem="x8Z-o1-aJn" firstAttribute="top" secondItem="eTE-bj-GCn" secondAttribute="top" constant="2" id="CD5-yN-hov"/>
207+
<constraint firstItem="G2I-Km-kja" firstAttribute="leading" secondItem="x8Z-o1-aJn" secondAttribute="trailing" constant="20" id="asR-AI-xH5"/>
208+
<constraint firstItem="G2I-Km-kja" firstAttribute="bottom" secondItem="eTE-bj-GCn" secondAttribute="bottomMargin" constant="2" id="cff-CZ-qIm"/>
209+
<constraint firstAttribute="trailingMargin" secondItem="G2I-Km-kja" secondAttribute="trailing" constant="10" id="ctK-u5-nIz"/>
210+
<constraint firstAttribute="bottom" secondItem="x8Z-o1-aJn" secondAttribute="bottom" constant="2" id="nCe-jf-BdC"/>
211+
</constraints>
212+
</tableViewCellContentView>
213+
<connections>
214+
<outlet property="iconView" destination="x8Z-o1-aJn" id="QNb-sw-31N"/>
215+
<outlet property="label" destination="G2I-Km-kja" id="WK7-xC-dao"/>
216+
</connections>
217+
</tableViewCell>
218+
</prototypes>
219+
<connections>
220+
<outlet property="dataSource" destination="gkV-ZT-87H" id="klI-dJ-ck1"/>
221+
<outlet property="delegate" destination="gkV-ZT-87H" id="DWq-D2-pfU"/>
222+
</connections>
223+
</tableView>
224+
</tableViewController>
225+
<placeholder placeholderIdentifier="IBFirstResponder" id="aeR-bF-2mP" userLabel="First Responder" sceneMemberID="firstResponder"/>
226+
</objects>
227+
<point key="canvasLocation" x="3588" y="922"/>
228+
</scene>
165229
<!--Navigation Controller-->
166230
<scene sceneID="xlj-i8-25u">
167231
<objects>

Xcode/PaintCodeTests/View/CircleView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protocol CircleViewDelegate {
1616
func didCompleteAnimation()
1717
}
1818

19-
@IBDesignable class CircleView: UIView {
19+
class CircleView: UIView {
2020

2121
// MARK: - Properties
2222

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// CustomCell.swift
3+
// PaintCodeTests
4+
//
5+
// Created by Fernando Fernandes on 03.03.19.
6+
// Copyright © 2019 backslash-f. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class CustomCell: UITableViewCell {
12+
13+
// MARK: - Properties
14+
15+
@IBOutlet weak var iconView: UIView!
16+
@IBOutlet weak var label: UILabel!
17+
}

0 commit comments

Comments
 (0)