This commit is contained in:
relikd
2020-03-19 00:05:43 +01:00
parent 188a130825
commit 126da073a5
53 changed files with 2476 additions and 593 deletions

View File

@@ -0,0 +1,40 @@
import UIKit
class TVCFilter: UITableViewController, EditActionsRemove {
var currentFilter: FilterOptions = .none
private var dataSource: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 10.0, *) {
tableView.refreshControl = UIRefreshControl(call: #selector(reloadDataSource), on: self)
}
NotifyFilterChanged.observe(call: #selector(reloadDataSource), on: self)
reloadDataSource()
}
@objc func reloadDataSource() {
dataSource = DBWrp.dataF_list(currentFilter)
tableView.reloadData()
}
// MARK: - Table View Delegate
override func tableView(_ _: UITableView, numberOfRowsInSection _: Int) -> Int { dataSource.count }
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DomainFilterCell")!
cell.textLabel?.text = dataSource[indexPath.row]
return cell
}
// MARK: - Editing
func editableRowCallback(_ index: IndexPath, _ action: RowAction, _ userInfo: Any?) -> Bool {
let domain = self.dataSource[index.row]
DBWrp.updateFilter(domain, remove: currentFilter)
self.dataSource.remove(at: index.row)
self.tableView.deleteRows(at: [index], with: .automatic)
return true
}
}