Skip to content

Commit 0d268f3

Browse files
authored
Merge pull request #8 from giulio92/develop
2 parents 388662e + f130551 commit 0d268f3

6 files changed

Lines changed: 66 additions & 37 deletions

File tree

GLTableCollectionView/GLCollectionTableViewCell.swift renamed to Classes/GLCollectionTableViewCell.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
import UIKit
3131

3232
class GLIndexedCollectionViewFlowLayout: UICollectionViewFlowLayout {
33-
var customPagination: Bool?
33+
var paginatedScroll: Bool?
3434

3535
override func awakeFromNib() {
3636
super.awakeFromNib()
3737
}
3838

3939
override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
40-
guard customPagination == true else {
40+
guard paginatedScroll == true else {
4141
return CGPoint(x: proposedContentOffset.x, y: 0)
4242
}
4343

@@ -129,7 +129,7 @@ class GLCollectionTableViewCell: UITableViewCell {
129129
Default value is `nil`, since this `Bool` is `Optional`.
130130

131131
*/
132-
var collectionViewScrollPagination: Bool?
132+
var collectionViewPaginatedScroll: Bool?
133133

134134
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
135135
super.init(style: style, reuseIdentifier: reuseIdentifier)
@@ -162,9 +162,9 @@ class GLCollectionTableViewCell: UITableViewCell {
162162
override func layoutSubviews() {
163163
super.layoutSubviews()
164164

165-
collectionFlowLayout.customPagination = collectionViewScrollPagination
165+
collectionFlowLayout.paginatedScroll = collectionViewPaginatedScroll
166166

167-
if collectionViewScrollPagination == true {
167+
if collectionViewPaginatedScroll == true {
168168
collectionView.isPagingEnabled = false
169169
}
170170

@@ -190,7 +190,7 @@ class GLCollectionTableViewCell: UITableViewCell {
190190
method of GLTableCollectionViewController so the UITableView will re-assign
191191
it automatically following the regular UITableViewCells reuse logic.
192192

193-
This method will also check if the re-assignment is needed or not.
193+
This method will also check if the re-assignment are needed or not.
194194

195195
- Parameter dataSource: The `dataSource` class for the
196196
GLIndexedCollectionView in the GLCollectionTableViewCell, it will be
File renamed without changes.
File renamed without changes.

GLTableCollectionView/GLTableCollectionViewController.swift renamed to Classes/GLTableCollectionViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa
114114

115115
// Configure the cell...
116116
cell!.selectionStyle = .none
117-
cell!.collectionViewScrollPagination = paginationEnabled
117+
cell!.collectionViewPaginatedScroll = paginationEnabled
118118
}
119119

120120
return cell!
@@ -167,14 +167,14 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa
167167

168168
// MARK: <UICollectionViewDelegate Flow Layout>
169169

170-
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
171-
return CGSize(width: 65, height: 65)
172-
}
173-
174170
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
175171
return UIEdgeInsetsMake(0, 10, 0, 10)
176172
}
177173

174+
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
175+
return CGSize(width: 65, height: 65)
176+
}
177+
178178
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
179179
return 10
180180
}

GLTableCollectionView.xcodeproj/project.pbxproj

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
745E87FE1DE74BC800788EC7 /* GLIndexedCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 745E87FC1DE74BC800788EC7 /* GLIndexedCollectionViewCell.swift */; };
11-
745E87FF1DE74BC800788EC7 /* GLIndexedCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 745E87FD1DE74BC800788EC7 /* GLIndexedCollectionViewCell.xib */; };
10+
742CE82E1E099064000ACFB6 /* GLTableCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 742CE82D1E099064000ACFB6 /* GLTableCollectionViewController.swift */; };
11+
742CE8301E099070000ACFB6 /* GLCollectionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 742CE82F1E099070000ACFB6 /* GLCollectionTableViewCell.swift */; };
12+
742CE8321E099077000ACFB6 /* GLIndexedCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 742CE8311E099077000ACFB6 /* GLIndexedCollectionViewCell.swift */; };
13+
742CE8341E09907D000ACFB6 /* GLIndexedCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 742CE8331E09907D000ACFB6 /* GLIndexedCollectionViewCell.xib */; };
1214
747CF8FD1DE6EB010051A5FF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747CF8FC1DE6EB010051A5FF /* AppDelegate.swift */; };
1315
747CF9021DE6EB010051A5FF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 747CF9001DE6EB010051A5FF /* Main.storyboard */; };
1416
747CF9041DE6EB010051A5FF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 747CF9031DE6EB010051A5FF /* Assets.xcassets */; };
1517
747CF9071DE6EB010051A5FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 747CF9051DE6EB010051A5FF /* LaunchScreen.storyboard */; };
1618
747CF9121DE6EB010051A5FF /* GLTableCollectionViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747CF9111DE6EB010051A5FF /* GLTableCollectionViewTests.swift */; };
17-
747CF91D1DE6EBFF0051A5FF /* GLTableCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747CF91C1DE6EBFF0051A5FF /* GLTableCollectionViewController.swift */; };
18-
747CF91F1DE6ECB60051A5FF /* GLCollectionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747CF91E1DE6ECB60051A5FF /* GLCollectionTableViewCell.swift */; };
1919
/* End PBXBuildFile section */
2020

2121
/* Begin PBXContainerItemProxy section */
@@ -29,8 +29,10 @@
2929
/* End PBXContainerItemProxy section */
3030

3131
/* Begin PBXFileReference section */
32-
745E87FC1DE74BC800788EC7 /* GLIndexedCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GLIndexedCollectionViewCell.swift; sourceTree = "<group>"; };
33-
745E87FD1DE74BC800788EC7 /* GLIndexedCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GLIndexedCollectionViewCell.xib; sourceTree = "<group>"; };
32+
742CE82D1E099064000ACFB6 /* GLTableCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GLTableCollectionViewController.swift; path = Classes/GLTableCollectionViewController.swift; sourceTree = SOURCE_ROOT; };
33+
742CE82F1E099070000ACFB6 /* GLCollectionTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GLCollectionTableViewCell.swift; path = Classes/GLCollectionTableViewCell.swift; sourceTree = SOURCE_ROOT; };
34+
742CE8311E099077000ACFB6 /* GLIndexedCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GLIndexedCollectionViewCell.swift; path = Classes/GLIndexedCollectionViewCell.swift; sourceTree = SOURCE_ROOT; };
35+
742CE8331E09907D000ACFB6 /* GLIndexedCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = GLIndexedCollectionViewCell.xib; path = Classes/GLIndexedCollectionViewCell.xib; sourceTree = SOURCE_ROOT; };
3436
747CF8F91DE6EB010051A5FF /* GLTableCollectionView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GLTableCollectionView.app; sourceTree = BUILT_PRODUCTS_DIR; };
3537
747CF8FC1DE6EB010051A5FF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3638
747CF9011DE6EB010051A5FF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@@ -40,8 +42,6 @@
4042
747CF90D1DE6EB010051A5FF /* GLTableCollectionViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GLTableCollectionViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4143
747CF9111DE6EB010051A5FF /* GLTableCollectionViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GLTableCollectionViewTests.swift; sourceTree = "<group>"; };
4244
747CF9131DE6EB010051A5FF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
43-
747CF91C1DE6EBFF0051A5FF /* GLTableCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GLTableCollectionViewController.swift; sourceTree = "<group>"; };
44-
747CF91E1DE6ECB60051A5FF /* GLCollectionTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GLCollectionTableViewCell.swift; sourceTree = "<group>"; };
4545
/* End PBXFileReference section */
4646

4747
/* Begin PBXFrameworksBuildPhase section */
@@ -84,13 +84,13 @@
8484
isa = PBXGroup;
8585
children = (
8686
747CF8FC1DE6EB010051A5FF /* AppDelegate.swift */,
87-
747CF91C1DE6EBFF0051A5FF /* GLTableCollectionViewController.swift */,
88-
747CF91E1DE6ECB60051A5FF /* GLCollectionTableViewCell.swift */,
89-
745E87FC1DE74BC800788EC7 /* GLIndexedCollectionViewCell.swift */,
90-
745E87FD1DE74BC800788EC7 /* GLIndexedCollectionViewCell.xib */,
87+
742CE82D1E099064000ACFB6 /* GLTableCollectionViewController.swift */,
88+
742CE82F1E099070000ACFB6 /* GLCollectionTableViewCell.swift */,
89+
742CE8311E099077000ACFB6 /* GLIndexedCollectionViewCell.swift */,
90+
742CE8331E09907D000ACFB6 /* GLIndexedCollectionViewCell.xib */,
9191
747CF9001DE6EB010051A5FF /* Main.storyboard */,
92-
747CF9031DE6EB010051A5FF /* Assets.xcassets */,
9392
747CF9051DE6EB010051A5FF /* LaunchScreen.storyboard */,
93+
747CF9031DE6EB010051A5FF /* Assets.xcassets */,
9494
747CF9081DE6EB010051A5FF /* Info.plist */,
9595
);
9696
path = GLTableCollectionView;
@@ -190,8 +190,8 @@
190190
files = (
191191
747CF9071DE6EB010051A5FF /* LaunchScreen.storyboard in Resources */,
192192
747CF9041DE6EB010051A5FF /* Assets.xcassets in Resources */,
193+
742CE8341E09907D000ACFB6 /* GLIndexedCollectionViewCell.xib in Resources */,
193194
747CF9021DE6EB010051A5FF /* Main.storyboard in Resources */,
194-
745E87FF1DE74BC800788EC7 /* GLIndexedCollectionViewCell.xib in Resources */,
195195
);
196196
runOnlyForDeploymentPostprocessing = 0;
197197
};
@@ -209,10 +209,10 @@
209209
isa = PBXSourcesBuildPhase;
210210
buildActionMask = 2147483647;
211211
files = (
212-
747CF91D1DE6EBFF0051A5FF /* GLTableCollectionViewController.swift in Sources */,
213-
745E87FE1DE74BC800788EC7 /* GLIndexedCollectionViewCell.swift in Sources */,
214-
747CF91F1DE6ECB60051A5FF /* GLCollectionTableViewCell.swift in Sources */,
212+
742CE8301E099070000ACFB6 /* GLCollectionTableViewCell.swift in Sources */,
213+
742CE82E1E099064000ACFB6 /* GLTableCollectionViewController.swift in Sources */,
215214
747CF8FD1DE6EB010051A5FF /* AppDelegate.swift in Sources */,
215+
742CE8321E099077000ACFB6 /* GLIndexedCollectionViewCell.swift in Sources */,
216216
);
217217
runOnlyForDeploymentPostprocessing = 0;
218218
};

GLTableCollectionViewTests/GLTableCollectionViewTests.swift

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,28 @@
33
// GLTableCollectionViewTests
44
//
55
// Created by Giulio Lombardo on 24/11/16.
6-
// Copyright © 2016 Giulio Lombardo. All rights reserved.
6+
//
7+
// MIT License
8+
//
9+
// Copyright (c) 2016 Giulio Lombardo
10+
//
11+
// Permission is hereby granted, free of charge, to any person obtaining a copy
12+
// of this software and associated documentation files (the "Software"), to deal
13+
// in the Software without restriction, including without limitation the rights
14+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
// copies of the Software, and to permit persons to whom the Software is
16+
// furnished to do so, subject to the following conditions:
17+
//
18+
// The above copyright notice and this permission notice shall be included in all
19+
// copies or substantial portions of the Software.
20+
//
21+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27+
// SOFTWARE.
728
//
829

930
import XCTest
@@ -66,6 +87,8 @@ class GLTableCollectionViewTests: XCTestCase {
6687
}
6788

6889
func testTableViewCellsIdentifier() {
90+
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")
91+
6992
for tableViewCell in visibleCells as! [GLCollectionTableViewCell] {
7093
XCTAssertTrue(Int(tableViewCell.reuseIdentifier!.components(separatedBy: "#").last!)! >= 0, "The GLCollectionTableViewCell cellIdentifier must end with a positive integer")
7194
}
@@ -74,16 +97,20 @@ class GLTableCollectionViewTests: XCTestCase {
7497
// MARK: <GLCollectionTableViewCell>
7598

7699
func testDataSourceAndDelegateCollectionCells() {
77-
for tableViewCell in visibleCells as! [GLCollectionTableViewCell] {
78-
XCTAssertNotNil(tableViewCell.collectionView.dataSource, "GLCollectionTableViewCell dataSource is nil")
79-
XCTAssertNotNil(tableViewCell.collectionView.delegate, "GLCollectionTableViewCell delegate is nil")
100+
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")
101+
102+
for collectionTableCell in visibleCells as! [GLCollectionTableViewCell] {
103+
XCTAssertNotNil(collectionTableCell.collectionView.dataSource, "GLCollectionTableViewCell dataSource is nil")
104+
XCTAssertNotNil(collectionTableCell.collectionView.delegate, "GLCollectionTableViewCell delegate is nil")
80105
}
81106
}
82107

83108
func testCollectionNativePaginationFlag() {
84-
for tableViewCell in visibleCells as! [GLCollectionTableViewCell] {
85-
if tableViewCell.collectionViewScrollPagination == true {
86-
XCTAssertFalse(tableViewCell.collectionView.isPagingEnabled, "Custom scrolling pagination and native UICollectionView pagination can't be enabled at the same time")
109+
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")
110+
111+
for collectionTableCell in visibleCells as! [GLCollectionTableViewCell] {
112+
if collectionTableCell.collectionViewPaginatedScroll == true {
113+
XCTAssertFalse(collectionTableCell.collectionView.isPagingEnabled, "Custom scrolling pagination and native UICollectionView pagination can't be enabled at the same time")
87114
}
88115
}
89116
}
@@ -93,8 +120,10 @@ class GLTableCollectionViewTests: XCTestCase {
93120
func testOpaqueFlag() {
94121
XCTAssertTrue(tableCollectionView.tableView.isOpaque, "The UITableView should be opaque for increased performances")
95122

96-
for cell in visibleCells as! [GLCollectionTableViewCell] {
97-
XCTAssertTrue(cell.collectionView.isOpaque, "The UICollectionView should be opaque for increased performances")
123+
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")
124+
125+
for collectionTableCell in visibleCells as! [GLCollectionTableViewCell] {
126+
XCTAssertTrue(collectionTableCell.collectionView.isOpaque, "The UICollectionView should be opaque for increased performances")
98127
}
99128
}
100129

0 commit comments

Comments
 (0)