@@ -18,9 +18,6 @@ https://img.shields.io/cocoapods/p/SwiftDataTables.svg
1818<a href =" https://swift.org/package-manager " >
1919 <img src="https://img.shields.io/badge/SPM-compatible-brightgreen.svg?style=flat" alt="SPM Compatible" />
2020 </a>
21- <a href =" https://cocoapods.org/pods/SwiftDataTables " >
22- <img src="https://img.shields.io/badge/Cocoapods-compatible-4BC51D.svg?style=flat" />
23- </a>
2421 <a href =" https://en.wikipedia.org/wiki/MIT_License " >
2522 <img src="https://img.shields.io/badge/License-MIT-brightgreen.svg?style=flat" />
2623 </a >
@@ -61,30 +58,83 @@ https://img.shields.io/cocoapods/p/SwiftDataTables.svg
6158<!-- <img src="http://g.recordit.co/Mh9PYXB9T4.gif" width="50%"> -->
6259<img src =" /Example/SwiftDataTables-Preview.gif " width =" 50% " >
6360
64- ## Install
61+ ## Quick Start
62+
63+ ``` swift
64+ import SwiftDataTables
65+
66+ // Simple array-based table
67+ let data = [
68+ [" Alice" , " Engineer" , " London" ],
69+ [" Bob" , " Designer" , " Paris" ],
70+ [" Carol" , " Manager" , " Berlin" ]
71+ ]
72+ let dataTable = SwiftDataTable (
73+ data : data,
74+ headerTitles : [" Name" , " Role" , " City" ]
75+ )
76+ view.addSubview (dataTable)
77+ ```
78+
79+ Or with type-safe columns:
80+
81+ ``` swift
82+ struct Employee : Identifiable {
83+ let id: String
84+ let name: String
85+ let role: String
86+ let salary: Int
87+ }
88+
89+ let columns: [DataTableColumn<Employee>] = [
90+ .init (" Name" , \.name ),
91+ .init (" Role" , \.role ),
92+ .init (" Salary" ) { .string (" £\( $0 .salary ) " ) }
93+ ]
6594
66- ### [ Carthage] ( https://github.com/Carthage/Carthage )
95+ let dataTable = SwiftDataTable (data : employees, columns : columns)
96+ ```
97+
98+ Update data with animated diffing:
99+
100+ ``` swift
101+ // Load initial data
102+ var employees: [Employee] = []
103+ dataTable.setData (employees)
67104
68- - Add the following to your Cartfile: ` github "pavankataria/SwiftDataTables" `
69- - Then run ` carthage update `
70- - Follow the current instructions in [ Carthage's README] [ carthage-installation ]
71- for up to date installation instructions.
105+ // Fetch and update
106+ employees = await api.fetchEmployees ()
107+ dataTable.setData (employees, animatingDifferences : true )
72108
73- [ carthage-installation ] : https://github.com/Carthage/Carthage#adding-frameworks-to-an-application
109+ // Append new items
110+ employees.append (newEmployee)
111+ dataTable.setData (employees, animatingDifferences : true )
112+ ```
74113
75- ### [ CocoaPods ] ( http://cocoapods.org )
114+ ## Install
76115
77- - Add the following to your [ Podfile] ( http://guides.cocoapods.org/using/the-podfile.html ) : ` pod 'SwiftDataTables' `
78- - You will also need to make sure you're opting into using frameworks: ` use_frameworks! `
79- - Then run ` pod install ` .
116+ ### Swift Package Manager
117+
118+ Add SwiftDataTables to your project via Xcode:
119+ 1 . File → Add Package Dependencies...
120+ 2 . Enter the repository URL: ` https://github.com/pavankataria/SwiftDataTables `
121+ 3 . Select your version rules and add to your target
122+
123+ Or add it to your ` Package.swift ` :
124+
125+ ``` swift
126+ dependencies: [
127+ .package (url : " https://github.com/pavankataria/SwiftDataTables" , from : " 0.9.0" )
128+ ]
129+ ```
80130
81131## Demo Project Included
82132
83133To run the example project do the following:
841341 . Download or clone the repo (` git clone https://github.com/pavankataria/SwiftDataTables ` )
85- 2 . Change directory into the ` DemoSwiftDataTables/Example ` folder ( ` cd SwiftDataTables/Example ` )
86- 4 . With Xcode 9 installed, as normal, open the ` SwiftDataTables.xcodeproj ` project
87- 5 . Build and Run.
135+ 2 . Open the ` SwiftDataTables.xcodeproj ` project in Xcode
136+ 3 . Select the ` DemoSwiftDataTables ` scheme
137+ 4 . Build and Run
88138
89139If you have any questions or wish to make any suggestions, please open an issue with the appropriate label, and I'll get back to you right away. Thank you
90140
0 commit comments