Blame view

HDFwear/Setting/BackgroundVC.swift 4.62 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
  //
  //  BackgroundVC.swift
  //  HDFwear
  //
  //  Created by yangbin on 2022/4/1.
  //
  
  import UIKit
  
  class BackgroundVC: UIViewController {
      @IBOutlet weak var tableView: UITableView!
      let settingArray: [[String]] = [["iPhone", "三星", "华为", "小米", "OPPO", "vivo"], ["iOS", "Android"]]
      
      override func viewDidLoad() {
          super.viewDidLoad()
          title = LocString("后台保护")
          
          tableView.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom: 10, right: 0)
          tableView.register(UINib.init(nibName: "SettingCell3", bundle: Bundle.main), forCellReuseIdentifier: "SettingCell3")
  
          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 BackgroundVC: UITableViewDelegate, UITableViewDataSource {
      
      func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
          return 30
      }
      
      func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
          let view = UIView()
          view.backgroundColor = .clear
          let label = UILabel()
          label.font = RegularFont(14)
          label.numberOfLines = 0
          if section == 0 {
              label.text = LocString("系统运行保护权限")
          } else {
              label.text = LocString("APP使用权限")
          }
          view.addSubview(label)
          label.snp.makeConstraints { make in
              make.left.equalToSuperview().offset(12)
              make.right.equalToSuperview().offset(-10)
              make.top.equalToSuperview().offset(5)
          }
          return view
      }
      
      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
          if section == 0 {
              label.text = LocString("为了给你提供更加准确稳定的服务,不影响APP和设备正常使用,请你务必打开以上系统!")
          } else {
              label.text = LocString("为了不影响APP和设备正常使用,请你务必同意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 75
      }
      func numberOfSections(in tableView: UITableView) -> Int {
          return settingArray.count
      }
      
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
          return settingArray[section].count
      }
      
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "SettingCell3", for: indexPath) as! SettingCell3
cf12a6bb   daifengyi   feat:remind page UI
101
102
  //        cell.widthLayout.constant = 30
  //        cell.setImageView.image = UIImage(named: settingArray[indexPath.section][indexPath.row])
f2cf74c7   yangbin   1.0.20(4)
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
128
          cell.titleLabel.font = BoldFont(14)
          cell.titleLabel.text = " " + LocString(settingArray[indexPath.section][indexPath.row])
          return cell
          
      }
      
  
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          let cell = tableView.cellForRow(at: indexPath)
          cell?.isSelected = false
          let brand = settingArray[indexPath.section][indexPath.row]
          if indexPath.section == 0 {
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "BackgroundProtectionVC") as! BackgroundProtectionVC
              vc.brand = brand
              navigationController?.pushViewController(vc, animated: true)
          } else {
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "PermissionSettingVC") as! PermissionSettingVC
              vc.brand = brand
              vc.permission = "APP使用权限"
              navigationController?.pushViewController(vc, animated: true)
          }
         
      }
      
  
  }