|
@@ -10,6 +10,23 @@ class TSNightLightVC: TSBaseVC {
|
|
private var isOpen = false
|
|
private var isOpen = false
|
|
private var currentValue:CGFloat = 0.5
|
|
private var currentValue:CGFloat = 0.5
|
|
|
|
|
|
|
|
+
|
|
|
|
+ lazy var myTimer: TSCustomTimer = {
|
|
|
|
+ let customTimer = TSCustomTimer(interval: 1.0,repeats: true) { [weak self] in
|
|
|
|
+ guard let self = self else { return }
|
|
|
|
+
|
|
|
|
+ if setToolView.countdown <= 0{
|
|
|
|
+ stopMyTimer()//关闭定时器
|
|
|
|
+ isOpen = false
|
|
|
|
+ showToView()//退出全屏
|
|
|
|
+ }else {
|
|
|
|
+ setToolView.countdown -= 1
|
|
|
|
+ setToolView.timeLabel.text = setToolView.countdown.toHourMinuteSecondString()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return customTimer
|
|
|
|
+ }()
|
|
|
|
+
|
|
lazy var shapeView: TSLightShapeView = {
|
|
lazy var shapeView: TSLightShapeView = {
|
|
let shapeView = TSLightShapeView()
|
|
let shapeView = TSLightShapeView()
|
|
shapeView.imageNamed = "bold_roundness_shape"
|
|
shapeView.imageNamed = "bold_roundness_shape"
|
|
@@ -35,11 +52,14 @@ class TSNightLightVC: TSBaseVC {
|
|
setToolView.isHidden = true
|
|
setToolView.isHidden = true
|
|
}
|
|
}
|
|
UIDevice.keepScreenAwake()
|
|
UIDevice.keepScreenAwake()
|
|
- setToolView.myTimer.start()
|
|
|
|
|
|
+
|
|
|
|
+ if(setToolView.countdown > 0){
|
|
|
|
+ startMyTimer()
|
|
|
|
+ }
|
|
setToolView.submitBtn.setTitle("close".localized, for: .normal)
|
|
setToolView.submitBtn.setTitle("close".localized, for: .normal)
|
|
}else{
|
|
}else{
|
|
UIDevice.allowScreenSleep()
|
|
UIDevice.allowScreenSleep()
|
|
- setToolView.myTimer.stop()
|
|
|
|
|
|
+ stopMyTimer()
|
|
setToolView.submitBtn.setTitle("open".localized, for: .normal)
|
|
setToolView.submitBtn.setTitle("open".localized, for: .normal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -77,15 +97,23 @@ class TSNightLightVC: TSBaseVC {
|
|
if setToolView.isHidden == true {
|
|
if setToolView.isHidden == true {
|
|
UIView.animate(withDuration: 0.5, delay: 0, options: []) {
|
|
UIView.animate(withDuration: 0.5, delay: 0, options: []) {
|
|
self.setToolView.isHidden = false
|
|
self.setToolView.isHidden = false
|
|
- self.setToolView.submitBtn.setTitle(self.isOpen ? "Close" : "Open", for: .normal)
|
|
|
|
}
|
|
}
|
|
- UIDevice.allowScreenSleep()
|
|
|
|
}
|
|
}
|
|
|
|
+ self.setToolView.submitBtn.setTitle(self.isOpen ? "Close" : "Open", for: .normal)
|
|
|
|
+ UIDevice.allowScreenSleep()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func startMyTimer(){
|
|
|
|
+ myTimer.start()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func stopMyTimer(){
|
|
|
|
+ myTimer.stop()
|
|
|
|
+ }
|
|
|
|
|
|
deinit {
|
|
deinit {
|
|
UIDevice.allowScreenSleep()
|
|
UIDevice.allowScreenSleep()
|
|
|
|
+ myTimer.stop()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -108,7 +136,7 @@ class TSNightSetToolView: TSBaseView {
|
|
var isShow = true
|
|
var isShow = true
|
|
|
|
|
|
|
|
|
|
- private var countdown:Int = 0
|
|
|
|
|
|
+ var countdown:Int = 0
|
|
|
|
|
|
lazy var titleLabel1: UILabel = {
|
|
lazy var titleLabel1: UILabel = {
|
|
let titleLabel1 = UILabel.createLabel(text: "Brightness".localized,font: .font(size: 14,weight: .medium),textColor: .white)
|
|
let titleLabel1 = UILabel.createLabel(text: "Brightness".localized,font: .font(size: 14,weight: .medium),textColor: .white)
|
|
@@ -143,14 +171,7 @@ class TSNightSetToolView: TSBaseView {
|
|
return submitBtn
|
|
return submitBtn
|
|
}()
|
|
}()
|
|
|
|
|
|
- lazy var myTimer: TSCustomTimer = {
|
|
|
|
- let customTimer = TSCustomTimer(interval: 1.0,repeats: true) { [weak self] in
|
|
|
|
- guard let self = self else { return }
|
|
|
|
- countdown -= 1
|
|
|
|
- timeLabel.text = countdown.toHourMinuteSecondString()
|
|
|
|
- }
|
|
|
|
- return customTimer
|
|
|
|
- }()
|
|
|
|
|
|
+
|
|
//时间选择器
|
|
//时间选择器
|
|
lazy var timerView: TSTimerView = {
|
|
lazy var timerView: TSTimerView = {
|
|
let timerView = TSTimerView()
|
|
let timerView = TSTimerView()
|
|
@@ -268,10 +289,6 @@ class TSNightSetToolView: TSBaseView {
|
|
self.timerView.isHidden = false
|
|
self.timerView.isHidden = false
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- deinit {
|
|
|
|
- myTimer.stop()
|
|
|
|
- }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|