Skip to content

ximximik/DPTableView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DPTableView

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

DPTableView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'DPTableView', :git => 'https://github.com/ximximik/DPTableView.git', :tag => '0.1.2'

Using

Firstly, needed specify type of Table View in outlet and xib/storyboard

@IBOutlet private weak var tableView: DPTableView!
Basic using
  1. Impelement in your cell DPTableViewElementCellProtocol:
public class MyElementCell: UITableViewCell, DPTableViewElementCellProtocol {
    
    public static let estimatedHeight: CGFloat = 100
    
    public func set(viewModel: MyElementCellViewModel) {
        ...
    }
}
  1. Declare somewhere observable of array of cells viewModel's:
var elementsObservable: Observable<[MyElementCellViewModel]>
  1. Bind it!
tableView.setup(cellType: MyElementCell.self, viewModels: elementsObservable)

It's work if cells prototype designed in storyboard inside table view. Reuse identifier should equal cell class name. For cells prototype designed in xib file, use function parameter isLoadFromNib

tableView.setup(cellType: MyElementCell.self, viewModels: elementsObservable, isLoadFromNib: true)
Sections

TODO

No items text

At this moment is possibly set only simple string text

tableView.noItemsText = "Data not yet loaded"
Custom actions with cells after dequeued

For perform additional setups for cell (delegate setup and etc.), use additional parameter customCellSetup:

tableView.setup(cellType: MyElementCell.self, viewModels: elementsObservable, isLoadFromNib: true) { [weak self] cell, index in
    cell.delegate = self
}

Author

ximximik, [email protected]

License

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

About

UITableView + RxSwift + DZNEmpyDataSet

Resources

License

Stars

Watchers

Forks

Packages

No packages published