// // EPBaseListViewController.swift // YuMi // // A lightweight table-view base class used by EP Message subpages. // import UIKit import SnapKit class EPBaseListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { let tableView = UITableView(frame: .zero, style: .plain) var itemsCount: Int = 0 { didSet { tableView.reloadData() } } override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor(named: "ep.background.dark") ?? UIColor.black.withAlphaComponent(0.9) tableView.backgroundColor = .clear tableView.separatorStyle = .none tableView.showsVerticalScrollIndicator = false tableView.dataSource = self tableView.delegate = self tableView.rowHeight = 72 tableView.contentInsetAdjustmentBehavior = .never tableView.keyboardDismissMode = .onDrag tableView.register(Cell.self, forCellReuseIdentifier: "cell") view.addSubview(tableView) tableView.snp.makeConstraints { make in make.edges.equalTo(view.safeAreaLayoutGuide) } } // MARK: - UITableViewDataSource func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return itemsCount } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! Cell cell.backgroundColor = .clear return cell } // MARK: - Helpers func simulateItems(_ count: Int) { itemsCount = count } }