A declarative wrapper approach to UITableView

Overview

Thunder Table

Build Status Swift 5.3.2 Apache 2

Thunder Table is a useful framework which enables quick and easy creation of table views in iOS, making the process of creating complex tables as simple as a few lines of code; and removing the necessity for having long chains of index paths and if statements.

How It Works

Thunder table comprises of two main types of objects:

Rows

Table rows are objects that conform to the Row protocol, this protocol has properties such as: title, subtitle and image which are responsible for providing the content to a table view cell. As this is a protocol any object can conform to it, which allows you to simply send an array of model objects to the table view to display your content.

Sections

Table sections are objects that conform to the Section protocol, most of the time you won't need to implement this protocol yourself as Thunder Table has a convenience class TableSection 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 ThunderTable is a simple and quick process. You can choose between a manual installation, or use Carthage.

Carthage

  • Add github "3sidedcube/ThunderTable" == 1.6.1 to your Cartfile.
  • Run carthage update --platform ios to fetch the framework.
  • Drag ThunderTable 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 ThunderTable.xcproject into your project
  • Add ThunderTable.framework to your Embedded Binaries.
  • Wherever you want to use ThunderTable use import ThunderTable.

Code Example

A Simple Table View Controller

Setting up a table view is massively simplified using thunder table, in fact, we can get a simple table view running with just a few lines of code. To create a custom table view we subclass from TableViewController. We then set up our table in the viewDidLoad: method. Below is the full code for a table view that displays one row, with text, a subtitle, image and handles table selection by pushing another view.

import ThunderTable

class MyTableViewController: TableViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let imageRow = TableRow(title: "Settings", subtitle: "Configure your settings", image: UIImage(named: "settings-cog")) { (row, selected, indexPath, tableView) -> (Void) in
            
            let settings = SettingsViewController()
            self.showDetailViewController(settings, sender: self)
        }
        
        let section = TableSection(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.

Code level documentation

Documentation is available for the entire library in AppleDoc format. This is available in the framework itself or in the Hosted Version

License

See LICENSE.md

Comments
  • Feature/data did set

    Feature/data did set

    When reloadData() is not desired after setting data subclasses may set reloadDataOnDataDidSet = false. Subclasses should be responsible for their own reloading in this case.

    Motivation and Context

    Fix issue with a search row in an app referencing this framework.

    How Has This Been Tested?

    In the app referencing this framework.

    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.
    • [ ] 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 BenShutt 3
  • Release/v1.7.0

    Release/v1.7.0

    Summary

    Release for supporting the Swift 5.4 compiler and functional updates. Including:

    • (#68) Creating DeclarativeSection
    • (#69) Swift 5.4 fixes

    How Has This Been Tested?

    Tested in referencing apps.

    Types of changes

    • [x] 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.
    • [ ] All new and existing tests passed.
    opened by BenShutt 1
  • Adds a scroll offset manager class which caches and restores scroll offsets

    Adds a scroll offset manager class which caches and restores scroll offsets

    Description

    Adds ScrollOffsetManager for storing and restoring scroll offsets via a protocol implementation.

    This ensures that scroll offsets are only remembered where users explicitly request them to be, meaning we won't interfere with any custom logic they already have to handle this.

    Also adds examples of this to the demo project

    Related Issue

    N/A

    Motivation and Context

    Bugs were found in Blood within ThunderCloud where scroll offsets were incorrect due to cell re-use. This allows us to handle this better by caching scroll offsets where required.

    How Has This Been Tested?

    Has been tested using the demo project, and will shortly be tested within ThunderCloud and specifically in the case of Blood

    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.
    enhancement 
    opened by simonmitchell 1
  • Fixes cell separators on iPad

    Fixes cell separators on iPad

    Wraps view height check in brackets to fix cell separators never displaying

    on iPad... turns out on iPad cell separators are 1pt high rather than hairline width (1 pixel high) which mean that this was only affecting iPad. The brackets make sure our boolean logic is applied in the way we expected:

    if !shouldDisplaySeparators && is1PixelOrPointHigh

    rather than:

    if (!shouldDisplaySeparators && is1PixelHigh) || is1PointHight

    opened by simonmitchell 1
  • Fixes crash accessing IndexPath's section

    Fixes crash accessing IndexPath's section

    Description

    Fixes crash caused when we are sent an IndexPath with 0 elements in it's indexes array (occasionally when VoiceOver enabled). See: https://developer.apple.com/forums/thread/663787

    Motivation and Context

    Fixes a crash in (potentially) all of our apps when VoiceOver enabled

    How Has This Been Tested?

    Tested locally in ARC Emergency

    Screenshots (if appropriate):

    Types of changes

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [ ] 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.
    • [ ] 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.
    • [x] All new and existing tests passed.
    opened by simonmitchell 0
  • Feature/make func public

    Feature/make func public

    Description

    makes function public.

    Related Issue

    Motivation and Context

    How Has This Been Tested?

    Screenshots (if appropriate):

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] 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.
    • [ ] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    • [ ] 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/v2.0.0

    Release/v2.0.0

    Description

    • Bump version to v2.0.0
    • Make suggested Xcode 13 updates
    • Changes inherited from "release/v1.7.0"

    No particular major changes needed. Now support up to iOS 12. iOS 13 will require more action.

    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 table.xcframework

    Feature/thunder table.xcframework

    Description

    Converts ThunderTable.framework into 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 and added the ThunderTable.xcframework via Carthage. It is working as intended.

    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
  • Create `DeclarativeTableViewController` and remove `DeclarativeSection` logic from `TableViewController`

    Create `DeclarativeTableViewController` and remove `DeclarativeSection` logic from `TableViewController`

    Description

    Fix issue with implementing both:

    tableView(_:titleForHeaderInSection:)
    tableView(_:viewForHeaderInSection:)
    

    Use of DeclarativeSection will now require use of DeclarativeTableViewController Note - this was actually never merged, this is a fix into a release branch.

    Motivation and Context

    Fixing previous change

    How Has This Been Tested?

    Referencing apps

    Screenshots (if appropriate):

    Simulator Screen Shot - iPhone 12 - 2021-06-10 at 11 38 38

    Types of changes

    • [x] 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.
    • [ ] 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 BenShutt 0
  • Create `DeclarativeSection` and override header/footer methods in `TableViewController` for when the section is `DeclarativeSection`

    Create `DeclarativeSection` and override header/footer methods in `TableViewController` for when the section is `DeclarativeSection`

    Create DeclarativeSection for common usage of declarative UITableView Sections

    Motivation and Context

    A common use case, allows programmers to define Section logic in the redraw rather than overriding UITableViewDelegate methods.

    How Has This Been Tested?

    Used in other company apps

    Usage:

    func redraw() {
        data = [
            DeclarativeSection(rows: [textRow]),
            DeclarativeSection(rows: answerRows, headerHeight: 16),
            DeclarativeSection(rows: answerRows, headerHeight: UITableView.automaticDimension, headerView: UILabel.header)
        ]
    }
    

    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.
    • [ ] 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 BenShutt 0
  • Release/v1.6.0

    Release/v1.6.0

    Description

    Release for supporting the Swift 5.3 compiler and iOS 14

    Related Issue

    N/A

    Motivation and Context

    Adds support for new iOS 14 APIs

    How Has This Been Tested?

    Has been tested using the included demo project

    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.
    • [ ] 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.
    • [x] All new and existing tests passed.
    opened by simonmitchell 0
  • Adds placeholderImage property to `Row` protocol

    Adds placeholderImage property to `Row` protocol

    Description

    This solves an issue I was having with didSet not being called on a struct/class/enum implementing the Row protocol.

    If you want the image view to have a placeholder image, previously the easiest way was to return this placeholder from the image property. However, ThunderTable does a check for nil on the row's image before setting image after an asynchronous image load and therefore didSet on image was never called!

    Motivation and Context

    Solves problems around loading images for rows

    How Has This Been Tested?

    Has been tested in the example project

    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
  • Add support for partial redraw

    Add support for partial redraw

    We should find some way that when you set data on TableViewController 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 Row protocol which returns if the change has affected the drawn UI.

    enhancement 
    opened by simonmitchell 1
  • 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 Row protocol in a similar style to the selectionHandler.

    enhancement 
    opened by simonmitchell 0
Releases(v1.6.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 api for working with UITableView.

⚡️ Lightning Table Lightning Table provides a powerful declarative API for working with UITableView's. Table views are the foundation of almost every

Electric Kangaroo 28 Aug 25, 2021
INTUZ is presenting an interesting a Multilevel Expand/Collapse UITableView App Control to integrate inside your native iOS-based application

INTUZ is presenting an interesting a Multilevel Expand/Collapse UITableView App Control to integrate inside your native iOS-based application. MultilevelTableView is a simple component, which lets you use the tableview with multilevel tree view in your project.

INTUZ 3 Oct 3, 2022
A PageView, which supporting scrolling to transition between a UIView and a UITableView

YXTPageView ##A Page View, which support scrolling to transition between a UIView and a UITableView UIView (at the top) UITableView (at the bottom) In

Hanton Yang 68 May 25, 2022
A simple way to create a UITableView for settings in Swift.

QuickTableViewController A simple way to create a table view for settings, including: Table view cells with UISwitch Table view cells with center alig

Cheng-Yao Lin 525 Dec 20, 2022
Simple and beautiful stacked UIView to use as a replacement for an UITableView, UIImageView or as a menu

VBPiledView simple but highly effective animation and interactivity! By v-braun - viktor-braun.de. Preview Description Very simple and beautiful stack

Viktor Braun 168 Jan 3, 2023
A pixel perfect replacement for UITableView section index, written in Swift

MYTableViewIndex MYTableViewIndex is a re-implementation of UITableView section index. This control is usually seen in apps displaying contacts, track

Yury 520 Oct 27, 2022
Easy UITableView drag-and-drop cell reordering

SwiftReorder NOTE: Some users have encountered compatibility issues when using this library with recent versions of iOS. For apps targeting iOS 11 and

Adam Shin 378 Dec 13, 2022
A cells of UITableView can be rearranged by drag and drop.

TableViewDragger This is a demo that uses a TableViewDragger. Appetize's Demo Requirements Swift 4.2 iOS 8.0 or later How to Install TableViewDragger

Kyohei Ito 515 Dec 28, 2022
A subclass of UITableView that styles it like Settings.app on iPad

TORoundedTableView As of iOS 13, Apple has released an official version of this table view style called UITableViewStyleInsetGrouped! Yay! In order to

Tim Oliver 162 Nov 2, 2022
A simpler way to do cool UITableView animations! (╯°□°)╯︵ ┻━┻

TableFlip (╯°□°)╯︵ ┻━┻ ┬──┬ ノ( ゜-゜ノ) Animations are cool. UITableView isn't. So why not make animating UITableView cool? The entire API for TableFlip

Joe Fabisevich 555 Dec 9, 2022
Protocol-oriented UITableView management, powered by generics and associated types.

DTTableViewManager Features Powerful mapping system between data models and cells, headers and footers Automatic datasource and interface synchronizat

Denys Telezhkin 454 Nov 9, 2022
A UITableView extension that enables cell insertion from the bottom of a table view.

ReverseExtension UITableView extension that enabled to insert cell from bottom of tableView. Concept It is difficult to fill a tableview content from

Taiki Suzuki 1.7k Dec 15, 2022
Simple single-selection or multiple-selection checklist, based on UITableView

SelectionList Simple single-selection or multiple-selection checklist, based on UITableView. Usage let selectionList = SelectionList() selectionList.i

Yonat Sharon 111 Oct 6, 2022
Type-safe declarative table views.

TableKit TableKit is a super lightweight yet powerful generic library that allows you to build complex table views in a declarative type-safe manner.

Max Sokolov 694 Dec 13, 2022
The declarative approach to UIKit.

SugarKit SugarKit is a declarative approach to the UIKit framework. It allows you to Declare your views in a clean and concise way like let button = U

Roman Nabiullin 3 Oct 31, 2022
HoverConversion realized vertical paging with UITableView. UIViewController will be paged when reaching top or bottom of UITableView contentOffset.

HoverConversion ManiacDev.com referred. https://maniacdev.com/2016/09/hoverconversion-a-swift-ui-component-for-navigating-between-multiple-table-views

Taiki Suzuki 166 Feb 1, 2022
Carbon🚴 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 declarative api for working with UITableView.

⚡️ Lightning Table Lightning Table provides a powerful declarative API for working with UITableView's. Table views are the foundation of almost every

Electric Kangaroo 28 Aug 25, 2021
🚴 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
Tempura - A holistic approach to iOS development, inspired by Redux and MVVM

Tempura is a holistic approach to iOS development, it borrows concepts from Redux (through Katana) and MVVM. ?? Installation Requirements CocoaPods ??

Bending Spoons 692 Dec 17, 2022