Boom 1.1.0

Boom 1.1.0

Maintained by Meniny.



Boom 1.1.0

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

10.2+

Language

Swift

5+

📲 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)