Swiftpack.co - Package - blinover/ListsKit

ListsKit

Version License: MIT Platform Swift 5.0 iOS 9.0+ Swift Package Manager compatible

Intoduction

ListsKit helps you write less code and reuse cells as easily as possible. Use UICollectionView inside UITableView + Fancy click animations

Usage

Basic

import ListsKit

Create cell model and Inherit LKCellModel, setup model and use parent initializer

class ShopHeaderCellModel: LKCellModel {
	let frontImage: UIImage
	let titleText: String
	
	init(name: String, image: UIImage) {
		self.titleText = name
		self.frontImage = image
		super.init(cellIdentifier: ShopHeaderTableViewCell.cellIdentifier)
	}
}

Create UITableViewCell + .xib and Inherit LKTableViewCell, for configuring cell use func configureCell(_ cellModel: LKCellModel)

class ShopHeaderTableViewCell: LKTableViewCell {
	@IBOutlet private weak var shopImageView: UIImageView!
	@IBOutlet private weak var titleLabel: UILabel!
	
	override func configureCell(_ cellModel: LKCellModel) {
		super.configureCell(cellModel)
		guard let model = cellModel as? ShopHeaderCellModel else { return }
		shopImageView.image = model.frontImage
		titleLabel.text = model.titleText
	}  
}

Add LKTableController property in your ViewController

	private let tableController = LKTableController()

Create cell models and bind it to LKTableController cellModels property

	private func createCellModels() {
		var models = [LKCellModel](https://raw.github.com/blinover/ListsKit/blob/master/)

		let shopHeaderCell = ShopHeaderCellModel(name: shopModel.shopName, image: shopModel.headerImage)
		models.append(shopHeaderCell)

		tableController.cellModels.onNext(models)
	}

Now you can easily reuse ShopHeaderCellModel modify and safly inject in another controller.

See Example project for more information and complex examples.

Requirements

ListsKit written in Swift 5.0. Compatible with iOS 13.0+

Installation

Cocoapods

pod 'ListsKit'

Contributors

Anton Lisovoy

License

ListsKit is released under a MIT License.

Github

link
Stars: 0

Dependencies

Used By

Total: 0