Makes Swift 4 tables much simpler and declarative, like React, making it simple to add and remove sections and rows dynamically.
Simply add pod 'SwiftyTables' to your Podfile. Run pod setup if you get the error Unable to find a specification for SwiftyTables.
No more crazy switches and monster UITableViewDelegates methods! Each cell's state is declared in one place.
Forked off of Shopify's FunctionalTableData.
I've added the following,
🌟 A easy to use generic CarouselCell that it is a CellConfigType (i.e. a FunctionalTableData cell), containing a UICollectionView with a single type of UICollectionViewCell.
🌟 Sample cells and view controllers demonstrating how to use FunctionalTableData.
🌟 Custom cells, headers, and CarouselItemCells created can be created programically or with nibs. Simply conform the UIVIew/UICollectionViewCell to the protocol NibView/CarouselItemNibView.
🌟 Estimated cell, section, and header heights.
FunctionalTableData demo with multiple types of cells.
FunctionalTableData demo where cells can be inserted and removed when you tap ➕ or 🗑.
CollectionTableData demo where cells can be inserted and removed when you tap ➕ or 🗑.
A generic FunctionalTableData cell with a horizontal scrolling, or vertical non-scrolling UICollectionView.
Each CarouselCell takes a single CarouselItemCell type.
Each CarouselItemCell is a UICollectionViewCell, and is associated with a ItemModel type that it uses to calculate its size, and configure its views.
protocol CarouselItemCell where Self: UICollectionViewCell {
associatedtype ItemModel: Equatable'
static func sizeForItem(model: ItemModel, in collectionView: UICollectionView) -> CGSize
func configure(model: ItemModel)
static func scrollDirection() -> UICollectionViewScrollDirection
}A programically created scrolling horizontal CarouselCell.
The ItemModel is a UIColor, which sets the CarouselItemColorTilesCell's color.
let cell = CarouselColorTilesCell(
key: "colorTilesCell",
state: CarouselState<CarouselItemColorTilesCell>(
itemModels: [.red, .blue, .purple, .yellow, .green, .orange],
collectionHeight: 120,
didSelectItemCell: { indexPath in
print("Did tap item \(indexPath.row)")})
)A programically created non-scrolling vertical CarouselCell.
let fourGridCell = resizableCell(key: "fourGridCell", color: .purple, height: 100, itemsPerRow: [1, 3])
let fiveGridCell = resizableCell(key: "fiveGridCell", color: .green, height: 100, itemsPerRow: [2, 3])
let tenGridCell = resizableCell(key: "tenGridCell", color: .blue, height: 100, itemsPerRow: [4, 3, 2, 1])A scrolling horizontal CarouselCell created using a storyboard.
let dogeItemState = CarouselItemDetailState(image: #imageLiteral(resourceName: "finedog"), title: "Doge", subtitle: "This is fine")
let dogeCarousel = CarouselDetailCell(
key: "dogeCarousel",
state: CarouselState<CarouselItemDetailCell>(
itemModels: Array(repeating: dogeItemState, count: 20),
collectionHeight: 220,
didSelectItemCell: { index in
print("Did select doge at index \(index)") }))A CellConfigType created with storyboard.
let detailCell = DetailCell(
key: "detailCell",
state: DetailState(
image: #imageLiteral(resourceName: "finedog"),
title: "Sample Title",
subtitle: "This is the subs on a detail cell"))A programically created CellConfigType.
let labelCell = LabelCell(
key: "labelCell",
actions: CellActions(selectionAction: { _ in
print("label cell tapped")
return .deselected
}),
state: LabelState(text: "This is a LabelCell"))



