From 647474b9b7d64a90bd2a5371c598b0d5e2e9d2a3 Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Fri, 17 May 2019 13:02:48 -0400 Subject: [PATCH] Fluidly change vibrancy --- public/electron.js | 39 ++++++++++++------- src/components/AppLayout/AppLayout.styles.tsx | 7 +++- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/public/electron.js b/public/electron.js index 90f8cc5..33d9357 100644 --- a/public/electron.js +++ b/public/electron.js @@ -21,6 +21,13 @@ protocol.registerSchemesAsPrivileged([ { scheme: 'hyperspace', privileges: { standard: true, secure: true } } ]) +/** + * Determine whether the desktop app is on macOS + */ +function darwin() { + return process.platform === "darwin"; +} + /** * Register the protocol for Hyperspace */ @@ -126,7 +133,9 @@ function createWindow() { // Set some preferences that are specific to macOS. titleBarStyle: 'hidden', - vibrancy: systemPreferences.isDarkMode()? "dark": "light" + vibrancy: systemPreferences.isDarkMode()? "ultra-dark": "light", + transparent: darwin(), + backgroundColor: darwin()? "#80FFFFFF": "#FFF" } ); @@ -138,8 +147,10 @@ function createWindow() { // Watch for a change in macOS's dark mode and reload the window to apply changes systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { - if (mainWindow != null) + if (mainWindow != null) { + mainWindow.setVibrancy(systemPreferences.isDarkMode()? "ultra-dark": "light"); mainWindow.webContents.reload(); + } }) // Delete the window when closed @@ -199,18 +210,18 @@ function createMenubar() { submenu: [ { role: 'reload' }, { role: 'forcereload' }, - // { - // label: 'Open Dev Tools', - // click () { - // try { - // mainWindow.webContents.openDevTools({mode: 'undocked'}); - // } catch (err) { - // console.error("Couldn't open dev tools: " + err); - // } + { + label: 'Open Dev Tools', + click () { + try { + mainWindow.webContents.openDevTools({mode: 'undocked'}); + } catch (err) { + console.error("Couldn't open dev tools: " + err); + } - // }, - // accelerator: 'Shift+CmdOrCtrl+I' - // }, + }, + accelerator: 'Shift+CmdOrCtrl+I' + }, { type: 'separator' }, { role: 'togglefullscreen' } ] @@ -285,7 +296,7 @@ app.on('ready', () => { // Standard quit behavior changes for macOS app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { + if (!darwin()) { app.quit() } }); diff --git a/src/components/AppLayout/AppLayout.styles.tsx b/src/components/AppLayout/AppLayout.styles.tsx index afcd10f..7c4d125 100644 --- a/src/components/AppLayout/AppLayout.styles.tsx +++ b/src/components/AppLayout/AppLayout.styles.tsx @@ -1,4 +1,5 @@ import { Theme, createStyles } from "@material-ui/core"; +import { darken } from "@material-ui/core/styles/colorManipulator"; import { isDarwinApp } from '../../utilities/desktop'; import { fade } from "@material-ui/core/styles/colorManipulator"; @@ -36,7 +37,11 @@ export const styles = (theme: Theme) => createStyles({ appBar: { zIndex: 1000, backgroundImage: isDarwinApp()? `linear-gradient(${theme.palette.primary.main}, ${theme.palette.primary.dark})`: undefined, - backgroundColor: theme.palette.primary.main + backgroundColor: theme.palette.primary.main, + borderBottomColor: darken(theme.palette.primary.dark, 0.2), + borderBottomWidth: 1, + borderBottomStyle: isDarwinApp()? "solid": "none", + boxShadow: isDarwinApp()? "none": "inherit" }, appBarMenuButton: { marginLeft: -12,