Skip to content

Instantly share code, notes, and snippets.

@azu
Last active December 31, 2020 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/bd3fb1a24607410dd49b212b0f6ce413 to your computer and use it in GitHub Desktop.
Save azu/bd3fb1a24607410dd49b212b0f6ce413 to your computer and use it in GitHub Desktop.
Tile Split View: TweetDeck | Discord https://github.com/kasper/phoenix
/**
* 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