Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import UIKit
  2. import AppComponents
  3.  
  4. class ViewController: UITableViewController {
  5.  
  6. override func viewDidLoad() {
  7. super.viewDidLoad()
  8. title = "Categorias de investimento"
  9. }
  10.  
  11. override func numberOfSections(in tableView: UITableView) -> Int {
  12. return 1
  13. }
  14.  
  15. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  16. return Service.investments.count
  17. }
  18.  
  19. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  20. let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
  21. let component = createComponent(with: Service.investments[indexPath.row])
  22. component.pinToBounds(of: cell)
  23. return cell
  24. }
  25.  
  26. private func createComponent(with investment: Investment) -> CardComponent {
  27. let component: CardComponent = UIView.componentFromNib()
  28. let dto = CardComponent.DTO(title: investment.name, content: investment.description, isFavorite: false)
  29. component.render(.build(dto))
  30. return component
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement