Blame view

Twear/Setting(设置)/RemindViewController.swift 4.4 KB
75d24c15   yangbin   123
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
  //
  //  RemindViewController.swift
  //  Twear
  //
  //  Created by yangbin on 2021/12/24.
  //
  
  import UIKit
  
  class RemindViewController: UIViewController {
      
      @IBOutlet weak var tableView: UITableView!
  
      var device = CurDevice
      private let remindArray: [String] = ["来电提醒", "短信提醒", "健康提醒", "应用提醒", "闹钟提醒"]
      
      override func viewWillAppear(_ animated: Bool) {
          super.viewWillAppear(animated)
          device = CurDevice
          tableView.reloadData()
      }
      
      override func viewDidLoad() {
          super.viewDidLoad()
          title = LocString("提醒功能")
          
          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.
      }
  }
  
  extension RemindViewController: UITableViewDelegate, UITableViewDataSource {
      func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
          return 5
      }
  
      
      func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
          let view = UIView()
          view.backgroundColor = UIColor.rgbColorFromHex(0xF2F2F2)
          return view
      }
      
      func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
          return 0.5
      }
      
      func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
          return 50
      }
      
      func numberOfSections(in tableView: UITableView) -> Int {
          return remindArray.count
      }
      
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
          return 1
      }
      
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "SettingCell3", for: indexPath) as! SettingCell3
          
          let remindText = LocString(remindArray[indexPath.section])
          cell.titleLabel.text = remindText
          cell.setImageView.image = UIImage(named: remindArray[indexPath.section])
          
          
          switch remindText {
          case "闹钟提醒":
              var isOn: Bool = false
              for alarmClock in device.alarmClocks {
                  if alarmClock.isOn {
                      isOn = true
                  }
              }
              cell.detailLabel.text = isOn ? "已开启" : "未开启"
          case "来电提醒":
              cell.detailLabel.text = device.push.call ? "已开启" : "未开启"
          case "短信提醒":
              cell.detailLabel.text = device.push.sms ? "已开启" : "未开启"
          case "应用提醒":
              cell.detailLabel.text = device.push.app ? "已开启" : "未开启"
          case "健康提醒":
              cell.detailLabel.text = (device.drink.isOn || device.disturb.isOn) ? "已开启" : "未开启"
          default:
              break
          }
  
          
          return cell
      }
      
  
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          let cell = tableView.cellForRow(at: indexPath) as! SettingCell3
          cell.isSelected = false
  //        let device = CurDevice
          switch remindArray[indexPath.section] {
          case "来电提醒":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "CallRemindVC")
              navigationController?.pushViewController(vc, animated: true)
          case "短信提醒":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "SMSRemindVC")
              navigationController?.pushViewController(vc, animated: true)
          case "应用提醒":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "APPRemindVC")
              navigationController?.pushViewController(vc, animated: true)
          case "健康提醒":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "HealthRemindVC")
              navigationController?.pushViewController(vc, animated: true)
          case "闹钟提醒":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "AlarmClockVC")
              navigationController?.pushViewController(vc, animated: true)
          default:
              break
          }
      }
  }