An open API service indexing awesome lists of open source software.

https://github.com/meniny/boom

🎢 UITableView and UICollectionView manager with efficient, declarative and type-safe approach.
https://github.com/meniny/boom

Last synced: over 1 year ago
JSON representation

🎢 UITableView and UICollectionView manager with efficient, declarative and type-safe approach.

Awesome Lists containing this project

README

          

:name: Boom
:author: Elias Abel
:author_esc: Elias%20Abel
:mail: admin@meniny.cn
:desc: an UITableView and UICollectionView manager with efficient, declarative and type-safe approach
:icon: {name}.png
:version: 1.1.0
:na: N/A
:ios: 9.0
:macos: {na}
:watchos: {na}
:tvos: {na}
:linux: {na}
:xcode: 10.2
:swift: 5
:license: MIT
:sep: %20%7C%20
:platform: iOS
// :toc: left
:toclevels: 6
:toc-title: TOC
:source-highlighter: highlightjs
// :source-highlighter: pygments
= Meet `{name}`
{author} <{mail}>
v{version}, 2019-04-21

[subs="attributes"]
++++


{name}



Author
EMail
MIT


Version
Platforms
Swift


Build Passing
Cocoapods
Carthage
SPM


++++

:toc:

== 🏵 Introduction

**{name}** is {desc}.

== 📋 Requirements

[%header]
|===
2+^m|Type 1+^m|Requirement

1.5+^.^|Platform ^|iOS ^|{ios}+
^|macOS ^|{macos}
^|tvOS ^|{tvos}
^|watchOS ^|{watchos}
^|Linux ^|{linux}

^|IDE ^|Xcode ^| {xcode}+
^|Language ^|Swift ^| {swift}+
|===

== 📲 Installation

=== CocoaPods

`{name}` is available on link:https://cocoapods.org[CocoaPods].

[source, ruby, subs="verbatim,attributes"]
----
use_frameworks!
pod '{name}'
----

=== Manually

Copy all files in the `{name}` directory into your project.

== 🛌 Dependency

{na}

== ❤️ Contribution

You are welcome to fork and submit pull requests.

== 🔖 License

`{name}` is open-sourced software, licensed under the link:./LICENSE.md[`{license}`] license.

== 🔫 Usage

=== Prepare Model

For example:

[source, swift, subs="verbatim,attributes"]
----
import {name}

// 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:

[source, swift, subs="verbatim,attributes"]
----
import {name}

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

[source, swift, subs="verbatim,attributes"]
----
let adapter = TableAdapter()
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

[source, swift, subs="verbatim,attributes"]
----
let dataSet: [CellData] = [...]

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

// optional: Footer
let footer = TableSectionView()
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

[source, swift, subs="verbatim,attributes"]
----
tableView.manager.rowHeight = .autoLayout(estimated: 100)
----

=== Reload

[source, swift, subs="verbatim,attributes"]
----
tableView.manager.reloadData(after: { _ in
return TableReloadAnimations.default()
}, onEnd: nil)
----