ThunderTable
  • October 7, 2023

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" == 2.0.0 to your Cartfile.
  • Run carthage update --platform ios --use-xcframeworks to fetch the framework.
  • Drag ThunderTable into your project’s Frameworks and Libraries section from the Carthage/Build folder (Embed).
  • 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]
}
}

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

GitHub


View Github

#declarativeui #swift #table #tableview #uitableview
YOU MIGHT ALSO LIKE...
EEStackLayout

A vertical stackview which takes subviews with different widths and adds them to it's rows with paddings, spacings etc.

AudioManager

AudioManager is a Swift package that provides a modular and easy-to-use interface for implementing audio feedback in your applications. It ...

CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...