mirror of
https://github.com/kremalicious/blowfish.git
synced 2024-12-28 15:47:52 +01:00
fix highlight color
This commit is contained in:
parent
d5b43be6ec
commit
99aaabcc29
16
src/main.js
16
src/main.js
@ -109,12 +109,12 @@ const createWindow = async () => {
|
|||||||
// Load menubar
|
// Load menubar
|
||||||
buildMenu(mainWindow)
|
buildMenu(mainWindow)
|
||||||
// Load touchbar
|
// Load touchbar
|
||||||
process.platform === 'darwin' &&
|
if (process.platform === 'darwin') {
|
||||||
const systemAccentColor = systemPreferences.getAccentColor()
|
const accentColor = getAccentColor()
|
||||||
buildTouchbar(prices, mainWindow, systemAccentColor)
|
buildTouchbar(prices, mainWindow, accentColor)
|
||||||
|
|
||||||
ipcMain.on('prices-updated', (event, pricesNew) => {
|
ipcMain.on('prices-updated', (event, pricesNew) => {
|
||||||
updateTouchbar(pricesNew, mainWindow, systemAccentColor)
|
updateTouchbar(pricesNew, mainWindow, accentColor)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,9 +145,13 @@ app.on('activate', () => {
|
|||||||
// Accent color setting
|
// Accent color setting
|
||||||
// macOS & Windows
|
// macOS & Windows
|
||||||
//
|
//
|
||||||
const switchAccentColor = () => {
|
const getAccentColor = () => {
|
||||||
const systemAccentColor = systemPreferences.getAccentColor()
|
const systemAccentColor = systemPreferences.getAccentColor()
|
||||||
const accentColor = rgbaToHex(systemAccentColor)
|
return rgbaToHex(systemAccentColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
const switchAccentColor = () => {
|
||||||
|
const accentColor = getAccentColor()
|
||||||
mainWindow.webContents.send('accent-color', accentColor)
|
mainWindow.webContents.send('accent-color', accentColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,32 +6,33 @@ const { TouchBarButton } = TouchBar
|
|||||||
// const currency = ipc...
|
// const currency = ipc...
|
||||||
// const prices = ipc...
|
// const prices = ipc...
|
||||||
|
|
||||||
const createButton = (value, key, mainWindow, systemAccentColor) =>
|
const createButton = (value, key, mainWindow, accentColor) => {
|
||||||
new TouchBarButton({
|
return new TouchBarButton({
|
||||||
label: cryptoFormatter(value, key.toUpperCase()),
|
label: cryptoFormatter(value, key.toUpperCase()),
|
||||||
click: () => mainWindow.webContents.send('setCurrency', key),
|
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({
|
const touchBar = new TouchBar({
|
||||||
items: [
|
items: [
|
||||||
createButton(1, 'ocean', mainWindow, systemAccentColor),
|
createButton(1, 'ocean', mainWindow, accentColor),
|
||||||
...prices.map(key => createButton(0, key, mainWindow, systemAccentColor))
|
...prices.map(key => createButton(0, key, mainWindow, accentColor))
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWindow.setTouchBar(touchBar)
|
mainWindow.setTouchBar(touchBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateTouchbar = (prices, mainWindow, systemAccentColor) => {
|
const updateTouchbar = (prices, mainWindow, accentColor) => {
|
||||||
const touchBar = new TouchBar({
|
const touchBar = new TouchBar({
|
||||||
items: [
|
items: [
|
||||||
createButton(1, 'ocean', mainWindow, systemAccentColor),
|
createButton(1, 'ocean', mainWindow, accentColor),
|
||||||
...Object.entries(prices)
|
...Object.entries(prices)
|
||||||
.filter(([key]) => key !== 'ocean')
|
.filter(([key]) => key !== 'ocean')
|
||||||
.map(([key, value]) =>
|
.map(([key, value]) =>
|
||||||
createButton(value, key, mainWindow, systemAccentColor)
|
createButton(value, key, mainWindow, accentColor)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user