diff --git a/.travis.yml b/.travis.yml index 4a80fee..32ad00f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: - PROJECT=GLTableCollectionView.xcodeproj - SCHEME=GLTableCollectionView - SDK=iphonesimulator10.1 - - DESTINATION="OS=10.1,name=iPhone 5" + - DESTINATION="platform=iOS Simulator,OS=latest,name=iPhone 5" before_install: - brew update diff --git a/GLTableCollectionView.xcodeproj/project.pbxproj b/GLTableCollectionView.xcodeproj/project.pbxproj index 5516e77..574a3fe 100644 --- a/GLTableCollectionView.xcodeproj/project.pbxproj +++ b/GLTableCollectionView.xcodeproj/project.pbxproj @@ -355,9 +355,28 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = GLTableCollectionView/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -373,9 +392,27 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEVELOPMENT_TEAM = ""; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = GLTableCollectionView/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/GLTableCollectionView/GLCollectionTableViewCell.swift b/GLTableCollectionView/GLCollectionTableViewCell.swift index bf54b34..18d00c8 100644 --- a/GLTableCollectionView/GLCollectionTableViewCell.swift +++ b/GLTableCollectionView/GLCollectionTableViewCell.swift @@ -21,29 +21,31 @@ class GLIndexedCollectionViewFlowLayout: UICollectionViewFlowLayout { } // To make paginated scrolling work fine this CGFloat below must be - // equal to the value set in the insetForSectionAt method + // equal to the value set in the insetForSectionAt method of // UICollectionView's UICollectionViewDelegate Flow Layout. let collectionViewInsets: CGFloat = 10.0 // Since UICollectionViewFlowLayout proposedContentOffset coordinates // won't take count of any UICollectionView UIEdgeInsets values we need - // to fix it by adding collectionViewInsets to .x coordinate. + // to fix it by adding collectionViewInsets to the .x coordinate. // - // Note: This will cover horizonal scrolling and pagination, if you need - // vertical pagination replace the .x coordinate with .y and update + // Note: This will only cover horizonal scrolling and pagination, if you + // need vertical pagination replace the .x coordinate with .y and update // collectionViewInsets value with the approriate one. let proposedXCoordWithInsets = proposedContentOffset.x + collectionViewInsets - // We start by creating a variable and we assign a very high CGFloat to - // it, a big number here is needed to cover very large - // UICollectionViewContentSize cases. + // We now create a variable and we assign a very high CGFloat to it (a + // big number here is needed to cover very large + // UICollectionViewContentSize cases). This var will hold the needed + // horizontal adjustment to make the UICollectionView paginate scroll. var offsetCorrection: CGFloat = .greatestFiniteMagnitude // Now we loop through all the different layout attributes of the // UICollectionViewCells contained between the .x value of the - // proposedContentOffset and collectionView's width looking for the cell - // which needs the least offsetCorrection value, it will mean that it's - // the first cell on the left of the screen which will give pagination. + // proposedContentOffset and collectionView's width, looking for the + // cell which needs the least offsetCorrection value: it will mean that + // it's the first cell on the left of the screen which will give + // pagination. for layoutAttributes in super.layoutAttributesForElements(in: CGRect(x: proposedContentOffset.x, y: 0, width: collectionView!.bounds.width, height: collectionView!.bounds.height))! { // Since layoutAttributesForElements may contain all sort of layout // attributes we need to check if it belongs to a @@ -169,11 +171,11 @@ class GLCollectionTableViewCell: UITableViewCell { - Parameter dataSource: The `dataSource` class for the GLIndexedCollectionView in the GLCollectionTableViewCell, it will be - responsible for the usual UICollectionView `dataSource` methods. + responsible for the UICollectionView's `dataSource` methods. - Parameter delegate: The `delegate class` for the GLIndexedCollectionView - in the GLCollectionTableViewCell, it will be responsible for the usual - UICollectionView delegation methods. + in the GLCollectionTableViewCell, it will be responsible for the + UICollectionView's delegation methods. - Parameter indexPath: The inner-`indexPath` of the GLIndexedCollectionView, it's recommended to pass the same `indexPath` of the UITableViewCell to the diff --git a/GLTableCollectionView/GLTableCollectionViewController.swift b/GLTableCollectionView/GLTableCollectionViewController.swift index 9367efa..7385dff 100644 --- a/GLTableCollectionView/GLTableCollectionViewController.swift +++ b/GLTableCollectionView/GLTableCollectionViewController.swift @@ -12,8 +12,8 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa // This string constant will be the cellIdentifier for the UITableViewCells // holding the UICollectionView, it's important to append "_section#" to it // so we can understand which cell is the one we are looking for in the - // debugger. Look in the UITableView's data source cellForRowAt method for - // more explaination about how we handle the cell reuse. + // debugger. Look in UITableView's data source cellForRowAt method for more + // explainations about the UITableViewCell reuse handling. let tableCellID: String = "tableViewCellID_section_#" let collectionCellID: String = "collectionViewCellID" @@ -23,7 +23,7 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa var colorsDict: [Int: [UIColor]] = [:] - // Set true to enable UICollectionViews scroll pagination + /// Set true to enable UICollectionViews scroll pagination var paginationEnabled: Bool = true override func viewDidLoad() { @@ -72,18 +72,18 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - // As you can see below instead of having a single cellIdentifier for - // each type of UITableViewCells, as you would do with normally, we will - // have multiple IDs each related to a indexPath section. Doing so the - // UITableViewCells will still be recycled but it will be done only with - // dequeueReusableCell of a given section. + // Instead of having a single cellIdentifier for each type of + // UITableViewCells, like in a regular implementation, we have multiple + // cellIDs, each related to a indexPath section. By Doing so the + // UITableViewCells will still be recycled but only with + // dequeueReusableCell of that section. // // For example the cellIdentifier for section 4 cells will be: // "tableViewCellID_section_#3" // dequeueReusableCell will only reuse previous UITableViewCells with // the same cellIdentifier instead of using any UITableViewCell as a // regular UITableView would do, this is necessary because every cell - // will have a different UICollectionView and UICollectionViewCells in + // will have a different UICollectionView with UICollectionViewCells in // it and UITableView reuse won't work as expected giving back wrong // cells. var cell: GLCollectionTableViewCell? = tableView.dequeueReusableCell(withIdentifier: tableCellID + indexPath.section.description) as? GLCollectionTableViewCell diff --git a/GitHub Page/Images/Source/Diagram.graffle b/GitHub Page/Images/Source/Diagram.graffle index 519a25e..5ba5794 100644 Binary files a/GitHub Page/Images/Source/Diagram.graffle and b/GitHub Page/Images/Source/Diagram.graffle differ diff --git a/GitHub Page/Images/Source/Logo.pxm b/GitHub Page/Images/Source/Logo.pxm index 6b5b96f..e7a1c22 100644 Binary files a/GitHub Page/Images/Source/Logo.pxm and b/GitHub Page/Images/Source/Logo.pxm differ diff --git a/GitHub Page/Images/diagram.png b/GitHub Page/Images/diagram.png index f387a5c..26f0bce 100644 Binary files a/GitHub Page/Images/diagram.png and b/GitHub Page/Images/diagram.png differ diff --git a/GitHub Page/Images/logo.png b/GitHub Page/Images/logo.png index 88bfcff..9f809e0 100644 Binary files a/GitHub Page/Images/logo.png and b/GitHub Page/Images/logo.png differ diff --git a/README.md b/README.md index be0d798..9103e7a 100644 --- a/README.md +++ b/README.md @@ -15,24 +15,24 @@ [![GitHub license](https://img.shields.io/badge/license-AGPL-blue.svg)](https://raw.githubusercontent.com/giulio92/GLTableCollectionView/master/LICENSE.txt) ## What it is -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. +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. ||**GLTableCollectionView**| |:---:|---| -|🔄|Uses the **same** ```UITableView``` reusable cells logic provided from Apple's implementation| -|♻️|```UICollectionView``` cell recycle| -|🆒|Both ```UITableView``` & ```UICollectionView``` can have their own sections and/or headers| -|🖼|Customization of ```UICollectionViewCell```s using the same ```UICollectionViewDelegate Flow Layout``` you already know| -|✨|Previous ```UICollectionView``` **.contentOffset** value restoration after scroll| +|🔄|Uses the **same** `UITableView` reusable cells logic provided from Apple's implementation| +|♻️|`UICollectionView` cell recycle| +|🆒|Both `UITableView` & `UICollectionView` can have their own sections and/or headers| +|🎨|Customization of `UICollectionViewCell`s using the same `UICollectionViewDelegate Flow Layout` you already know| +|✨|Previous `UICollectionView` **.contentOffset** value restoration after scroll| |↔️|UICollectionView cell-size-based scroll pagination, see below for instructions| |📐|Storyboard and Auto Layout compatibility| |💎|Clean architecture| |🔧|Unit Tests| ## Enable/disable scroll pagination -Set ```paginationEnabled``` variable ```true``` in GLTableCollectionViewController class, ```false``` to disable +Set `paginationEnabled` variable `true` in GLTableCollectionViewController class, `false` to disable. Default value is `true`. ``` -// Set true to enable UICollectionViews scroll pagination +/// Set true to enable UICollectionViews scroll pagination var paginationEnabled: Bool = true ``` @@ -52,4 +52,4 @@ var paginationEnabled: Bool = true - iOS 8.0+ ## Note -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. +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.