All Projects → devxoul → Reusablekit

devxoul / Reusablekit

Licence: mit
Generic reusables for UICollectionView and UITableView

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Reusablekit

Binary
Generic and fast binary serializer for Go
Stars: ✭ 86 (-33.85%)
Mutual labels:  generic
Feeds For Ios Developer
A list of rss feeds for iOS developers
Stars: ✭ 100 (-23.08%)
Mutual labels:  cocoa
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+1270.77%)
Mutual labels:  cocoa
Xuikit
📦 XUIKIt is a UI framework for macOS, it extends a lot of methods similar to UIKit.
Stars: ✭ 90 (-30.77%)
Mutual labels:  cocoa
Generic Auto Updater
Generic Auto-Updater: a robust, user-friendly, clean and efficient Auto-Updater to maintain any client patched.
Stars: ✭ 95 (-26.92%)
Mutual labels:  generic
Sbplayerclient
支持全格式的mac版视频播放器
Stars: ✭ 110 (-15.38%)
Mutual labels:  cocoa
Macdown
Open source Markdown editor for macOS.
Stars: ✭ 8,855 (+6711.54%)
Mutual labels:  cocoa
Genericdatasource
A generic small reusable components for data source implementation for UITableView/UICollectionView in Swift.
Stars: ✭ 127 (-2.31%)
Mutual labels:  generic
Scroll
Scroll - making scrolling through buffers fun since 2016
Stars: ✭ 100 (-23.08%)
Mutual labels:  generic
Macassistant
Google Assistant for macOS!
Stars: ✭ 1,564 (+1103.08%)
Mutual labels:  cocoa
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+902.31%)
Mutual labels:  cocoa
Goreuse
Generic Code for Go
Stars: ✭ 93 (-28.46%)
Mutual labels:  generic
Articles Zh Hans
Articles for NSHipster.cn
Stars: ✭ 113 (-13.08%)
Mutual labels:  cocoa
Nytl
Modern C++ generic header-only template library.
Stars: ✭ 87 (-33.08%)
Mutual labels:  generic
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (-3.85%)
Mutual labels:  cocoa
Openquickly
A custom 'open quickly' window that imitates macOS' Spotlight
Stars: ✭ 78 (-40%)
Mutual labels:  cocoa
Web Client
Generic Linked Data browser and UX component framework. Apache license.
Stars: ✭ 105 (-19.23%)
Mutual labels:  generic
Alternativeicon Example
😱 Change your iOS application's icon programmatically since iOS 10.3
Stars: ✭ 129 (-0.77%)
Mutual labels:  cocoa
Daterangepicker
The best (?) date range picker control for OS X.
Stars: ✭ 126 (-3.08%)
Mutual labels:  cocoa
Typescript Tuple
Generics to work with tuples in TypeScript
Stars: ✭ 118 (-9.23%)
Mutual labels:  generic

ReusableKit

Swift CocoaPods Build Status Codecov

Generic reusables for Cocoa. Currently supports UITableView and UICollectionView.

At a Glance

Before 🤢

collectionView.register(UserCell.self, forCellWithReuseIdentifier: "userCell")
collectionView.dequeueReusableCell(withReuseIdentifier: "userCell", for: indexPath) as! UserCell
  1. A hard-coded string identifier can cause a human error.
  2. A force downcasting should be avoided.

After 😊

let reusableUserCell = ReusableCell<UserCell>()
collectionView.register(reusableUserCell)
collectionView.dequeue(reusableUserCell) // UserCell
  1. A string identifier is generated automatically using UUID and stored in the struct.
  2. A generic can ensure the type of the dequeued cell statically.

Example Usage

It is recommended to define reusable types as a static constants in an enum or a struct.

UITableView

// 1. define
enum Reusable {
  static let headerView = ReusableCell<SectionHeaderView>()
  static let userCell = ReusableCell<UserCell>()
}

// 2. register
tableView.register(Reusable.headerView)
tableView.register(Reusable.userCell)

// 3. dequeue
tableView.dequeue(Reusable.headerView, for: indexPath)
tableView.dequeue(Reusable.userCell, for: indexPath)

UICollectionView

// 1. define
enum Reusable {
  static let headerView = ReusableCell<SectionHeaderView>()
  static let photoCell = ReusableCell<PhotoCell>()
}

// 2. register
collection.register(Reusable.headerView, kind: .header)
collection.register(Reusable.photoCell)

// 3. dequeue
collection.dequeue(Reusable.headerView, kind: .header, for: indexPath)
collection.dequeue(Reusable.photoCell, for: indexPath)

RxSwift Extension

ReusableKit supports a RxSwift extension.

users // Observable<[String]>
  .bind(to: collectionView.rx.items(Reusable.userCell)) { i, user, cell in
    cell.user = user
  }

Contrubiting

Pull requests are welcomed 💖

In order to create Xcode project, run:

$ swift package generate-xcodeproj

Installation

  • For iOS 8+ projects with CocoaPods:

    pod 'ReusableKit'
    pod 'ReusableKit/RxSwift'  # with RxSwift extension
    

License

ReusableKit is under MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].