Blame view

HDFwear/Setting/BackgroundProtectionVC.swift 4.56 KB
f2cf74c7   yangbin   1.0.20(4)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  //
  //  BackgroundProtectionVC.swift
  //  HDFwear
  //
  //  Created by yangbin on 2022/4/1.
  //
  
  import UIKit
  import SnapKit
  
  class BackgroundProtectionVC: UIViewController {
  
      @IBOutlet weak var tableView: UITableView!
      var settingArray = ["后台APP刷新", "应用权限设置"]
      
      @IBOutlet weak var titleLabel: UILabel!
      
      var brand: String = ""
      
      override func viewDidLoad() {
          super.viewDidLoad()
          title = LocString("后台保护")
          titleLabel.text = LocString(brand) + LocString("系统运行保护权限")
          switch brand {
          case "iPhone":
              settingArray = ["后台APP刷新", "应用权限设置"]
          case "三星":
              if AppSettings.shared.language == .Chinese {
                  settingArray = ["耗电保护", "后台使用限制", "清理保护", "应用权限", "自启动权限"]
              } else {
                  settingArray = ["耗电保护", "后台使用限制", "清理保护", "应用权限"]
              }
          case "华为":
              settingArray = ["耗电保护", "清理保护", "消息通知权限", "应用权限", "自启动权限"]
          case "OPPO":
              settingArray = ["耗电保护", "清理保护", "消息通知权限", "应用权限", "自启动权限"]
          case "vivo":
              settingArray = ["耗电保护", "清理保护", "消息通知权限", "应用权限", "自启动权限"]
          case "小米":
              settingArray = ["耗电保护", "清理保护", "消息通知权限", "应用权限", "自启动权限"]
          default:
              break
          }
          
          
          tableView.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 10, right: 0)
          tableView.register(UINib.init(nibName: "SettingCell4", bundle: Bundle.main), forCellReuseIdentifier: "SettingCell4")
        
          tableView.tableFooterView = UIView(frame: CGRect.zero)
          // Do any additional setup after loading the view.
      }
      
  
      /*
      // MARK: - Navigation
  
      // In a storyboard-based application, you will often want to do a little preparation before navigation
      override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
          // Get the new view controller using segue.destination.
          // Pass the selected object to the new view controller.
      }
      */
  
  }
  
  
  
  
  
  extension BackgroundProtectionVC: UITableViewDelegate, UITableViewDataSource {
      
      
      
      func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
          let view = UIView()
          view.backgroundColor = .clear
          let label = UILabel()
          label.font = RegularFont(11)
          label.textColor = UIColor.rgbColorFromHex(0xFF0000)
          label.numberOfLines = 0
          label.text = LocString("为了给你提供更加准确稳定的服务,不影响APP和设备正常使用,请你务必打开以上系统!")
          view.addSubview(label)
          label.snp.makeConstraints { make in
              make.left.equalToSuperview().offset(12)
              make.right.equalToSuperview().offset(-30)
              make.top.equalToSuperview().offset(5)
          }
          return view
      }
      
      func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
          return 50
      }
      
      
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
          return settingArray.count
      }
      
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "SettingCell4", for: indexPath) as! SettingCell4
          cell.titleLabel.font = BoldFont(14)
          cell.titleLabel.text = LocString(settingArray[indexPath.row])
          return cell
          
      }
      
  
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          let cell = tableView.cellForRow(at: indexPath)
          cell?.isSelected = false
  //        switch settingArray[indexPath.row] {
  //        case "后台APP刷新":
  //            let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "BackgroundRefreshVC")
  //            navigationController?.pushViewController(vc, animated: true)
  //        case "应用权限设置":
          let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "PermissionSettingVC") as! PermissionSettingVC
          vc.brand = brand
          vc.permission = settingArray[indexPath.row]
              navigationController?.pushViewController(vc, animated: true)
  //        default:
  //            break
  //        }
      }
      
  
  }