Skip to content

Commit b1e26e1

Browse files
authored
Merge pull request #5 from giulio92/develop
2 parents 869b300 + c891a58 commit b1e26e1

9 files changed

Lines changed: 71 additions & 32 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ env:
66
- PROJECT=GLTableCollectionView.xcodeproj
77
- SCHEME=GLTableCollectionView
88
- SDK=iphonesimulator10.1
9-
- DESTINATION="OS=10.1,name=iPhone 5"
9+
- DESTINATION="platform=iOS Simulator,OS=latest,name=iPhone 5"
1010

1111
before_install:
1212
- brew update

GLTableCollectionView.xcodeproj/project.pbxproj

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,28 @@
355355
isa = XCBuildConfiguration;
356356
buildSettings = {
357357
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
358+
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
359+
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
360+
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
361+
CLANG_ENABLE_OBJC_WEAK = YES;
362+
CLANG_WARN_ASSIGN_ENUM = YES;
363+
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
364+
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
365+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
366+
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
367+
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
358368
CODE_SIGN_IDENTITY = "";
359369
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
370+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
360371
DEVELOPMENT_TEAM = "";
372+
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
373+
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
374+
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
375+
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
376+
GCC_WARN_SIGN_COMPARE = YES;
377+
GCC_WARN_UNKNOWN_PRAGMAS = YES;
378+
GCC_WARN_UNUSED_LABEL = YES;
379+
GCC_WARN_UNUSED_PARAMETER = YES;
361380
INFOPLIST_FILE = GLTableCollectionView/Info.plist;
362381
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
363382
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -373,9 +392,27 @@
373392
isa = XCBuildConfiguration;
374393
buildSettings = {
375394
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
395+
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
396+
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
397+
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
398+
CLANG_ENABLE_OBJC_WEAK = YES;
399+
CLANG_WARN_ASSIGN_ENUM = YES;
400+
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
401+
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
402+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
403+
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
404+
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
376405
CODE_SIGN_IDENTITY = "";
377406
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
378407
DEVELOPMENT_TEAM = "";
408+
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
409+
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
410+
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
411+
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
412+
GCC_WARN_SIGN_COMPARE = YES;
413+
GCC_WARN_UNKNOWN_PRAGMAS = YES;
414+
GCC_WARN_UNUSED_LABEL = YES;
415+
GCC_WARN_UNUSED_PARAMETER = YES;
379416
INFOPLIST_FILE = GLTableCollectionView/Info.plist;
380417
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
381418
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

GLTableCollectionView/GLCollectionTableViewCell.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,31 @@ class GLIndexedCollectionViewFlowLayout: UICollectionViewFlowLayout {
2121
}
2222

2323
// To make paginated scrolling work fine this CGFloat below must be
24-
// equal to the value set in the insetForSectionAt method
24+
// equal to the value set in the insetForSectionAt method of
2525
// UICollectionView's UICollectionViewDelegate Flow Layout.
2626
let collectionViewInsets: CGFloat = 10.0
2727

2828
// Since UICollectionViewFlowLayout proposedContentOffset coordinates
2929
// won't take count of any UICollectionView UIEdgeInsets values we need
30-
// to fix it by adding collectionViewInsets to .x coordinate.
30+
// to fix it by adding collectionViewInsets to the .x coordinate.
3131
//
32-
// Note: This will cover horizonal scrolling and pagination, if you need
33-
// vertical pagination replace the .x coordinate with .y and update
32+
// Note: This will only cover horizonal scrolling and pagination, if you
33+
// need vertical pagination replace the .x coordinate with .y and update
3434
// collectionViewInsets value with the approriate one.
3535
let proposedXCoordWithInsets = proposedContentOffset.x + collectionViewInsets
3636

37-
// We start by creating a variable and we assign a very high CGFloat to
38-
// it, a big number here is needed to cover very large
39-
// UICollectionViewContentSize cases.
37+
// We now create a variable and we assign a very high CGFloat to it (a
38+
// big number here is needed to cover very large
39+
// UICollectionViewContentSize cases). This var will hold the needed
40+
// horizontal adjustment to make the UICollectionView paginate scroll.
4041
var offsetCorrection: CGFloat = .greatestFiniteMagnitude
4142

4243
// Now we loop through all the different layout attributes of the
4344
// UICollectionViewCells contained between the .x value of the
44-
// proposedContentOffset and collectionView's width looking for the cell
45-
// which needs the least offsetCorrection value, it will mean that it's
46-
// the first cell on the left of the screen which will give pagination.
45+
// proposedContentOffset and collectionView's width, looking for the
46+
// cell which needs the least offsetCorrection value: it will mean that
47+
// it's the first cell on the left of the screen which will give
48+
// pagination.
4749
for layoutAttributes in super.layoutAttributesForElements(in: CGRect(x: proposedContentOffset.x, y: 0, width: collectionView!.bounds.width, height: collectionView!.bounds.height))! {
4850
// Since layoutAttributesForElements may contain all sort of layout
4951
// attributes we need to check if it belongs to a
@@ -169,11 +171,11 @@ class GLCollectionTableViewCell: UITableViewCell {
169171

170172
- Parameter dataSource: The `dataSource` class for the
171173
GLIndexedCollectionView in the GLCollectionTableViewCell, it will be
172-
responsible for the usual UICollectionView `dataSource` methods.
174+
responsible for the UICollectionView's `dataSource` methods.
173175

174176
- Parameter delegate: The `delegate class` for the GLIndexedCollectionView
175-
in the GLCollectionTableViewCell, it will be responsible for the usual
176-
UICollectionView delegation methods.
177+
in the GLCollectionTableViewCell, it will be responsible for the
178+
UICollectionView's delegation methods.
177179

178180
- Parameter indexPath: The inner-`indexPath` of the GLIndexedCollectionView,
179181
it's recommended to pass the same `indexPath` of the UITableViewCell to the

GLTableCollectionView/GLTableCollectionViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa
1212
// This string constant will be the cellIdentifier for the UITableViewCells
1313
// holding the UICollectionView, it's important to append "_section#" to it
1414
// so we can understand which cell is the one we are looking for in the
15-
// debugger. Look in the UITableView's data source cellForRowAt method for
16-
// more explaination about how we handle the cell reuse.
15+
// debugger. Look in UITableView's data source cellForRowAt method for more
16+
// explainations about the UITableViewCell reuse handling.
1717
let tableCellID: String = "tableViewCellID_section_#"
1818
let collectionCellID: String = "collectionViewCellID"
1919

@@ -23,7 +23,7 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa
2323

2424
var colorsDict: [Int: [UIColor]] = [:]
2525

26-
// Set true to enable UICollectionViews scroll pagination
26+
/// Set true to enable UICollectionViews scroll pagination
2727
var paginationEnabled: Bool = true
2828

2929
override func viewDidLoad() {
@@ -72,18 +72,18 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa
7272
}
7373

7474
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
75-
// As you can see below instead of having a single cellIdentifier for
76-
// each type of UITableViewCells, as you would do with normally, we will
77-
// have multiple IDs each related to a indexPath section. Doing so the
78-
// UITableViewCells will still be recycled but it will be done only with
79-
// dequeueReusableCell of a given section.
75+
// Instead of having a single cellIdentifier for each type of
76+
// UITableViewCells, like in a regular implementation, we have multiple
77+
// cellIDs, each related to a indexPath section. By Doing so the
78+
// UITableViewCells will still be recycled but only with
79+
// dequeueReusableCell of that section.
8080
//
8181
// For example the cellIdentifier for section 4 cells will be:
8282
// "tableViewCellID_section_#3"
8383
// dequeueReusableCell will only reuse previous UITableViewCells with
8484
// the same cellIdentifier instead of using any UITableViewCell as a
8585
// regular UITableView would do, this is necessary because every cell
86-
// will have a different UICollectionView and UICollectionViewCells in
86+
// will have a different UICollectionView with UICollectionViewCells in
8787
// it and UITableView reuse won't work as expected giving back wrong
8888
// cells.
8989
var cell: GLCollectionTableViewCell? = tableView.dequeueReusableCell(withIdentifier: tableCellID + indexPath.section.description) as? GLCollectionTableViewCell
427 Bytes
Binary file not shown.

GitHub Page/Images/Source/Logo.pxm

2.3 KB
Binary file not shown.

GitHub Page/Images/diagram.png

55.8 KB
Loading

GitHub Page/Images/logo.png

486 Bytes
Loading

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515
[![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg)](https://raw.githubusercontent.com/giulio92/GLTableCollectionView/master/LICENSE.txt)
1616

1717
## What it is
18-
GLTableCollectionView is a ready-to-use ```UITableViewController``` with a ```UICollectionView``` for each ```UITableViewCell```, something like Netflix, Airbnb or the Apple's App Store are doing in their iOS apps. GLTableCollectionView is completely customizable in both his UITableView and UICollectionView parts since it has been made on the same Data Source and Delegate methods with no complicated additions.
18+
GLTableCollectionView is a ready to use `UITableViewController` with a `UICollectionView` for each `UITableViewCell`, something like Netflix, Airbnb or the Apple's App Store are doing in their iOS apps. GLTableCollectionView is completely customizable in both his UITableView and UICollectionView parts since it has been made on the same Data Source and Delegate methods with no complicated additions.
1919

2020
||**GLTableCollectionView**|
2121
|:---:|---|
22-
|🔄|Uses the **same** ```UITableView``` reusable cells logic provided from Apple's implementation|
23-
|♻️|```UICollectionView``` cell recycle|
24-
|🆒|Both ```UITableView``` & ```UICollectionView``` can have their own sections and/or headers|
25-
|🖼|Customization of ```UICollectionViewCell```s using the same ```UICollectionViewDelegate Flow Layout``` you already know|
26-
||Previous ```UICollectionView``` **.contentOffset** value restoration after scroll|
22+
|🔄|Uses the **same** `UITableView` reusable cells logic provided from Apple's implementation|
23+
|♻️|`UICollectionView` cell recycle|
24+
|🆒|Both `UITableView` & `UICollectionView` can have their own sections and/or headers|
25+
|🎨|Customization of `UICollectionViewCell`s using the same `UICollectionViewDelegate Flow Layout` you already know|
26+
||Previous `UICollectionView` **.contentOffset** value restoration after scroll|
2727
|↔️|UICollectionView cell-size-based scroll pagination, see below for instructions|
2828
|📐|Storyboard and Auto Layout compatibility|
2929
|💎|Clean architecture|
3030
|🔧|Unit Tests|
3131

3232
## Enable/disable scroll pagination
33-
Set ```paginationEnabled``` variable ```true``` in GLTableCollectionViewController class, ```false``` to disable
33+
Set `paginationEnabled` variable `true` in GLTableCollectionViewController class, `false` to disable. Default value is `true`.
3434
```
35-
// Set true to enable UICollectionViews scroll pagination
35+
/// Set true to enable UICollectionViews scroll pagination
3636
var paginationEnabled: Bool = true
3737
```
3838

@@ -52,4 +52,4 @@ var paginationEnabled: Bool = true
5252
- iOS 8.0+
5353

5454
## Note
55-
GLTableCollectionView is written using Swift 3.0 so it would only support iOS 8.0+ due to Swift 3 language compatibility, if you use Swift 2.0 in your project or you need iOS 7.0+ compatibility GLTableCollectionView will work too, but you **must** convert ```UITableView``` and ```UICollectionView``` Data Source and Delegate methods signatures before building your code or Xcode won't compile.
55+
GLTableCollectionView is written using Swift 3.0 so it would only support iOS 8.0+ due to Swift 3 language compatibility, if you use Swift 2.0 in your project or you need iOS 7.0+ compatibility GLTableCollectionView will work too, but you **must** convert `UITableView` and `UICollectionView` Data Source and Delegate methods signatures before building your code or Xcode won't compile.

0 commit comments

Comments
 (0)