A wrapper around UICollectionViewController enabling a declarative API around it's delegate methods using protocols.

Overview

Thunder Collection

Build Status Swift 5.3.2 Apache 2

Thunder Collection is a useful framework which enables quick and easy creation of collection views in iOS using a declarative approach. It makes the process of creating complex collection views as simple as a few lines of code; and removes the necessity for having long chains of index paths and if statements.

How It Works

Thunder Collection comprises of two main types of objects:

Items

Collection items are objects that conform to the CollectionItemDisplayable protocol, this protocol has properties such as: cellClass, selectionHandler which are responsible for defining how the cell is configured. As this is a protocol any object can conform to it, which allows you to simply send an array of model objects to the collection view to display your content.

Sections

Collection sections are objects that conform to the CollectionSectionDisplayable protocol, most of the time you won't need to implement this protocol yourself as Thunder Collection has a convenience class CollectionSection which can be used in most circumstances. However you can implement more complex layouts using this protocol on your own classes.

Installation

Setting up your app to use ThunderCollection is a simple and quick process. You can choose between a manual installation, or use Carthage.

Carthage

  • Add github "3sidedcube/ThunderCollection" == 1.3.1 to your Cartfile.
  • Run carthage update --platform ios to fetch the framework.
  • Drag ThunderCollection into your project's Linked Frameworks and Libraries section from the Carthage/Build folder.
  • Add the Build Phases script step as defined here.

Manual

  • Clone as a submodule, or download this repo
  • Import ThunderCollection.xcproject into your project
  • Add ThunderCollection.framework to your Embedded Binaries.
  • Wherever you want to use ThunderCollection use import ThunderCollection.

Code Example

A Simple Collection View Controller

Setting up a collection view is massively simplified using thunder collection, in fact, we can get a simple collection view running with just a few lines of code. To create a custom collection view we subclass from CollectionViewController. We then set up our collection view in the viewDidLoad: method. In contrast to ThunderCollection no default implementations of CollectionItemDisplayable are provided, as there is no standard implementation of UICollectionViewCell like there is with UITableViewCell.

import ThunderCollection

class MyCollectionViewController: CollectionViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // ImageRow not provided by framework!
        let imageRow = ImageRow(image: someImage)
        
        let section = CollectionSection(rows: [imageRow])
        data = [section]
    }
}

Building Binaries for Carthage

Since Xcode 12 there has been issues with building Carthage binaries caused by the inclusion of a secondary arm64 slice in the generated binary needed for Apple Silicon on macOS. This means that rather than simply using carthage build --archive you need to use the ./carthage-build build --archive command which uses the script included with this repo. For more information, see the issue on Carthage's github here

We will be investigating moving over to use SPM as an agency soon, and will also look into migrating to use .xcframeworks as soon as Carthage have support for it.

License

See LICENSE.md

Comments
  • Release/v2.0.0

    Release/v2.0.0

    Description

    • Bump version to v2.0.0
    • Make suggested Xcode 13 updates

    No particular major changes needed. Now support up to iOS 13.

    Motivation and Context

    OS Updates

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [x] Breaking change (fix or feature that would cause existing functionality to change)

    It is breaking in the sense that we have dropped pre-iOS12 support.

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] My change requires a change to the documentation.
    • [x] I have updated the documentation accordingly.
    • [x] I have read the CONTRIBUTING document.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by BenShutt 0
  • Feature/thunder collection.xcframework

    Feature/thunder collection.xcframework

    Migrate to xcframework

    Description

    Migrate to ThunderCollection.framework to ThunderCollection.xcframework

    Related Issue

    Motivation and Context

    Migrating to use .xcframeworks as Carthage has support for it.

    How Has This Been Tested?

    Created a small project, installed ThunderCollection via carthage, created a collectionview and added images.

    Screenshots (if appropriate):

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    • [x] I have read the CONTRIBUTING document.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by RodrigoLondon 0
  • Release/v1.3.0

    Release/v1.3.0

    Description

    Simple release update for iOS 14 and Swift 5.3 support

    Motivation and Context

    Needed for compiling for Swift 5.3

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] My change requires a change to the documentation.
    • [x] I have updated the documentation accordingly.
    • [x] I have read the CONTRIBUTING document.
    • [ ] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
    opened by simonmitchell 0
  • Removed ThunderTable dependency

    Removed ThunderTable dependency

    ThunderTable itself is not referenced anywhere within the ThunderCollection framework, yet somehow was being built when using carthage - and as it was out of date (Swift 3.0) it was causing compiler errors in projects that depended on ThunderCloud.

    Therefore, I've removed the git submodule and the containing folder. Now, with ThunderCloud pointing at 92fd022, it is building without error!

    opened by ryanbourneuk 0
  • Fixes single column when manually change collection view's frame

    Fixes single column when manually change collection view's frame

    Changes the cell sizing to check the collectionView's frame rather than the view's frame because if apps change the view's frame (Looking at you GDPC Hazards) then this logic is broken and we end up with a single column layout

    opened by simonmitchell 0
  • Changes `collectionCellClass` to `UICollectionViewCell.Type` and renames it to `cellClass`

    Changes `collectionCellClass` to `UICollectionViewCell.Type` and renames it to `cellClass`

    Changes collectionCellClass to cellClass and makes it UICollectionViewCell.Type

    rather than AnyClass so it is more strongly typed and inline with ThunderTable

    opened by simonmitchell 0
  • Fix/cell size iphone x

    Fix/cell size iphone x

    Due to the iPhone X having a width of 375 pts, when calculating available width with zero insets or interim spacing and columns == 2 the collection view would be rendered as 1 column due to the width of the device being odd. This PR makes sure the width is always floored to avoid this!

    opened by simonmitchell 0
  • Changes get set defines of protocol methods

    Changes get set defines of protocol methods

    These are changed to be in-line with ThunderTable so you don't have to worry about providing both the get and set function when implementing the protocol.

    opened by simonmitchell 0
  • Adjust the available width calculation slightly to get rid of available width/height errors

    Adjust the available width calculation slightly to get rid of available width/height errors

    Been working on a personal app and realised that the column/row width calculations are off slightly. This fixes it 😊 before, it was dividing the width/height by number of columns/rows respectively, and then removing the interim spacing. Now it removes the interim spacing first, and then divides.

    opened by simonmitchell 0
  • Fixes recursion of redraw

    Fixes recursion of redraw

    This fixes an issue where in Swift 4.1 the didSet method of data method was called continuously if any of the code the redraw calls mutates anything in the array of data items, see swift bug report here.

    This is fairly simple to fix by having the public data property being a calculated var which uses an internal private equivalent used by the methods in CollectionViewController.

    It's possible we will be able to undo this change in a later version of swift.

    opened by simonmitchell 0
  • Add support for reloading certain index paths.

    Add support for reloading certain index paths.

    We should find some way that when you set data on CollectionViewController we can only reload cells that actually need it. Might need to move away from data being an array, or possibly have a function on the CollectionItemDisplayable which returns if the change has affected the drawn UI.

    enhancement 
    opened by simonmitchell 0
  • Add support for pre-fetching APIs

    Add support for pre-fetching APIs

    We should add support for the pre-fetching APIs introduced by Apple in iOS 10! This could be really simply done, by adding a closure to the CollectionItemDisplayable protocol in a similar style to the selectionHandler.

    enhancement 
    opened by simonmitchell 0
Releases(v1.3.1)
Owner
3 SIDED CUBE
We're an app development and digital product company that specialises in tech for good.
3 SIDED CUBE
🚴 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
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
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state.

Prephirences - Preϕrences Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, co

Eric Marchand 557 Nov 22, 2022
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. UserDefaults

Prephirences - Preϕrences Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, co

Eric Marchand 557 Nov 22, 2022
Xcode Plugin helps you find missing methods in your class header, protocols, and super class, also makes fast inserting.

FastStub-Xcode Life is short, why waste it on meaningless typing? What is it? A code generating feature borrowed from Android Studio. FastStub automat

mrpeak 509 Jun 29, 2022
A stand-alone Swift wrapper around the mongo-c client library, enabling access to MongoDB servers.

This package is deprecated in favour of the official Mongo Swift Driver. We advise users to switch to that pack

PerfectlySoft Inc. 54 Jul 9, 2022
Perfect - a Swift wrapper around the MySQL client library, enabling access to MySQL database servers.

Perfect - MySQL Connector This project provides a Swift wrapper around the MySQL client library, enabling access to MySQL database servers. This packa

PerfectlySoft Inc. 119 Dec 16, 2022
A stand-alone Swift wrapper around the libpq client library, enabling access to PostgreSQL servers.

Perfect - PostgreSQL Connector This project provides a Swift wrapper around the libpq client library, enabling access to PostgreSQL servers. This pack

PerfectlySoft Inc. 51 Nov 19, 2022
A stand-alone Swift wrapper around the MySQL client library, enabling access to MySQL servers.

Perfect - MySQL Connector This project provides a Swift wrapper around the MySQL client library, enabling access to MySQL database servers. This packa

PerfectlySoft Inc. 118 Jan 1, 2023
A stand-alone Swift wrapper around the libpq client library, enabling access to PostgreSQL servers.

Perfect - PostgreSQL Connector This project provides a Swift wrapper around the libpq client library, enabling access to PostgreSQL servers. This pack

PerfectlySoft Inc. 51 Nov 19, 2022
A stand-alone Swift wrapper around the FileMaker XML Web publishing interface, enabling access to FileMaker servers.

Perfect - FileMaker Server Connector This project provides access to FileMaker Server databases using the XML Web publishing interface. This package b

PerfectlySoft Inc. 33 Jul 13, 2022
A wrapper on the CoreLocation framework replacing the delegate pattern with Swift concurrency

swift-locations A wrapper on the CoreLocation framework replacing the delegate pattern with Swift concurrency. Overview CoreLocation reports a device'

Alexandre H. Saad 5 Nov 26, 2022
`Republished` is a property wrapper enabling nested ObservableObjects in SwiftUI.

Republished The @Republished proprty wrapper allows an ObservableObject nested within another ObservableObject to naturally notify SwiftUI of changes.

Adam Zethraeus 13 Dec 5, 2022
UIView subclass that bends its edges when its position changes.

AHKBendableView BendableView is a UIView subclass that bends its edges when its position change is animated. Internally, BendableView contains CAShape

Arek Holko 591 Jul 24, 2022
A UISwitch that infects its superview with its tint color.

UISwitch subclass that 'infects' the parent view with the onTintColor when the switch is turned on. Inspired by this Dribble by Ramotion. Screenshot I

Andrea Mazzini 337 Sep 12, 2022
An Integer type that clamps its value to its minimum and maximum instead of over- or underflowing.

ClampedInteger An Integer type that clamps its value to its minimum and maximum instead of over- or underflowing. Examples let big = ClampedIntege

Berik Visschers 0 Jan 17, 2022
MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP.

MailCore 2: Introduction MailCore 2 provides a simple and asynchronous Objective-C API to work with the e-mail protocols IMAP, POP and SMTP. The API h

MailCore 2.5k Jan 1, 2023
This package gives wrapper methods for Desk360 SDK.

Desk360 (flutter sdk) This package gives wrapper methods for desk360 sdks. iOS - Android Getting started Add below code into your pubspec.yaml file un

Teknasyon Tech 10 Dec 12, 2022
A meta library to provide a better `Delegate` pattern.

Delegate A meta library to provide a better Delegate pattern described here and here. Usage Instead of a regular Apple's protocol-delegate pattern, us

Wei Wang 67 Dec 23, 2022