Last active
December 31, 2020 06:37
-
-
Save azu/bd3fb1a24607410dd49b212b0f6ce413 to your computer and use it in GitHub Desktop.
Tile Split View: TweetDeck | Discord https://github.com/kasper/phoenix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SplitView | |
*/ | |
const splitView = ({ leftAppName, rightAppName, mainAppName }) => { | |
const leftApp = App.get(leftAppName); | |
const leftAppWindow = leftApp.mainWindow(); | |
const rightApp = App.get(rightAppName); | |
const rightAppWindow = rightApp.mainWindow(); | |
const frame = Screen.main().visibleFrame(); | |
const { width, height } = frame; | |
const windowRatio = { | |
left: 0.73, | |
right: 0.27 | |
}; | |
// Resize | |
leftAppWindow.setFrame({ x: 0, y: 0, width: width * windowRatio.left, height }); | |
rightAppWindow.setFrame({ x: width * windowRatio.left, y: 0, width: width * windowRatio.right, height }); | |
// raise up to front | |
if (leftAppName === mainAppName) { | |
rightAppWindow.raise(); | |
leftAppWindow.raise(); | |
} else { | |
leftAppWindow.raise(); | |
rightAppWindow.raise(); | |
} | |
} | |
const appNames = { | |
left: "TweetDeck", | |
right: "Discord" | |
} | |
// on active | |
Event.on('appDidActivate', app => { | |
const appName = app.name(); | |
if (appName === appNames.left || appName === appNames.right) { | |
splitView({ | |
leftAppName: appNames.left, | |
rightAppName: appNames.right, | |
mainAppName: appName | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment