mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Merge branch 'master' into actionURL
This commit is contained in:
commit
6f3425f4c3
@ -9,14 +9,13 @@
|
||||
import Cocoa
|
||||
import CoreLocation
|
||||
|
||||
class CurrencyBarItem: NSCustomTouchBarItem {
|
||||
class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
private var timer: Timer!
|
||||
private var interval: TimeInterval!
|
||||
private var prefix: String
|
||||
private var from: String
|
||||
private var to: String
|
||||
private var oldValue: Float32!
|
||||
private let button = NSButton(title: "", target: nil, action: nil)
|
||||
|
||||
private let currencies = [
|
||||
"USD": "$",
|
||||
@ -35,7 +34,7 @@ class CurrencyBarItem: NSCustomTouchBarItem {
|
||||
"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.from = from
|
||||
self.to = to
|
||||
@ -46,10 +45,9 @@ class CurrencyBarItem: NSCustomTouchBarItem {
|
||||
self.prefix = from
|
||||
}
|
||||
|
||||
super.init(identifier: identifier)
|
||||
super.init(identifier: identifier, title: "⏳", onTap: onTap)
|
||||
|
||||
button.bezelColor = .clear
|
||||
button.title = "⏳"
|
||||
self.view = button
|
||||
|
||||
timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(updateCurrency), userInfo: nil, repeats: true)
|
||||
|
||||
@ -179,9 +179,9 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
barItem = BrightnessViewController(identifier: identifier, refreshInterval: interval)
|
||||
}
|
||||
case .weather(interval: let interval, units: let units, api_key: let api_key, icon_type: let icon_type):
|
||||
barItem = WeatherBarItem(identifier: identifier, interval: interval, units: units, api_key: api_key, icon_type: icon_type)
|
||||
barItem = WeatherBarItem(identifier: identifier, interval: interval, units: units, api_key: api_key, icon_type: icon_type, onTap: action)
|
||||
case .currency(interval: let interval, from: let from, to: let to):
|
||||
barItem = CurrencyBarItem(identifier: identifier, interval: interval, from: from, to: to)
|
||||
barItem = CurrencyBarItem(identifier: identifier, interval: interval, from: from, to: to, onTap: action)
|
||||
}
|
||||
|
||||
if case .width(let value)? = item.additionalParameters[.width], let widthBarItem = barItem as? CanSetWidth {
|
||||
|
||||
@ -9,14 +9,13 @@
|
||||
import Cocoa
|
||||
import CoreLocation
|
||||
|
||||
class WeatherBarItem: NSCustomTouchBarItem, CLLocationManagerDelegate {
|
||||
class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||
private let dateFormatter = DateFormatter()
|
||||
private var timer: Timer!
|
||||
private var interval: TimeInterval!
|
||||
private var units: String
|
||||
private var api_key: String
|
||||
private var units_str = "°F"
|
||||
private let button = NSButton(title: "", target: nil, action: nil)
|
||||
private var prev_location: CLLocation!
|
||||
private var location: CLLocation!
|
||||
private let iconsImages = ["01d": "☀️", "01n": "☀️", "02d": "⛅️", "02n": "⛅️", "03d": "☁️", "03n": "☁️", "04d": "☁️", "04n": "☁️", "09d": "⛅️", "09n": "⛅️", "10d": "🌦", "10n": "🌦", "11d": "🌩", "11n": "🌩", "13d": "❄️", "13n": "❄️", "50d": "🌫", "50n": "🌫"]
|
||||
@ -25,7 +24,7 @@ class WeatherBarItem: NSCustomTouchBarItem, CLLocationManagerDelegate {
|
||||
|
||||
private var manager:CLLocationManager!
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, units: String, api_key: String, icon_type: String? = "text") {
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, units: String, api_key: String, icon_type: String? = "text", onTap: @escaping () -> ()) {
|
||||
self.interval = interval
|
||||
self.units = units
|
||||
self.api_key = api_key
|
||||
@ -40,10 +39,9 @@ class WeatherBarItem: NSCustomTouchBarItem, CLLocationManagerDelegate {
|
||||
iconsSource = iconsText
|
||||
}
|
||||
|
||||
super.init(identifier: identifier)
|
||||
super.init(identifier: identifier, title: "⏳", onTap: onTap)
|
||||
|
||||
button.bezelColor = .clear
|
||||
button.title = "⏳"
|
||||
self.view = button
|
||||
|
||||
let status = CLLocationManager.authorizationStatus()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user