diff --git a/README.md b/README.md index f80237bc..2a401098 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # sleek [![Code scan and test cases](https://github.com/ransome1/sleek/actions/workflows/code-scan.yml/badge.svg?branch=develop)](https://github.com/ransome1/sleek/actions/workflows/code-scan.yml) +[![sleek](https://snapcraft.io/sleek/badge.svg)](https://snapcraft.io/sleek) + ## ❤️ Become a contributer. [sleek is currently being rewritten.](https://github.com/ransome1/sleek/discussions/501) Now is a good time to join us in our mission to provide a user-friendly, free, and open-source todo.txt client. We're actively inviting passionate contributors skilled in `React`, `TypeScript`, `Electron`, and `Jest/Playwright` to join our collaborative effort. The `develop` branch reflects the most recent progress. Here you'll find our roadmap: https://github.com/users/ransome1/projects/3. diff --git a/src/main/main.ts b/src/main/main.ts index 07aa68fd..12ff13e9 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -15,6 +15,7 @@ import { createTray } from './tray'; import './modules/Ipc'; const files: File[] = (configStorage.get('files') as File[]) || []; +const windowMaximized: boolean = configStorage.get('windowMaximized'); let mainWindow: BrowserWindow | null = null; let eventListeners: Record = {}; @@ -38,19 +39,33 @@ const handleClosed = () => { } const handleResize = () => { - if (mainWindow) { + if (!windowMaximized && mainWindow) { const { width, height } = mainWindow.getBounds(); configStorage.set('windowDimensions', { width, height }); } } const handleMove = () => { - if (mainWindow) { + if (!windowMaximized && mainWindow) { const { x, y } = mainWindow.getBounds(); configStorage.set('windowPosition', { x, y }); } } +const handleUnmaximize = () => { + configStorage.set('windowMaximized', false) +} + +const handleMaximize = () => { + configStorage.set('windowMaximized', true) +} + +const handleShow = () => { + if (app.dock) { + app.dock.show(); + } +} + const createWindow = async() => { mainWindow = new BrowserWindow({ width: 1280, @@ -76,27 +91,33 @@ const createWindow = async() => { } }); } - - const windowDimensions: { width: number; height: number } | null = configStorage.get('windowDimensions') as { width: number; height: number } | null; - if (windowDimensions) { - const { width, height } = windowDimensions; - mainWindow.setSize(width, height); + if(windowMaximized) { + mainWindow.maximize(); + } else { + const windowDimensions: { width: number; height: number } | null = configStorage.get('windowDimensions') as { width: number; height: number } | null; + + if (windowDimensions) { + const { width, height } = windowDimensions; + mainWindow.setSize(width, height); - const windowPosition: { x: number; y: number } | null = configStorage.get('windowPosition') as { x: number; y: number } | null; - if (windowPosition) { - const { x, y } = windowPosition; - mainWindow.setPosition(x, y); + const windowPosition: { x: number; y: number } | null = configStorage.get('windowPosition') as { x: number; y: number } | null; + if (windowPosition) { + const { x, y } = windowPosition; + mainWindow.setPosition(x, y); + } } } - + mainWindow.loadURL(resolveHtmlPath('index.html')); mainWindow .on('ready-to-show', handleReadyToShow) .on('resize', handleResize) .on('move', handleMove) .on('show', handleShow) - .on('closed', handleClosed); + .on('closed', handleClosed) + .on('maximize', handleMaximize) + .on('unmaximize', handleUnmaximize); return "Main window has been created successfully" } @@ -123,11 +144,7 @@ const handleReadyToShow = async () => { // } } -const handleShow = () => { - if (app.dock) { - app.dock.show(); - } -} + const handleWindowAllClosed = () => { const tray: boolean = configStorage.get('tray'); diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 330fced0..6ed14895 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -198,14 +198,18 @@ const App = () => { isSettingsOpen={isSettingsOpen} setIsSettingsOpen={setIsSettingsOpen} /> - + {files?.length > 0 && ( + <> + + + )} {files?.length > 0 && ( <>