Skip to content
🎒 UITableView and UICollectionView manager with efficient, declarative and type-safe approach.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets
Boom
Sample
.gitignore
Boom.podspec
LICENSE.md
README.adoc
_config.yml

README.adoc

Meet Boom

Boom

Author EMail MIT
Version Platforms Swift
Build Passing Cocoapods Carthage SPM

🏡 Introduction

Boom is an UITableView and UICollectionView manager with efficient, declarative and type-safe approach.

πŸ“‹ Requirements

Type Requirement

Platform

iOS

9.0+

macOS

N/A

tvOS

N/A

watchOS

N/A

Linux

N/A

IDE

Xcode

9.3+

Language

Swift

4.1+

πŸ“² Installation

CocoaPods

Boom is available on CocoaPods.

use_frameworks!
pod 'Boom'

Manually

Copy all files in the Boom directory into your project.

πŸ›Œ Dependency

N/A

❀️ Contribution

You are welcome to fork and submit pull requests.

πŸ”– License

Boom is open-sourced software, licensed under the MIT license.

πŸ”« Usage

Prepare Model

For example:

import Boom

// Confirm to BoomModel protocol
struct CellData: Equatable, Hashable, BoomModel {
    var identifier: Int {
        return id.hashValue
    }

    let id: String = NSUUID().uuidString

    var avatar: UIImage
    var title: String
    var detail: String?

    init(avatar: UIImage, title: String, detail: String?) {
        self.avatar = avatar
        self.title = title
        self.detail = detail
    }
}

Prepare Cell

For example:

import Boom

class ConversationTableViewCell: UITableViewCell {

    @IBOutlet weak var titleLbale: UILabel!
    @IBOutlet weak var avatarImageView: UIImageView!
    @IBOutlet weak var subtitleLabel: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()

        titleLbale.font = UIFont.boldSystemFont(ofSize: 20)
        titleLbale.textColor = UIColor.darkText

        subtitleLabel.font = UIFont.systemFont(ofSize: 15)
        subtitleLabel.textColor = UIColor.lightGray
    }

}

// Confirm to BoomCell protocol
extension ConversationTableViewCell {
    static var reuseIdentifier: String {
        return "ConversationTableViewCell"
    }

    static var registerAsClass: Bool {
        return false
    }
}

Generate Adapter

let adapter = TableAdapter<CellData, ConversationTableViewCell>()
adapter.on.dequeue = { ctx in
    ctx.cell?.avatarImageView.image = ctx.model.avatar
    ctx.cell?.titleLbale?.text = ctx.model.title
    ctx.cell?.subtitleLabel?.text = ctx.model.detail
}
adapter.on.tap = { ctx in
    print("Tapped on \(ctx.model.identifier)")
    return .deselectAnimated
}
tableView.manager.register(adapter: adapter)

Generate Sections

let dataSet: [CellData] = [...]

// optional: Header
let header = TableSectionView<TableExampleHeaderView>()
header.on.height = { _ in
    return 50
}

// optional: Footer
let footer = TableSectionView<TableFooterExample>()
footer.on.height = { _ in
    return 30
}
footer.on.dequeue = { ctx in
    ctx.view?.titleLabel?.text = "\(dataSet.count) Data"
}

// generate
let section = TableSection(headerView: header, footerView: footer, models: dataSet)

// add to manager
tableView.manager.add(section: section)

Setup Height for Rows

tableView.manager.rowHeight = .autoLayout(estimated: 100)

Reload

tableView.manager.reloadData(after: { _ in
    return TableReloadAnimations.default()
}, onEnd: nil)
You can’t perform that action at this time.