1
0
mirror of https://github.com/kremalicious/blowfish.git synced 2024-12-28 07:37:51 +01:00

fix highlight color

This commit is contained in:
Matthias Kretschmann 2019-05-20 20:14:15 +02:00
parent d5b43be6ec
commit 99aaabcc29
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 20 additions and 15 deletions

View File

@ -109,12 +109,12 @@ const createWindow = async () => {
// Load menubar
buildMenu(mainWindow)
// Load touchbar
process.platform === 'darwin' &&
const systemAccentColor = systemPreferences.getAccentColor()
buildTouchbar(prices, mainWindow, systemAccentColor)
if (process.platform === 'darwin') {
const accentColor = getAccentColor()
buildTouchbar(prices, mainWindow, accentColor)
ipcMain.on('prices-updated', (event, pricesNew) => {
updateTouchbar(pricesNew, mainWindow, systemAccentColor)
updateTouchbar(pricesNew, mainWindow, accentColor)
})
}
}
@ -145,9 +145,13 @@ app.on('activate', () => {
// Accent color setting
// macOS & Windows
//
const switchAccentColor = () => {
const getAccentColor = () => {
const systemAccentColor = systemPreferences.getAccentColor()
const accentColor = rgbaToHex(systemAccentColor)
return rgbaToHex(systemAccentColor)
}
const switchAccentColor = () => {
const accentColor = getAccentColor()
mainWindow.webContents.send('accent-color', accentColor)
}

View File

@ -6,32 +6,33 @@ const { TouchBarButton } = TouchBar
// const currency = ipc...
// const prices = ipc...
const createButton = (value, key, mainWindow, systemAccentColor) =>
new TouchBarButton({
const createButton = (value, key, mainWindow, accentColor) => {
return new TouchBarButton({
label: cryptoFormatter(value, key.toUpperCase()),
click: () => mainWindow.webContents.send('setCurrency', key),
backgroundColor: key === 'ocean' ? systemAccentColor : '#141414'
backgroundColor: key === 'ocean' ? accentColor : '#141414'
})
}
const buildTouchbar = (prices, mainWindow, systemAccentColor) => {
const buildTouchbar = (prices, mainWindow, accentColor) => {
const touchBar = new TouchBar({
items: [
createButton(1, 'ocean', mainWindow, systemAccentColor),
...prices.map(key => createButton(0, key, mainWindow, systemAccentColor))
createButton(1, 'ocean', mainWindow, accentColor),
...prices.map(key => createButton(0, key, mainWindow, accentColor))
]
})
mainWindow.setTouchBar(touchBar)
}
const updateTouchbar = (prices, mainWindow, systemAccentColor) => {
const updateTouchbar = (prices, mainWindow, accentColor) => {
const touchBar = new TouchBar({
items: [
createButton(1, 'ocean', mainWindow, systemAccentColor),
createButton(1, 'ocean', mainWindow, accentColor),
...Object.entries(prices)
.filter(([key]) => key !== 'ocean')
.map(([key, value]) =>
createButton(value, key, mainWindow, systemAccentColor)
createButton(value, key, mainWindow, accentColor)
)
]
})