1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 17:38:38 +00:00

+ Dirty hack for show actual status for NightShift

This commit is contained in:
Toxblh 2018-08-29 00:11:30 +01:00
parent eee4082a1a
commit c6b6f7bbd5

View File

@ -1,5 +1,5 @@
// //
// nightShift.swift // NightShiftBarItem.swift
// MTMR // MTMR
// //
// Created by Anton Palgunov on 28/08/2018. // Created by Anton Palgunov on 28/08/2018.
@ -10,6 +10,7 @@ import Foundation
class NightShiftBarItem: CustomButtonTouchBarItem { class NightShiftBarItem: CustomButtonTouchBarItem {
private let nsclient = CBBlueLightClient() private let nsclient = CBBlueLightClient()
private var timer: Timer!
private var blueLightStatus: Status { private var blueLightStatus: Status {
var status: Status = Status() var status: Status = Status()
@ -32,6 +33,8 @@ class NightShiftBarItem: CustomButtonTouchBarItem {
self.tapClosure = { [weak self] in self?.nightShiftAction() } self.tapClosure = { [weak self] in self?.nightShiftAction() }
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(refresh), userInfo: nil, repeats: true)
self.refresh() self.refresh()
} }
@ -44,7 +47,7 @@ class NightShiftBarItem: CustomButtonTouchBarItem {
self.refresh() self.refresh()
} }
func refresh() { @objc func refresh() {
self.image = isNightShiftEnabled ? #imageLiteral(resourceName: "nightShiftOn") : #imageLiteral(resourceName: "nightShiftOff") self.image = isNightShiftEnabled ? #imageLiteral(resourceName: "nightShiftOn") : #imageLiteral(resourceName: "nightShiftOff")
} }
} }