mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Update CurrencyBarItem.swift
This commit is contained in:
parent
7341136897
commit
94d519cd65
@ -9,14 +9,13 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
import CoreLocation
|
import CoreLocation
|
||||||
|
|
||||||
class CurrencyBarItem: NSCustomTouchBarItem {
|
class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||||
private var timer: Timer!
|
private var timer: Timer!
|
||||||
private var interval: TimeInterval!
|
private var interval: TimeInterval!
|
||||||
private var prefix: String
|
private var prefix: String
|
||||||
private var from: String
|
private var from: String
|
||||||
private var to: String
|
private var to: String
|
||||||
private var oldValue: Float32!
|
private var oldValue: Float32!
|
||||||
private let button = NSButton(title: "", target: nil, action: nil)
|
|
||||||
|
|
||||||
private let currencies = [
|
private let currencies = [
|
||||||
"USD": "$",
|
"USD": "$",
|
||||||
@ -35,7 +34,7 @@ class CurrencyBarItem: NSCustomTouchBarItem {
|
|||||||
"CHF": "Fr."
|
"CHF": "Fr."
|
||||||
]
|
]
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: String, to: String) {
|
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: String, to: String, onTap: @escaping () -> ()) {
|
||||||
self.interval = interval
|
self.interval = interval
|
||||||
self.from = from
|
self.from = from
|
||||||
self.to = to
|
self.to = to
|
||||||
@ -46,10 +45,9 @@ class CurrencyBarItem: NSCustomTouchBarItem {
|
|||||||
self.prefix = from
|
self.prefix = from
|
||||||
}
|
}
|
||||||
|
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier, title: "⏳", onTap: onTap)
|
||||||
|
|
||||||
button.bezelColor = .clear
|
button.bezelColor = .clear
|
||||||
button.title = "⏳"
|
|
||||||
self.view = button
|
self.view = button
|
||||||
|
|
||||||
timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(updateCurrency), userInfo: nil, repeats: true)
|
timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(updateCurrency), userInfo: nil, repeats: true)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user