Last active
April 25, 2020 11:15
-
-
Save fjtrujy/fdd67e7d8a3df8bf6c0ddb174e383a35 to your computer and use it in GitHub Desktop.
WhatsappStateModule - Snapshot Testing
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
| import FTMTableSectionModules | |
| class WhatsappStateModule: TableSectionModule { | |
| private var decorator : WhatsappStateModuleDecorator? | |
| func configure(decorator : WhatsappStateModuleDecorator) { | |
| self.decorator = decorator | |
| createRows() | |
| } | |
| override func registerClassForHeadersFooters() -> [AnyClass] { | |
| return super.registerClassForHeadersFooters() + [ | |
| UITableViewHeaderFooterView.classForCoder(), | |
| ] | |
| } | |
| override func registerNibsForCells() -> [AnyClass] { | |
| return super.registerNibsForCells() + [ | |
| WhatsappStatusCell.classForCoder(), | |
| ] | |
| } | |
| override func createRows() { | |
| super.createRows() | |
| if (decorator != nil) { | |
| rows = rows + decorator!.rows! | |
| } | |
| } | |
| override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { | |
| return 25 | |
| } | |
| override func tableView(_ tableView: UITableView, heightForRowAtIndexPath indexPath: IndexPath) -> CGFloat { | |
| return 70; | |
| } | |
| override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { | |
| return 25; | |
| } | |
| override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | |
| let identifier = String(describing: UITableViewHeaderFooterView.self) | |
| let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: identifier) | |
| header?.textLabel?.text = decorator?.headerTitle?.uppercased() | |
| return header | |
| } | |
| override func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell { | |
| let identifier = String(describing: WhatsappStatusCell.self) | |
| let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) | |
| if let statusCell = cell as? WhatsappStatusCell, | |
| let decorator = decorator?.rows?[indexPath.row] { | |
| statusCell.configure(decorator: decorator) | |
| } | |
| return cell | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment