mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Upd default. Readme. Fixed reload for central scroller.
This commit is contained in:
parent
9b86ed1dee
commit
4b39b000e0
@ -98,9 +98,9 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
|
||||
if let oldValue = self.oldValue {
|
||||
if oldValue < value {
|
||||
color = NSColor(red: 95.0/255.0, green: 185.0/255.0, blue: 50.0/255.0, alpha: 1.0)
|
||||
color = NSColor.green
|
||||
} else if oldValue > value {
|
||||
color = NSColor(red: 185.0/255.0, green: 95.0/255.0, blue: 50.0/255.0, alpha: 1.0)
|
||||
color = NSColor.red
|
||||
}
|
||||
}
|
||||
self.oldValue = value
|
||||
|
||||
@ -208,7 +208,7 @@ enum ItemType: Decodable {
|
||||
let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type) ?? "text"
|
||||
self = .weather(interval: interval, units: units, api_key: api_key, icon_type: icon_type)
|
||||
case .currency:
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 600.0
|
||||
let from = try container.decodeIfPresent(String.self, forKey: .from) ?? "RUB"
|
||||
let to = try container.decodeIfPresent(String.self, forKey: .to) ?? "USD"
|
||||
self = .currency(interval: interval, from: from, to: to)
|
||||
|
||||
@ -42,7 +42,6 @@ extension ItemType {
|
||||
|
||||
extension NSTouchBarItem.Identifier {
|
||||
static let controlStripItem = NSTouchBarItem.Identifier("com.toxblh.mtmr.controlStrip")
|
||||
static let centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea")
|
||||
}
|
||||
|
||||
class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
@ -56,6 +55,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
var leftIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var centerItems: [NSTouchBarItem] = []
|
||||
var rightIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var scrollArea: NSCustomTouchBarItem?
|
||||
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||
|
||||
private override init() {
|
||||
super.init()
|
||||
@ -83,8 +84,12 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
return definition.align == .center ? items[identifier] : nil
|
||||
}
|
||||
|
||||
self.centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||
self.scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
||||
|
||||
touchBar.delegate = self
|
||||
touchBar.defaultItemIdentifiers = self.leftIdentifiers + [.centerScrollArea] + self.rightIdentifiers
|
||||
touchBar.defaultItemIdentifiers = []
|
||||
touchBar.defaultItemIdentifiers = self.leftIdentifiers + [centerScrollArea] + self.rightIdentifiers
|
||||
self.presentTouchBar()
|
||||
}
|
||||
|
||||
@ -143,8 +148,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
}
|
||||
|
||||
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||||
if identifier == .centerScrollArea {
|
||||
return ScrollViewItem(identifier: identifier, items: centerItems)
|
||||
if identifier == centerScrollArea {
|
||||
return self.scrollArea
|
||||
}
|
||||
|
||||
guard let item = self.items[identifier],
|
||||
|
||||
@ -33,6 +33,10 @@ class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||
units_str = "°C"
|
||||
}
|
||||
|
||||
if self.units == "imperial" {
|
||||
units_str = "°F"
|
||||
}
|
||||
|
||||
if icon_type == "images" {
|
||||
iconsSource = iconsImages
|
||||
} else {
|
||||
|
||||
@ -66,8 +66,10 @@
|
||||
{ "type": "previous", "width": 44 },
|
||||
{ "type": "play", "width": 44 },
|
||||
{ "type": "next", "width": 44 },
|
||||
{ "type": "weather", "refreshInterval": 1800 },
|
||||
{ "type": "weather", "icon_type": "images", "units": "metric" },
|
||||
{ "type": "currency", "from": "BTC", "to": "USD" },
|
||||
{ "type": "sleep", "width": 44 },
|
||||
{ "type": "mute", "width": 40, "align": "right" },
|
||||
{ "type": "volumeDown", "width": 34, "align": "right" },
|
||||
{ "type": "volume", "width": 60, "align": "right" },
|
||||
{ "type": "volumeUp", "width": 34, "align": "right" },
|
||||
|
||||
@ -116,6 +116,8 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
||||
"type": "weather",
|
||||
"refreshInterval": 600,
|
||||
"units": "metric", // or imperial
|
||||
"icon_type": "text" // or images
|
||||
"api_key": "" // you can get the key on openweather
|
||||
```
|
||||
|
||||
- `currency`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user