mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
Updated CurrenyBarItem to display second currency (TO FROM>RATE) and also correct number of decimal places.
Added INR to list of currencies.
This commit is contained in:
parent
f61550e510
commit
47561ce71b
@ -15,6 +15,7 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
private var postfix: String
|
||||
private var from: String
|
||||
private var to: String
|
||||
private var decimal as Int
|
||||
private var oldValue: Float32!
|
||||
private var full: Bool = false
|
||||
|
||||
@ -27,16 +28,37 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
"CAD": "$",
|
||||
"KRW": "₩",
|
||||
"CNY": "¥",
|
||||
"AUD": "$",
|
||||
"AUD": "Aus",
|
||||
"BRL": "R$",
|
||||
"IDR": "Rp",
|
||||
"MXN": "$",
|
||||
"SGD": "$",
|
||||
"CHF": "Fr.",
|
||||
"INR": "Rp",
|
||||
"MXN": "Mx",
|
||||
"SGD": "Sg",
|
||||
"CHF": "Fr",
|
||||
"BTC": "฿",
|
||||
"LTC": "Ł",
|
||||
"ETH": "Ξ",
|
||||
]
|
||||
private let decimals = [
|
||||
"USD": "4",
|
||||
"EUR": "4",
|
||||
"RUB": "2",
|
||||
"JPY": "2",
|
||||
"GBP": "4",
|
||||
"CAD": "4",
|
||||
"KRW": "4",
|
||||
"CNY": "4",
|
||||
"AUD": "4",
|
||||
"BRL": "4",
|
||||
"IDR": "0",
|
||||
"INR": "2",
|
||||
"MXN": "2",
|
||||
"SGD": "4",
|
||||
"CHF": "4",
|
||||
"BTC": "2",
|
||||
"LTC": "2",
|
||||
"ETH": "2",
|
||||
]
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: String, to: String, full: Bool) {
|
||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||
@ -57,6 +79,12 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
postfix = to
|
||||
}
|
||||
|
||||
if let decimal = decimals[to] {
|
||||
self.decimal = decimal
|
||||
} else {
|
||||
decimal = "2"
|
||||
}
|
||||
|
||||
super.init(identifier: identifier, title: "⏳")
|
||||
|
||||
activity.repeats = true
|
||||
@ -117,7 +145,7 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
|
||||
var title = ""
|
||||
if full {
|
||||
title = String(format: "%@‣%.2f%@", prefix, value, postfix)
|
||||
title = String(format: "%@%@‣%.%@f%@", prefix, postfix, decimal, value)
|
||||
} else {
|
||||
title = String(format: "%@%.2f", prefix, value)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user