OKTableViewLiaison alternatives and similar libraries
Based on the "UITableView" category.
Alternatively, view OKTableViewLiaison alternatives based on common mentions on social networks and blogs.
-
folding-cell
:octocat: 📃 FoldingCell is an expanding content cell with animation made by @Ramotion -
SwipeCellKit
Swipeable UITableViewCell/UICollectionViewCell based on the stock Mail.app, implemented in Swift. -
DGElasticPullToRefresh
Elastic pull to refresh for iOS developed in Swift -
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift -
HGPlaceholders
Nice library to show placeholders and Empty States for any UITableView/UICollectionView in your project -
ReverseExtension
A UITableView extension that enables cell insertion from the bottom of a table view. -
ExpandableCell
✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 5 -
GridView
Reusable GridView with excellent performance and customization that can be time table, spreadsheet, paging and more. -
DiffableDataSources
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource. -
PullToRefreshSwift
iOS Simple Cool PullToRefresh Library. It is written in pure swift. -
KJCategories
Collection of native ios extensions and classes to boost development process. Such as UIKit, Foundation, QuartzCore, Accelerate, OpenCV, CoreGraphics, os and more. 超实用开发加速工具收集 -
QuickTableViewController
A simple way to create a UITableView for settings in Swift. -
YNExpandableCell
✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 4 -
CollapsibleTableSectionViewController
:tada: Swift library to support collapsible sections in a table view. -
ExpyTableView
Make your table view expandable just by implementing one method. -
WLEmptyState
WLEmptyState is an iOS based component that lets you customize the view when the dataset of a UITableView or a UICollectionView is empty. We created a sample project with the WLEmptyState component to show how you can use it. -
SwiftyComments
UITableView based component designed to display a hierarchy of expandable/foldable comments. -
AEAccordion
Simple and lightweight UITableViewController with accordion effect (expand / collapse cells) -
SectionScrubber
A component to quickly scroll between collection view sections -
SelectionList
Simple single-selection or multiple-selection checklist, based on UITableView -
SPDiffable
Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar. -
AZTableViewController
Elegant and easy way to integrate pagination with dummy views -
CollapsibleTable
Collapsable table view sections with custom section header views. -
FDTextFieldTableViewCell
A UITableViewCell with an editable text field -
Doppelganger-Swift
Array diffs as collection view wants it - now in Swift ✨ -
CKTextFieldTableCell
UITableViewCell drop-in replacement with support of UITextField
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of OKTableViewLiaison or a related project?
README
UITableView
made simple 🙌
Main Features | |
---|---|
🙉 | Skip the UITableViewDataSource & UITableViewDelegate boilerplate and get right to building your UITableView ! |
🌀 | Closure based API for section and row configuration |
📄 | Built-in paging functionality |
✅ | Unit Tested |
🐤 | Written in Swift 4.2 |
OKTableViewLiaison
is 🔨 with ❤️ by 📱 @ OkCupid.
We use the latest and greatest open source version of master
in the OkCupid app.
Requirements
- Xcode 10.0+
- iOS 9.0+
Installation
CocoaPods
The preferred installation method is with CocoaPods. Add the following to your Podfile
:
pod 'OKTableViewLiaison'
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Usage
OKTableViewLiaison
allows you to more easily populate and manipulate UITableView
rows and sections.
Getting Started
To get started, all you need to do is liaise
an instance of UITableView
to with a OKTableViewLiaison
:
let liaison = OKTableViewLiaison()
let tableView = UITableView()
liaison.liaise(tableView: tableView)
By liaising your tableView with the liaison, the liaison becomes its UITableViewDataSource
, UITableViewDelegate
, and UITableViewDataSourcePrefetching
.
In the event you would like to remove the tableView from the liaison, simply invoke liaison.detach()
.
OKTableViewLiaison populates sections and rows using two main types:
Section
struct OKTableViewSection
To create a section for our tableView, create an instance of OKTableViewSection
and add it to the liaison.
let section = OKTableViewSection()
let liaison = OKTableViewLiaison(sections: [section])
or
let section = OKTableViewSection()
liaison.append(section: section)
Supplementary Section Views
To notify the liaison that your OKTableViewSection
will display a header and/or footer view, you must provide an instance of OKTableViewSectionComponentDisplayOption
during initialization.
OKTableViewSectionComponentDisplayOption
is an enumeration that notfies the liaison which supplementary views should be displayed for a given section. A header/footer view is represented by:
class OKTableViewSectionComponent<View: UITableViewHeaderFooterView, Model>
let header = OKTableViewSectionComponent<UITableViewHeaderFooterView, User>(.dylan)
let section = OKTableViewSection(componentDisplayOption: .header(component: header))
You can set a static height of a section component by using either a CGFloat value or closure:
header.set(height: .height, 55)
header.set(height: .height) { user -> CGFloat in
return user.username == "dylan" ? 100 : 75
}
header.set(height: .estimatedHeight, 125)
In the event a height is not provided for a section component, the liaison will assume the supplementary view is self sizing and return a .height
of UITableView.automaticDimension
. Make sure you provide an .estimatedHeight
to avoid layout complications.
The OKTableViewSectionComponent
views can be customized using func set(command: OKTableViewSectionComponentCommand, with closure: @escaping (View, Model, Int) -> Void)
at all the following lifecycle events:
- configuration
- didEndDisplaying
- willDisplay
header.set(command: .configuration) { view, user, section in
view.textLabel?.text = user.username
}
header.set(command: .willDisplay) { view, user, section in
print("Header: \(view) will display for Section: \(section) with User: \(user)")
}
Rows
class OKTableViewRow<Cell: UITableViewCell, Model>
To add a row for a section, create an instance of OKTableViewRow
and pass it to the initializer for a OKTableViewSection
or if the row is added after instantiation you can perform that action via the liaison:
let row = OKTableViewRow<RowTableViewCell, RowModel>(model: RowModel(type: .small))
let section = OKTableViewSection(rows: [row])
liaison.append(section: section)
or
let row = OKTableViewRow<RowTableViewCell, RowModel>(model: RowModel(type: .small))
let section = OKTableViewSection()
liaison.append(section: section)
liaison.append(row: row)
OKTableViewRow
heights are similarly configured to OKTableViewSection
:
row.set(height: .height, 300)
row.set(height: .estimatedHeight, 210)
row.set(height: .height) { model -> CGFloat in
switch model.type {
case .large:
return 400
case .medium:
return 200
case .small:
return 50
}
}
In the event a height is not provided, the liaison will assume the cell is self sizing and return UITableView.automaticDimension
.
The OKTableViewRow
can be customized using func set(command: OKTableViewRowCommand, with closure: @escaping (Cell, Model, IndexPath) -> Void)
at all the following lifecycle events:
- accessoryButtonTapped
- configuration
- delete
- didDeselect
- didEndDisplaying
- didEndEditing
- didHighlight
- didSelect
- didUnhighlight
- insert
- move
- reload
- willBeginEditing
- willDeselect
- willDisplay
- willSelect
row.set(command: .configuration) { cell, model, indexPath in
cell.label.text = model.text
cell.label.font = .systemFont(ofSize: 13)
cell.contentView.backgroundColor = .blue
cell.selectionStyle = .none
}
row.set(command: .didSelect) { cell, model, indexPath in
print("Cell: \(cell) selected at IndexPath: \(indexPath)")
}
OKTableViewRow
can also utilize UITableViewDataSourcePrefetching
by using func set(prefetchCommand: OKTableViewPrefetchCommand, with closure: @escaping (Model, IndexPath) -> Void)
row.set(prefetchCommand: .prefetch) { model, indexPath in
model.downloadImage()
}
row.set(prefetchCommand: .cancel) { model, indexPath in
model.cancelImageDownload()
}
Cell/View Registration
OKTableViewLiaison
handles cell & view registration for UITableView
view reuse on your behalf utilizing your sections/rows OKTableViewRegistrationType<T>
.
OKTableViewRegistrationType
tells the liaison whether your reusable view should be registered via a Nib
or Class
.
By default, OKTableViewRow
is instantiated with OKTableViewRegistrationType<Cell>.defaultClassType
.
OKTableViewSection
supplementary view registration is encapsulated by itsOKTableViewSectionComponentDisplayOption
. By default, OKTableViewSection
componentDisplayOption
is instantiated with .none
.
Pagination
OKTableViewLiaison
comes equipped to handle your pagination needs. To configure the liaison for pagination, simply set its paginationDelegate
to an instance of OKTableViewLiaisonPaginationDelegate
.
OKTableViewLiaisonPaginationDelegate
declares three methods:
func isPaginationEnabled() -> Bool
, notifies the liaison if it should show the pagination spinner when the user scrolls past the last cell.
func paginationStarted(indexPath: IndexPath)
, passes through the indexPath of the last OKTableViewRow
managed by the liaison.
func paginationEnded(indexPath: IndexPath)
, passes the indexPath of the first new OKTableViewRow
appended by the liaison.
To update the liaisons results during pagination, simply use append(sections: [OKAnyTableViewSection])
or func append(rows: [OKAnyTableViewRow])
and the liaison will automatically handle the removal of the pagination spinner.
To use a custom pagination spinner, you can pass an instance OKAnyTableViewRow
during the initialization of your OKTableViewLiaison
. By default it uses OKPaginationTableViewRow
provided by the framework.
Tips & Tricks
Because OKTableViewSection
and OKTableViewRow
utilize generic types and manage view/cell type registration, instantiating multiple different configurations of sections and rows can get verbose. Creating a subclass or utilizing a factory to create your various OKTableViewRow
/OKTableViewSectionComponent
types may be useful.
final class TextTableViewRow: OKTableViewRow<PostTextTableViewCell, String> {
init(text: String) {
super.init(text,
registrationType: .defaultNibType)
}
}
static func imageRow(with image: UIImage) -> AnyTableViewRow {
let row = OKTableViewRow<ImageTableViewCell, UIImage>(image)
row.set(height: .height, 225)
row.set(command: .configuration) { cell, image, indexPath in
cell.contentImageView.image = image
cell.contentImageView.contentMode = .scaleAspectFill
}
return row
}
Contribution
OKTableViewLiaison
is a framework in its infancy. It's implementation is not perfect. Not all UITableView
functionality has been liaised
just yet. If you would like to help bring OKTableViewLiaison
to a better place, feel free to make a pull request.
Authors
✌️ Dylan Shine, [email protected]
License
OKTableViewLiaison is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the OKTableViewLiaison README section above
are relevant to that project's source code only.