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
|
//
// 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
|
582f536d
yangbin
common:2022.1.28
|
65
66
67
68
|
let remindText = remindArray[indexPath.section]
cell.titleLabel.text = LocString(remindText)
cell.setImageView.image = UIImage(named: remindText)
cell.lineView.isHidden = true
|
75d24c15
yangbin
123
|
69
70
71
72
73
74
75
76
77
|
switch remindText {
case "闹钟提醒":
var isOn: Bool = false
for alarmClock in device.alarmClocks {
if alarmClock.isOn {
isOn = true
}
}
|
582f536d
yangbin
common:2022.1.28
|
78
|
cell.detailLabel.text = isOn ? LocString("已开启") : LocString("未开启")
|
75d24c15
yangbin
123
|
79
|
case "来电提醒":
|
582f536d
yangbin
common:2022.1.28
|
80
|
cell.detailLabel.text = device.push.call ? LocString("已开启") : LocString("未开启")
|
75d24c15
yangbin
123
|
81
|
case "短信提醒":
|
582f536d
yangbin
common:2022.1.28
|
82
|
cell.detailLabel.text = device.push.sms ? LocString("已开启") : LocString("未开启")
|
75d24c15
yangbin
123
|
83
|
case "应用提醒":
|
582f536d
yangbin
common:2022.1.28
|
84
|
cell.detailLabel.text = device.push.app ? LocString("已开启") : LocString("未开启")
|
75d24c15
yangbin
123
|
85
|
case "健康提醒":
|
582f536d
yangbin
common:2022.1.28
|
86
|
cell.detailLabel.text = (device.drink.isOn || device.sedentary.isOn) ? LocString("已开启") : LocString("未开启")
|
75d24c15
yangbin
123
|
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
|
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
}
}
}
|