Created
April 21, 2021 22:54
-
-
Save mhijack/59d3b052fdef1f6acc60f384da96f895 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmptyTableViewDataSource: NSObject, UITableViewDataSource { | |
let identifier: String | |
let emptyModel: EmptyTableViewCellModel | |
let cellConfigurator: EmptyTableViewCellConfigurator | |
init(identifier: String = "empty-table-view-cell", | |
emptyModel: EmptyTableViewCellModel = EmptyTableViewCellModel(), | |
cellConfigurator: EmptyTableViewCellConfigurator = PlainEmptyTableViewCellConfigurator()) { | |
self.identifier = identifier | |
self.emptyModel = emptyModel | |
self.cellConfigurator = cellConfigurator | |
super.init() | |
} | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return 1 | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
guard let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as? EmptyTableViewCell else { return EmptyTableViewCell() } | |
cellConfigurator.configure(cell: cell, forDisplaying: emptyModel) | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment