diff --git a/src/WindowManager.js b/src/WindowManager.js index 3cb85f4..adb4a96 100644 --- a/src/WindowManager.js +++ b/src/WindowManager.js @@ -24,9 +24,15 @@ class WindowManager { } init() { + const shouldRestore = this.app.settingsManager.get("restoreWindow", false); + const width = shouldRestore ? this.app.settingsManager.get("windowWidth", 800) : 800; + const height = shouldRestore ? this.app.settingsManager.get("windowHeight", 600) : 600; + this.mainWindow = WindowManager._CreateWindow({ fullscreen : false, - fullscreenable : true + fullscreenable : true, + width, + height }); this.windows.settings = WindowManager._CreateWindow({ height : 300, @@ -36,6 +42,12 @@ class WindowManager { show : false }, this.mainWindow, false); + this.mainWindow.on("resize", () => { + const [width, height] = this.mainWindow.getSize(); + this.app.settingsManager.set("windowWidth", width); + this.app.settingsManager.set("windowHeight", height); + }); + // on windows and linux we need to hide the main menu in the settings // window, because it would look odd. if (["win32", "linux"].includes(process.platform)) { diff --git a/src/ui/src/assets/css/_forms.scss b/src/ui/src/assets/css/_forms.scss index f79c758..0bd7efb 100644 --- a/src/ui/src/assets/css/_forms.scss +++ b/src/ui/src/assets/css/_forms.scss @@ -51,4 +51,68 @@ select { font-size: 1.8vw; } } +} + +$size : 20px; +$spacing : 3px; + +.toggle { + position: relative; + display: inline-block; + width: calc(($size + $spacing) * 2); + height: calc($size + 2 * $spacing); + vertical-align: middle; + margin: 0; + + input { + opacity: 0; + width: 0; + height: 0; + + &:checked { + & + .slider { + background-color: color(hightlight); + } + } + + &:checked + .slider::before { + transform: translateX($size); + } + } + + .slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: color(fadedForeground); + -webkit-transition: .4s; + transition: .4s; + + &::before { + position: absolute; + content: ""; + height: $size; + width: $size; + left: $spacing; + bottom: $spacing; + background-color: color(sidebarBackground); + -webkit-transition: .4s; + transition: .4s; + } + + &.round { + border-radius: calc($size * 2); + + &::before { + border-radius: 50%; + } + } + } + + & + label { + vertical-align: middle; + } } \ No newline at end of file diff --git a/src/ui/src/assets/css/_settings.scss b/src/ui/src/assets/css/_settings.scss index 3676d05..2417a0e 100644 --- a/src/ui/src/assets/css/_settings.scss +++ b/src/ui/src/assets/css/_settings.scss @@ -73,6 +73,10 @@ align-self: flex-start; } } + + &.mb { + margin-bottom: 2rem; + } } } diff --git a/src/ui/src/assets/css/ation.scss b/src/ui/src/assets/css/ation.scss index 8941bc0..4c20182 100644 --- a/src/ui/src/assets/css/ation.scss +++ b/src/ui/src/assets/css/ation.scss @@ -39,6 +39,7 @@ body { app-region: drag; height: 30px; width: 100%; + user-select: none; } ::selection { diff --git a/src/ui/src/components/settings/General.js b/src/ui/src/components/settings/General.js index 44fac04..e41149c 100644 --- a/src/ui/src/components/settings/General.js +++ b/src/ui/src/components/settings/General.js @@ -1,15 +1,36 @@ -import React from "react"; +import React, {useState, useEffect} from "react"; + +import Toggle from "../shared/Toggle"; const General = () => { + const [restoreWindow, setRestoreWindow] = useState(false); + + useEffect(() => { + (async () => { + setRestoreWindow(await window.appSettings.get("restoreWindow", false)); + })(setRestoreWindow); + }, []); + + const changeRestoreWindow = event => { + const value = event.target.checked === true; + setRestoreWindow(value); + window.appSettings.set("restoreWindow", value); + }; const reset = () => { window.appSettings.reset(); } return ( -
- -
+ <> +
+ + +
+
+ +
+ ); }; diff --git a/src/ui/src/components/shared/Toggle.js b/src/ui/src/components/shared/Toggle.js new file mode 100644 index 0000000..365d793 --- /dev/null +++ b/src/ui/src/components/shared/Toggle.js @@ -0,0 +1,12 @@ +import React from "react"; + +const Toggle = ({...props}) => { + return ( + + ); +}; + +export default Toggle; \ No newline at end of file