-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListView.swift
52 lines (39 loc) · 1.31 KB
/
ListView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// ListView.swift
// ToDo-App
//
// Created by Александр Ермаков on 13.05.2022.
//
import Foundation
import UIKit
class ListView: UIView, UITableViewDelegate, UITableViewDataSource {
// MARK: -
// MARK: IBActions
@IBAction func addButtonPressed(_ sender: UIBarButtonItem) {
self.controller?.addTask()
}
// MARK: -
// MARK: IBOutlets
@IBOutlet var navigationBar: UINavigationBar?
@IBOutlet var tableView: UITableView?
// MARK: -
// MARK: Public variables
var controller: ViewController?
// MARK: -
// MARK: Public functions
func prepare(with controller: ViewController) {
self.controller = controller
self.backgroundColor = .systemGray3
}
// MARK: -
// MARK: UITableViewDataSource, UITableViewDelegate
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let controller = self.controller else { return 0 }
return controller.list.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
cell.textLabel?.text = self.controller?.list[indexPath.row]
return cell
}
}