Skip to content

Commit 543bc97

Browse files
committed
Add UITableView+, UICollctionView+
1 parent 633fa7b commit 543bc97

File tree

7 files changed

+965
-1
lines changed

7 files changed

+965
-1
lines changed

ApplyStyleKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "ApplyStyleKit"
3-
s.version = "0.1.4"
3+
s.version = "0.2.0"
44
s.summary = "You can apply design style comfortably, using Swifty Method Chain."
55
s.description = <<-DESC
66
ApplyStyleKit is a library that applies styles to UIKit using Swifty Method Chain.

ApplyStyleKit.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
51399CFD21CDBEE800574BDB /* UISlider+ApplyStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51399CFC21CDBEE800574BDB /* UISlider+ApplyStyle.swift */; };
1212
51399CFF21CDBEFE00574BDB /* UISlider+ApplyStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51399CFE21CDBEFE00574BDB /* UISlider+ApplyStyleTests.swift */; };
1313
51399D0221CDC4DF00574BDB /* UIImage+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51399D0121CDC4DF00574BDB /* UIImage+.swift */; };
14+
51399D0421CDDC9B00574BDB /* UICollectionView+ApplyStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51399D0321CDDC9B00574BDB /* UICollectionView+ApplyStyle.swift */; };
15+
51399D0621CDDCB100574BDB /* UICollectionView+ApplyStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51399D0521CDDCB100574BDB /* UICollectionView+ApplyStyleTests.swift */; };
16+
51399D0821CDDD8C00574BDB /* UITableView+ApplyStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51399D0721CDDD8C00574BDB /* UITableView+ApplyStyleTests.swift */; };
17+
51399D0A21CDDD9A00574BDB /* UITableView+ApplyStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51399D0921CDDD9A00574BDB /* UITableView+ApplyStyle.swift */; };
1418
5143DAAA21C9148A00D7BCDB /* UIStackView+ApplyStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5143DAA921C9148A00D7BCDB /* UIStackView+ApplyStyle.swift */; };
1519
5143DAAC21C9149B00D7BCDB /* UIStackView+ApplyStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5143DAAB21C9149B00D7BCDB /* UIStackView+ApplyStyleTests.swift */; };
1620
516AB57821C5CBC60026052C /* UIView+ApplyStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 516AB57721C5CBC60026052C /* UIView+ApplyStyleTests.swift */; };
@@ -48,6 +52,10 @@
4852
51399CFC21CDBEE800574BDB /* UISlider+ApplyStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISlider+ApplyStyle.swift"; sourceTree = "<group>"; };
4953
51399CFE21CDBEFE00574BDB /* UISlider+ApplyStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISlider+ApplyStyleTests.swift"; sourceTree = "<group>"; };
5054
51399D0121CDC4DF00574BDB /* UIImage+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+.swift"; sourceTree = "<group>"; };
55+
51399D0321CDDC9B00574BDB /* UICollectionView+ApplyStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionView+ApplyStyle.swift"; sourceTree = "<group>"; };
56+
51399D0521CDDCB100574BDB /* UICollectionView+ApplyStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionView+ApplyStyleTests.swift"; sourceTree = "<group>"; };
57+
51399D0721CDDD8C00574BDB /* UITableView+ApplyStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+ApplyStyleTests.swift"; sourceTree = "<group>"; };
58+
51399D0921CDDD9A00574BDB /* UITableView+ApplyStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+ApplyStyle.swift"; sourceTree = "<group>"; };
5159
5143DAA921C9148A00D7BCDB /* UIStackView+ApplyStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+ApplyStyle.swift"; sourceTree = "<group>"; };
5260
5143DAAB21C9149B00D7BCDB /* UIStackView+ApplyStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+ApplyStyleTests.swift"; sourceTree = "<group>"; };
5361
516AB57721C5CBC60026052C /* UIView+ApplyStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+ApplyStyleTests.swift"; sourceTree = "<group>"; };
@@ -124,6 +132,8 @@
124132
516AB57921C5CF770026052C /* UILabel+ApplyStyleTests.swift */,
125133
5143DAAB21C9149B00D7BCDB /* UIStackView+ApplyStyleTests.swift */,
126134
51399CFE21CDBEFE00574BDB /* UISlider+ApplyStyleTests.swift */,
135+
51399D0521CDDCB100574BDB /* UICollectionView+ApplyStyleTests.swift */,
136+
51399D0721CDDD8C00574BDB /* UITableView+ApplyStyleTests.swift */,
127137
);
128138
path = "UIKit+ApplyStyle";
129139
sourceTree = "<group>";
@@ -191,6 +201,8 @@
191201
5143DAA921C9148A00D7BCDB /* UIStackView+ApplyStyle.swift */,
192202
175D80AC21C762480008DADD /* UIControl+ApplyStyle.swift */,
193203
51399CFC21CDBEE800574BDB /* UISlider+ApplyStyle.swift */,
204+
51399D0321CDDC9B00574BDB /* UICollectionView+ApplyStyle.swift */,
205+
51399D0921CDDD9A00574BDB /* UITableView+ApplyStyle.swift */,
194206
);
195207
path = "UIKit+ApplyStyle";
196208
sourceTree = "<group>";
@@ -362,6 +374,8 @@
362374
51399CFD21CDBEE800574BDB /* UISlider+ApplyStyle.swift in Sources */,
363375
51C715FF21C3FAD700110ABA /* ApplyStyle.swift in Sources */,
364376
51C7160821C3FB3700110ABA /* UILabel+ApplyStyle.swift in Sources */,
377+
51399D0A21CDDD9A00574BDB /* UITableView+ApplyStyle.swift in Sources */,
378+
51399D0421CDDC9B00574BDB /* UICollectionView+ApplyStyle.swift in Sources */,
365379
5143DAAA21C9148A00D7BCDB /* UIStackView+ApplyStyle.swift in Sources */,
366380
51C7160B21C3FB3700110ABA /* UISwitch+ApplyStyle.swift in Sources */,
367381
175D80AD21C762480008DADD /* UIControl+ApplyStyle.swift in Sources */,
@@ -378,6 +392,8 @@
378392
518F391921C3F18B00D6D903 /* ApplyStyleKitTests.swift in Sources */,
379393
51399D0221CDC4DF00574BDB /* UIImage+.swift in Sources */,
380394
516AB57821C5CBC60026052C /* UIView+ApplyStyleTests.swift in Sources */,
395+
51399D0621CDDCB100574BDB /* UICollectionView+ApplyStyleTests.swift in Sources */,
396+
51399D0821CDDD8C00574BDB /* UITableView+ApplyStyleTests.swift in Sources */,
381397
516AB57A21C5CF770026052C /* UILabel+ApplyStyleTests.swift in Sources */,
382398
);
383399
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
//
2+
// UICollectionView+ApplyStyle.swift
3+
// ApplyStyleKit
4+
//
5+
// Created by shindyu on 2018/12/22.
6+
// Copyright © 2018 shindyu. All rights reserved.
7+
//
8+
9+
extension StyleObject where Base: UICollectionView {
10+
@discardableResult public func collectionViewLayout(_ layout: UICollectionViewLayout) -> StyleObject {
11+
base.collectionViewLayout = layout
12+
return self
13+
}
14+
15+
@discardableResult public func delegate(_ delegate: UICollectionViewDelegate?) -> StyleObject {
16+
base.delegate = delegate
17+
return self
18+
}
19+
20+
@discardableResult public func dataSource(_ dataSource: UICollectionViewDataSource?) -> StyleObject {
21+
base.dataSource = dataSource
22+
return self
23+
}
24+
25+
@available(iOS 10.0, *)
26+
@discardableResult public func prefetchDataSource(_ dataSource: UICollectionViewDataSourcePrefetching?) -> StyleObject {
27+
base.prefetchDataSource = dataSource
28+
return self
29+
}
30+
31+
@available(iOS 10.0, *)
32+
@discardableResult public func isPrefetchingEnabled(_ enabled: Bool) -> StyleObject {
33+
base.isPrefetchingEnabled = enabled
34+
return self
35+
}
36+
37+
@available(iOS 11.0, *)
38+
@discardableResult public func dragDelegate(_ delegate: UICollectionViewDragDelegate?) -> StyleObject {
39+
base.dragDelegate = delegate
40+
return self
41+
}
42+
43+
@available(iOS 11.0, *)
44+
@discardableResult public func dropDelegate(_ delegate: UICollectionViewDropDelegate?) -> StyleObject {
45+
base.dropDelegate = delegate
46+
return self
47+
}
48+
49+
@available(iOS 11.0, *)
50+
@discardableResult public func dragInteractionEnabled(_ enabled: Bool) -> StyleObject {
51+
base.dragInteractionEnabled = enabled
52+
return self
53+
}
54+
55+
@available(iOS 11.0, *)
56+
@discardableResult public func reorderingCadence(_ cadence: UICollectionView.ReorderingCadence) -> StyleObject {
57+
base.reorderingCadence = cadence
58+
return self
59+
}
60+
61+
@discardableResult public func backgroundView(_ view: UIView) -> StyleObject {
62+
base.backgroundView = view
63+
return self
64+
}
65+
66+
@discardableResult public func register(_ cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String) -> StyleObject {
67+
base.register(cellClass, forCellWithReuseIdentifier: identifier)
68+
return self
69+
}
70+
71+
@discardableResult public func register(_ nib: UINib?, forCellWithReuseIdentifier identifier: String) -> StyleObject {
72+
base.register(nib, forCellWithReuseIdentifier: identifier)
73+
return self
74+
}
75+
76+
@discardableResult public func register(_ viewClass: AnyClass?, forSupplementaryViewOfKind elementKind: String, withReuseIdentifier identifier: String) -> StyleObject {
77+
base.register(viewClass, forSupplementaryViewOfKind: elementKind, withReuseIdentifier: identifier)
78+
return self
79+
}
80+
81+
@discardableResult public func register(_ nib: UINib?, forSupplementaryViewOfKind kind: String, withReuseIdentifier identifier: String) -> StyleObject {
82+
base.register(nib, forSupplementaryViewOfKind: kind, withReuseIdentifier: identifier)
83+
return self
84+
}
85+
86+
@discardableResult public func allowsSelection(_ enabled: Bool) -> StyleObject {
87+
base.allowsSelection = enabled
88+
return self
89+
}
90+
91+
@discardableResult public func allowsMultipleSelection(_ enabled: Bool) -> StyleObject {
92+
base.allowsMultipleSelection = enabled
93+
return self
94+
}
95+
96+
@discardableResult public func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionView.ScrollPosition) -> StyleObject {
97+
base.selectItem(at: indexPath, animated: animated, scrollPosition: scrollPosition)
98+
return self
99+
}
100+
101+
@discardableResult public func deselectItem(at indexPath: IndexPath, animated: Bool) -> StyleObject {
102+
base.deselectItem(at: indexPath, animated: animated)
103+
return self
104+
}
105+
106+
@discardableResult public func reloadData() -> StyleObject {
107+
base.reloadData()
108+
return self
109+
}
110+
111+
@discardableResult public func setCollectionViewLayout(_ layout: UICollectionViewLayout, animated: Bool) -> StyleObject {
112+
base.setCollectionViewLayout(layout, animated: animated)
113+
return self
114+
}
115+
116+
@discardableResult public func setCollectionViewLayout(_ layout: UICollectionViewLayout, animated: Bool, completion: ((Bool) -> Void)? = nil) -> StyleObject {
117+
base.setCollectionViewLayout(layout, animated: animated, completion: completion)
118+
return self
119+
}
120+
121+
@discardableResult public func finishInteractiveTransition() -> StyleObject {
122+
base.finishInteractiveTransition()
123+
return self
124+
}
125+
126+
@discardableResult public func cancelInteractiveTransition() -> StyleObject {
127+
base.cancelInteractiveTransition()
128+
return self
129+
}
130+
131+
@discardableResult public func scrollToItem(at indexPath: IndexPath, at scrollPosition: UICollectionView.ScrollPosition, animated: Bool) -> StyleObject {
132+
base.scrollToItem(at: indexPath, at: scrollPosition, animated: animated)
133+
return self
134+
}
135+
136+
@discardableResult public func insertSections(_ sections: IndexSet) -> StyleObject {
137+
base.insertSections(sections)
138+
return self
139+
}
140+
141+
@discardableResult public func deleteSections(_ sections: IndexSet) -> StyleObject {
142+
base.deleteSections(sections)
143+
return self
144+
}
145+
146+
@discardableResult public func reloadSections(_ sections: IndexSet) -> StyleObject {
147+
base.reloadSections(sections)
148+
return self
149+
}
150+
151+
@discardableResult public func moveSection(_ section: Int, toSection newSection: Int) -> StyleObject {
152+
base.moveSection(section, toSection: newSection)
153+
return self
154+
}
155+
156+
@discardableResult public func insertItems(at indexPaths: [IndexPath]) -> StyleObject {
157+
base.insertItems(at: indexPaths)
158+
return self
159+
}
160+
161+
@discardableResult public func deleteItems(at indexPaths: [IndexPath]) -> StyleObject {
162+
base.deleteItems(at: indexPaths)
163+
return self
164+
}
165+
166+
@discardableResult public func reloadItems(at indexPaths: [IndexPath]) -> StyleObject {
167+
base.reloadItems(at: indexPaths)
168+
return self
169+
}
170+
171+
@discardableResult public func moveItem(at indexPath: IndexPath, to newIndexPath: IndexPath) -> StyleObject {
172+
base.moveItem(at: indexPath, to: newIndexPath)
173+
return self
174+
}
175+
176+
@discardableResult public func performBatchUpdates(_ updates: (() -> Void)?, completion: ((Bool) -> Void)? = nil) -> StyleObject {
177+
base.performBatchUpdates(updates, completion: completion)
178+
return self
179+
}
180+
181+
@discardableResult public func updateInteractiveMovementTargetPosition(_ targetPosition: CGPoint) -> StyleObject {
182+
base.updateInteractiveMovementTargetPosition(targetPosition)
183+
return self
184+
}
185+
186+
@discardableResult public func endInteractiveMovement() -> StyleObject {
187+
base.endInteractiveMovement()
188+
return self
189+
}
190+
191+
@discardableResult public func cancelInteractiveMovement() -> StyleObject {
192+
base.cancelInteractiveMovement()
193+
return self
194+
}
195+
196+
@discardableResult public func remembersLastFocusedIndexPath(_ enabled: Bool) -> StyleObject {
197+
base.remembersLastFocusedIndexPath = enabled
198+
return self
199+
}
200+
}

0 commit comments

Comments
 (0)