Netflix and App Store like UITableView with UICollectionView, written in pure Swift 4.2

Overview

GLTableCollectionView

Branch Status
master BuddyBuild
develop BuddyBuild

Language Supported platforms codebeat badge license

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 its UITableView and UICollectionView parts since it has been made on the same Data Source and Delegate methods with no complicated additions.

GLTableCollectionView
🔄 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 UICollectionViewCells 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. Default value is true.

/// Set true to enable UICollectionViews scroll pagination
var paginationEnabled: Bool = true

Demo

How it works

Requirements

  • Xcode 10.0+
  • Swift 4.2+
  • iOS 9.0+
  • SwiftLint (Optional, but highly suggested)

Donations

  • PayPal

  • BTC: 3Mc25tFtxxwD9mXqtxFn5Qvkbndg3NhvXi

  • LTC: MUoZzdDqD2BkWsVpcSv1pQVHhCcUuiADCL

Comments
  • Jumping to end of Content

    Jumping to end of Content

    I had an issue with GLIndexedCollectionViewFlowLayout where when content offset is 0, if I were to bounce the collection (pull it to have a negative content offset on x) the offset would jump to the very end of the loaded content in the collection.

    I added this:

    if offsetCorrection != .greatestFiniteMagnitude {
        return CGPoint(x: proposedContentOffset.x + offsetCorrection, y: 0)
    } else {
        return CGPoint(x: proposedContentOffset.x , y: 0)
    }
    

    to the final return in:

    func targetContentOffset(forProposedContentOffset proposedContentOffset: , withScrollingVelocity velocity: )
    

    Probably not the best way to handle this behavior, since I am not 100% sure why that number needs to be so high

    I just wanted to bring some attention to this, as I wasn't sure if it was intended behavior to scroll to the end on a bounce at the beginning of the collection like that.

    bug standby 
    opened by mmdock 5
  • Fix pagingEnabled not working.

    Fix pagingEnabled not working.

    If collectionViewPaginatedScroll was true it set collectionView.isPagingEnabled to false and it was never set to true anywhere. So setting paginationEnabled inside of GLTableCollectionViewController did nothing.

    standby 
    opened by chickdan 4
  • How to get

    How to get "indexPath.section" in a UICollectionView?

    Thank you for the great project!! When I tapped a collectionView, how can I get "indexPath.section"? I could get indexPath.item but indexPath.section always returns "0".

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { print(indexPath.section) print(indexPath.item) }

    Thank you!

    question 
    opened by dkmczk 2
  • Change pronoun

    Change pronoun

    The pronoun "his" is for men, and "its" is for things. GLTableCollectionView is a thing, so "its" is the correct pronoun.

    opened by getaaron 1
  • Use custom UICollectionViewCell

    Use custom UICollectionViewCell

    I want to use more than one UICollectionViewCell in the table view

    Description:

    I want to use more than one UICollectionViewCell in the table view but get fatal error like the custom cell didn't registered! It works just with one view cell (default cell or custom cell) but if i want to use mixed of these i got error. Thanks for your help 👍

    Expected Behavior:

    Show default cell with custom new cell

    Actual Behavior:

    Fatal error

    Steps to Reproduce:

    Custom cell -> GameCell.swift

    import UIKit
    
    class GameCell: UICollectionViewCell {
        
        static let id: String = "collectionViewCellID"
        
        override init(frame: CGRect) {
            super.init(frame: frame)
            setupViews()
        }
        
        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }
        
        let imageView: UIImageView = {
            let iv = UIImageView()
            iv.contentMode = .scaleAspectFill
            iv.layer.cornerRadius = 16
            iv.layer.masksToBounds = true
            iv.image = UIImage(named: "someImage")
            return iv
        }()
        
        func setupViews() {
            addSubview(imageView)
            
            imageView.frame = CGRect(x: 0, y: 0, width: frame.width, height: frame.width)
        }
    }
    

    GLCollectionTableViewCell.swift -> line 147

    collectionView.register(GameCell.self, forCellWithReuseIdentifier: GameCell.id)

    GLTableCollectionViewController.swift -> line 117

            if indexPath.item % 2 == 0 {
                guard let cell: GLIndexedCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: GLIndexedCollectionViewCell.identifier, for: indexPath) as? GLIndexedCollectionViewCell else {
                    fatalError("UICollectionViewCell must be of GLIndexedCollectionViewCell type")
                }
                cell.backgroundColor = UIColor(hue: CGFloat(indexPath.item) / 20.0, saturation: 0.8, brightness: 0.9, alpha: 1)
                return cell
            }
            else{
                guard let cell: GameCell = collectionView.dequeueReusableCell(withReuseIdentifier: GameCell.id, for: indexPath) as? GameCell else {
                    fatalError("UICollectionViewCell must be of GLIndexedCollectionViewCell type")
                }
                return cell
            }
    

    Your Environment:

    • xCode: 9.4.1
    • GLTableCollectionView version: Last Version
    • Device: iPhone 6s (Real Device)
    • iOS version: 11.4
    opened by cylak 1
  • How to install this?

    How to install this?

    Description:

    Expected Behavior:

    Actual Behavior:

    Steps to Reproduce:

    Your Environment:

    • GLTableCollectionView version:
    • Device:
    • iOS version:
    standby 
    opened by sirvon 1
  • Conversion for carthage and pods support

    Conversion for carthage and pods support

    This PR is to reorganize the structure of the repo to separate out the classes necessary for the framework from the demo app. Everything is setup to be Carthage and Pods compatible and it is working with Carthage (needs to be registered on cocoapods.org for the pod to work). However because the library was initially designed as an app instead of a framework it is not easy to customize the behavior. The source classes will need some rework but I have yet to figure out where to begin (maybe another contributor can help out).

    standby 
    opened by chickdan 1
  • Carthage support

    Carthage support

    opened by TofPlay 1
  • Add/Delete Sections and Add/Delete CollectionView Cells

    Add/Delete Sections and Add/Delete CollectionView Cells

    Hi Giulio!

    Great Project! Do you have any writing about Add/Delete Sections and Add/Delete CollectionView Cells from user interface, can you help me please. Thanks

    question 
    opened by nelsaow 1
  • Fix wrong targetContentOffset return values

    Fix wrong targetContentOffset return values

    This PR will fix issue #30 causing the targetContentOffset(forProposedContentOffset proposedContentOffset: , withScrollingVelocity velocity: ) to return a CGPoint with x equal to .greatestFiniteMagnitude when proposedContentOffset.x was equal to 0.

    Thanks to @mmdock for finding this bug 🐞 and for proposing a solution!

    bug 
    opened by giulio92 0
  • Fix the

    Fix the "last cell" bug while using paginated scrolling

    • Fix the "last cell" bug while using the paginated scroll mode, the bug caused the first cell opposite to the scrolling direction to snap instead of the last one.
    • Comments updated
    • Few minor spelling fix here and there
    • Project files updated to Xcode 8.3
    bug enhancement 
    opened by giulio92 0
Releases(1.83)
Owner
Giulio
●○ Flickr https://flic.kr/giuliolombardo
Giulio
Automates prefetching of content in UITableView and UICollectionView

Automates preheating (prefetching) of content in UITableView and UICollectionView. Deprecated on iOS 10. This library is similar to UITableViewDataSou

Alexander Grebenyuk 633 Sep 16, 2022
Incremental update tool to UITableView and UICollectionView

EditDistance is one of the incremental update tool for UITableView and UICollectionView. The followings show how this library update UI. They generate

Kazuhiro Hayashi 90 Jun 9, 2022
🚴 A declarative library for building component-based user interfaces in UITableView and UICollectionView.

A declarative library for building component-based user interfaces in UITableView and UICollectionView. Declarative Component-Based Non-Destructive Pr

Ryo Aoyama 1.2k Jan 5, 2023
A generic small reusable components for data source implementation for UITableView/UICollectionView in Swift.

GenericDataSource A generic small reusable components for data source implementation for UITableView/UICollectionView written in Swift. Features Basic

null 132 Sep 8, 2021
ZHTCView - UITableview & UICollectionView

ZHTCView 这是一个使用Block替换代理的UITableview & UICollectionView。 使用方法如下: - (DSTableView *)tableView { if (!_tableView) { _tableView = DSTableView.

黑酒一 0 Jan 10, 2022
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.

DiffableDataSources ?? A library for backporting UITableView/UICollectionViewDiffableDataSource powered by DifferenceKit. Made with ❤️ by Ryo Aoyama I

Ryo Aoyama 762 Dec 28, 2022
Easier way to represent the structure of UITableView.

Shoyu Shoyu is a library written in Swift to represent UITableView data structures. Shoyu means Soy Sauce in Japanese. Usage Create single section and

yukiasai 278 Apr 14, 2022
A data-driven UICollectionView framework for building fast and flexible lists.

A data-driven UICollectionView framework for building fast and flexible lists. Main Features ?? Never call performBatchUpdates(_:, completion:) or rel

Instagram 12.5k Jan 1, 2023
Collapse and expand UICollectionView sections with one method call.

This library provides a custom UICollectionView that allows to expand and collapse sections. Provides a simple API to manage collection view appearanc

Touchlane 172 Dec 26, 2022
Protocol-oriented UICollectionView management, powered by generics and associated types.

DTCollectionViewManager Features Powerful mapping system between data models and cells, headers and footers Automatic datasource and interface synchro

Denys Telezhkin 308 Jan 6, 2023
UICollectionView layout for presenting of the overlapping cells.

StickyCollectionView UICollectionView layout for presenting of the overlapping cells. Objective-C version here Checkout demo Overview Installation Man

Bogdan Matveev 325 Oct 11, 2022
Reimagining UICollectionView

CollectionKit Reimagining UICollectionView A modern Swift framework for building composable data-driven collection view. Migration Guide v2.0 Features

SoySauceLab 4.3k Dec 27, 2022
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 157 Nov 25, 2022
CollectionView - UICollectionView using UICollectionViewCompositionalLayout

CollectionView UICollectionView using UICollectionViewCompositionalLayout create

null 0 Jan 11, 2022
CollectionViewSegmentedControl - Scrollable UISegmentedControl built using a UICollectionView

CollectionViewSegmentedControl Installation CocoaPods Download CocoaPods Run 'Po

James Sedlacek 7 Nov 24, 2022
Conv smart represent UICollectionView data structure more than UIKit.

Conv Conv smart represent UICollectionView data structure more than UIKit. Easy definition for UICollectionView DataSource and Delegate methods. And C

bannzai 155 May 12, 2022
A modest attempt to port UICollectionView to SwiftUI.

LazyCollectionView A modest attempt to port UICollectionView to SwiftUI. Table of Contents Description Requirements Installation Usage Components Impr

Unsplash 109 Dec 27, 2022
PJFDataSource is a small library that provides a simple, clean architecture for your app to manage its data sources while providing a consistent user interface for common content states (i.e. loading, loaded, empty, and error).

PJFDataSource PJFDataSource is a small library that provides a simple, clean architecture for your app to manage its data sources while providing a co

Square 88 Jun 30, 2022
Easy and type-safe iOS table and collection views in Swift.

Quick Start TL;DR? SimpleSource is a library that lets you populate and update table views and collection views with ease. It gives you fully typed cl

Squarespace 96 Dec 26, 2022