Last active
August 10, 2017 05:22
-
-
Save foobra/f0a8cc1fcd3ef2081e1b6eb6cbc70e25 to your computer and use it in GitHub Desktop.
This file contains 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
extension HomePageTimelineVC: UITableViewDataSource, UITableViewDelegate { | |
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
switch viewModel.vms[indexPath.row] { | |
case let model as TimelineCellPhotoViewModel: | |
let cell = tableView.dequeueReusableCell(withIdentifier: TimelineCellPhoto.className) as? TimelineCellPhoto | |
?? TimelineCellPhoto(.timeline, style: .default, reuseIdentifier: TimelineCellPhoto.className) | |
cell.configCell(viewModel: model, vc: self) | |
return cell | |
case let model as TimelineCellVideoViewModel: | |
let cell = tableView.dequeueReusableCell(withIdentifier: TimelineVideoCell.className) as? TimelineVideoCell | |
?? TimelineVideoCell(.timeline, style: .default, reuseIdentifier: TimelineVideoCell.className) | |
cell.configCell(viewModel: model, vc: self) | |
return cell | |
default: | |
fatalError() | |
} | |
} | |
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return viewModel.vms.count | |
} | |
public func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) { | |
if let model = viewModel.vms[indexPath.row] as? TimelineCellVideoViewModel { | |
model.state.playerPauseProxy?() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment