Skip to content

Commit b2e1ba7

Browse files
committed
First working version with SPM
1 parent 2535832 commit b2e1ba7

24 files changed

+2152
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/config/registries.json
8+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
9+
.netrc

Example/Example.xcodeproj/project.pbxproj

Lines changed: 403 additions & 0 deletions
Large diffs are not rendered by default.

Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Example/Example/AppDelegate.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// AppDelegate.swift
3+
// Example
4+
//
5+
// Created by Ben Alemu on 8/9/22.
6+
//
7+
8+
import UIKit
9+
10+
@main
11+
class AppDelegate: UIResponder, UIApplicationDelegate {
12+
13+
14+
15+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
16+
// Override point for customization after application launch.
17+
return true
18+
}
19+
20+
// MARK: UISceneSession Lifecycle
21+
22+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
23+
// Called when a new scene session is being created.
24+
// Use this method to select a configuration to create the new scene with.
25+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
26+
}
27+
28+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
29+
// Called when the user discards a scene session.
30+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
31+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
32+
}
33+
34+
35+
}
36+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "2x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "83.5x83.5"
82+
},
83+
{
84+
"idiom" : "ios-marketing",
85+
"scale" : "1x",
86+
"size" : "1024x1024"
87+
}
88+
],
89+
"info" : {
90+
"author" : "xcode",
91+
"version" : 1
92+
}
93+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
6+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
7+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<scenes>
11+
<!--View Controller-->
12+
<scene sceneID="tne-QT-ifu">
13+
<objects>
14+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController">
15+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
16+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
17+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
19+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
20+
</view>
21+
</viewController>
22+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
23+
</objects>
24+
<point key="canvasLocation" x="20" y="84"/>
25+
</scene>
26+
</scenes>
27+
<resources>
28+
<systemColor name="systemBackgroundColor">
29+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
30+
</systemColor>
31+
</resources>
32+
</document>

Example/Example/Examples/Person.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Person.swift
3+
// Table
4+
//
5+
// Created by Ben Alemu on 8/8/22.
6+
//
7+
8+
import UIKit
9+
10+
struct Person {
11+
let name: String
12+
let age: Int
13+
let imageSource: String
14+
}
15+
16+
extension Person: TableData {
17+
var title: String {
18+
return name
19+
}
20+
21+
var subtitle: String? {
22+
return "\(age)"
23+
}
24+
25+
var image: UIImage? {
26+
return UIImage(systemName: imageSource) ?? nil
27+
}
28+
29+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// SecondViewController.swift
3+
// Table
4+
//
5+
// Created by Ben Alemu on 8/8/22.
6+
//
7+
8+
import UIKit
9+
10+
class SecondViewController: UIViewController {
11+
12+
var table = Table<Person>()
13+
14+
15+
override func viewDidLoad() {
16+
super.viewDidLoad()
17+
18+
19+
// Build data
20+
let personOne = Person(name: "Paul", age: 24, imageSource: "person.circle.fill")
21+
let personTwo = Person(name: "Zhao", age: 31, imageSource: "shareplay")
22+
let personThree = Person(name: "Maria", age: 28, imageSource: "eye.fill")
23+
let personFour = Person(name: "Vincent", age: 43, imageSource: "brain")
24+
25+
26+
27+
// Form table
28+
self.table = Table(reuseIdentifier: "id",
29+
data: [personOne, personTwo, personThree, personFour] ,
30+
frame: view.frame)
31+
{ indexPath, element, cell in
32+
print("Tapped on element: \(element)")
33+
cell.addCheckmark()
34+
}
35+
36+
37+
// Show TableView
38+
let tableView = table.show()
39+
view.addSubview(tableView)
40+
41+
42+
43+
// Customize appearance
44+
table.setHeader(title: "Hello world!")
45+
table.setCellHeight(height: 50)
46+
table.setAccessory(style: .disclosureIndicator)
47+
48+
table.setTitleFont(font: .boldSystemFont(ofSize: 18))
49+
50+
table.setSubtitleFont(font: .italicSystemFont(ofSize: 14))
51+
table.setSubtitleColor(color: .brown)
52+
53+
table.setImageTint(color: .red)
54+
55+
}
56+
57+
58+
}
59+
60+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// SecondViewController.swift
3+
// Table
4+
//
5+
// Created by Ben Alemu on 8/8/22.
6+
//
7+
8+
import UIKit
9+
10+
class ThirdViewController: UIViewController {
11+
12+
var table = Table<String>(datasets: [
13+
["San Diego", "Hawaii", "Paris", "Buenos Aires"],
14+
["Swim", "Run", "Eat", "Play"],
15+
["Drive", "Fly"]
16+
])
17+
18+
19+
override func viewDidLoad() {
20+
super.viewDidLoad()
21+
22+
23+
// Show TableView
24+
let tableView = table.show()
25+
view.addSubview(tableView)
26+
27+
28+
// Customize appearance
29+
table.setHeader(titles: ["Locations", "Activities", "Travel"])
30+
}
31+
32+
33+
}
34+
35+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// ViewController.swift
3+
// Table
4+
//
5+
// Created by Ben Alemu on 8/6/22.
6+
//
7+
8+
import UIKit
9+
10+
class ViewController: UIViewController {
11+
12+
var table = Table(data: ["Krishna", "Thomas", "Jodeci", "Susan"])
13+
14+
15+
override func viewDidLoad() {
16+
super.viewDidLoad()
17+
18+
// Show TableView
19+
let tableView = table.show()
20+
view.addSubview(tableView)
21+
22+
23+
24+
// Customization
25+
table.setHeader(title: "Family")
26+
table.setAccessory(style: .disclosureIndicator)
27+
}
28+
29+
30+
}
31+

0 commit comments

Comments
 (0)