// // 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 // } } }