forked from confirmedcode/Lockdown-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockLogViewController.swift
More file actions
70 lines (56 loc) · 2.08 KB
/
Copy pathBlockLogViewController.swift
File metadata and controls
70 lines (56 loc) · 2.08 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// BlockLogViewController.swift
// Lockdown
//
// Copyright © 2019 Confirmed Inc. All rights reserved.
//
import UIKit
class BlockLogViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dayLogTime.count;
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "blockLogCell", for: indexPath) as! BlockLogCell
cell.time.text = dayLogTime[indexPath.row];
cell.logHost?.text = dayLogHost[indexPath.row];
return cell
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.refreshControl = refreshControl
refreshControl.addTarget(self, action: #selector(self.refreshData(_:)), for: .valueChanged);
refreshData(self);
}
@objc func refreshData(_ sender: Any) {
let kDayLogs = "LockdownDayLogs";
dayLogTime = [];
dayLogHost = [];
if var dayLogs = defaults.array(forKey: kDayLogs) as? [String] {
dayLogs = dayLogs.reversed();
for log in dayLogs {
let sp = log.components(separatedBy: "_");
if sp.count == 2 {
dayLogTime.append(sp[0]);
dayLogHost.append(sp[1]);
}
}
}
tableView.reloadData();
DispatchQueue.main.async {
self.refreshControl.endRefreshing()
}
}
@IBAction func dismiss() {
self.dismiss(animated: true, completion: {})
}
var dayLogTime: [String] = [];
var dayLogHost: [String] = [];
private let refreshControl = UIRefreshControl()
@IBOutlet weak var tableView: UITableView!
}