mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Update WeatherBarItem.swift
This commit is contained in:
parent
94d519cd65
commit
92c4eed4ed
@ -9,14 +9,13 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
import CoreLocation
|
import CoreLocation
|
||||||
|
|
||||||
class WeatherBarItem: NSCustomTouchBarItem, CLLocationManagerDelegate {
|
class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||||
private let dateFormatter = DateFormatter()
|
private let dateFormatter = DateFormatter()
|
||||||
private var timer: Timer!
|
private var timer: Timer!
|
||||||
private var interval: TimeInterval!
|
private var interval: TimeInterval!
|
||||||
private var units: String
|
private var units: String
|
||||||
private var api_key: String
|
private var api_key: String
|
||||||
private var units_str = "°F"
|
private var units_str = "°F"
|
||||||
private let button = NSButton(title: "", target: nil, action: nil)
|
|
||||||
private var prev_location: CLLocation!
|
private var prev_location: CLLocation!
|
||||||
private var 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": "🌫"]
|
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!
|
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.interval = interval
|
||||||
self.units = units
|
self.units = units
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
@ -40,10 +39,9 @@ class WeatherBarItem: NSCustomTouchBarItem, CLLocationManagerDelegate {
|
|||||||
iconsSource = iconsText
|
iconsSource = iconsText
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
let status = CLLocationManager.authorizationStatus()
|
let status = CLLocationManager.authorizationStatus()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user