diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 895e3c0..4eb2ccf 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -27,7 +27,40 @@
"all": true
},
"window": {
- "all": true
+ "all": true,
+ "create": true,
+ "center": true,
+ "requestUserAttention": true,
+ "setResizable": true,
+ "setMaximizable": true,
+ "setMinimizable": true,
+ "setClosable": true,
+ "setTitle": true,
+ "maximize": true,
+ "unmaximize": true,
+ "minimize": true,
+ "unminimize": true,
+ "show": true,
+ "hide": true,
+ "close": true,
+ "setDecorations": true,
+ "setAlwaysOnTop": true,
+ "setContentProtected": true,
+ "setSize": true,
+ "setMinSize": true,
+ "setMaxSize": true,
+ "setPosition": true,
+ "setFullscreen": true,
+ "setFocus": true,
+ "setIcon": true,
+ "setSkipTaskbar": true,
+ "setCursorGrab": true,
+ "setCursorVisible": true,
+ "setCursorIcon": true,
+ "setCursorPosition": true,
+ "setIgnoreCursorEvents": true,
+ "startDragging": true,
+ "print": true
}
},
"bundle": {
@@ -71,6 +104,7 @@
},
"windows": [
{
+ "decorations": false,
"fullscreen": false,
"height": 600,
"resizable": true,
diff --git a/src/components/HeaderBar/HeaderBar.tsx b/src/components/HeaderBar/HeaderBar.tsx
index 7c8f2c3..e80282f 100644
--- a/src/components/HeaderBar/HeaderBar.tsx
+++ b/src/components/HeaderBar/HeaderBar.tsx
@@ -1,25 +1,45 @@
-import { Box, Button, Typography } from "@mui/material";
+import { Box, Typography } from "@mui/material";
import { WindowButtons } from "./WindowButtons";
export const HeaderBar = () => {
- const test = async () => {
- console.log("hello");
- };
-
return (
- hello this is the left side
-
- hello this is the right side |
-
-
+
+ hello this is the left side
+
+
+ hello this is the right side |
+
+
);
};
diff --git a/src/components/HeaderBar/WindowButtons.tsx b/src/components/HeaderBar/WindowButtons.tsx
index ed5f9a7..835f8d1 100644
--- a/src/components/HeaderBar/WindowButtons.tsx
+++ b/src/components/HeaderBar/WindowButtons.tsx
@@ -1,22 +1,40 @@
import { Close, CloseFullscreen, Minimize } from "@mui/icons-material";
import { Box, Button, ButtonGroup, Stack, useTheme } from "@mui/material";
-import { appWindow } from "@tauri-apps/api/window";
+import { WebviewWindow } from "@tauri-apps/api/window";
+import { useEffect, useState } from "react";
export const WindowButtons = () => {
const userTheme = useTheme();
+ const [appWindow, setAppWindow] = useState();
+
+ // explanation:
+ // this is needed due to the server-sided nature of next js,
+ // this means that the window object might not be available on first load
+ // we will use dynamic imports to load the window object only when needed
+ // in hindsight, using next js for this project was a mistake
+ // using create-react-app or vite would have been a better choice just to generate a static site
+ const initializeAppWindow = async () => {
+ const { appWindow } = await import("@tauri-apps/api/window");
+ setAppWindow(appWindow);
+ };
+
const minimize = () => {
- appWindow.minimize();
+ appWindow?.minimize();
};
const maximize = () => {
- appWindow.toggleMaximize();
+ appWindow?.toggleMaximize();
};
const close = () => {
- appWindow.close();
+ appWindow?.close();
};
+ useEffect(() => {
+ initializeAppWindow();
+ });
+
return (