diff --git a/bun.lockb b/bun.lockb index d4f8a20..4a446f3 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 0f0fcbd..b0299f4 100644 --- a/package.json +++ b/package.json @@ -18,11 +18,13 @@ "@mui/material": "^5.16.5", "@tauri-apps/api": "^1.6.0", "@types/lodash": "^4.17.7", + "jotai": "^2.9.1", "lodash": "^4.17.21", "lowdb": "^7.0.1", "next": "14.2.5", "react": "^18", - "react-dom": "^18" + "react-dom": "^18", + "zustand": "^4.5.4" }, "devDependencies": { "@tauri-apps/cli": "^1.6.0", diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f9dddaf..1ea58fb 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -30,40 +30,7 @@ "all": true }, "window": { - "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 + "all": true } }, "bundle": { @@ -82,38 +49,19 @@ "icons/icon.ico" ], "identifier": "com.vomitblood.stort", - "longDescription": "", - "macOS": { - "entitlements": null, - "exceptionDomain": "", - "frameworks": [], - "providerShortName": null, - "signingIdentity": null - }, + "longDescription": "Launcher for Steam Deck", "resources": [], - "shortDescription": "", - "targets": "all", - "windows": { - "certificateThumbprint": null, - "digestAlgorithm": "sha256", - "timestampUrl": "" - } + "shortDescription": "Launcher for Steam Deck", + "targets": [ + "appimage", + "deb" + ] }, "security": { "csp": null }, "updater": { "active": false - }, - "windows": [ - { - "decorations": false, - "fullscreen": false, - "height": 600, - "resizable": true, - "title": "Stort", - "width": 800 - } - ] + } } } \ No newline at end of file diff --git a/src/components/FooterBar/FooterBar.tsx b/src/components/FooterBar/FooterBar.tsx new file mode 100644 index 0000000..e69de29 diff --git a/src/components/Generic/FloatingDialog.tsx b/src/components/Generic/FloatingDialog.tsx index dde1428..e0bf96a 100644 --- a/src/components/Generic/FloatingDialog.tsx +++ b/src/components/Generic/FloatingDialog.tsx @@ -4,31 +4,31 @@ import { FC, ReactNode } from "react"; import { useSettings } from "../../contexts/SettingsContext"; interface FloatingDialog { - sx?: any; - openState: boolean; - maximisedState: boolean; - setMaximisedState: (state: boolean) => void; - toggleOpen: () => void; - close: () => void; actionButtons?: ReactNode; body: ReactNode; bottomBar?: ReactNode; + close: () => void; + maximisedState: boolean; openButton: ReactNode; + openState: boolean; + setMaximisedState: (state: boolean) => void; + sx?: any; title: string; + toggleOpen: () => void; } export const FloatingDialog: FC = ({ - sx, - openState, - maximisedState, - setMaximisedState, - toggleOpen, - close, actionButtons, body, bottomBar, + close, + maximisedState, openButton, + openState, + setMaximisedState, + sx, title, + toggleOpen, }) => { const { settings } = useSettings(); @@ -75,7 +75,7 @@ export const FloatingDialog: FC = ({ { + onClick={() => { setMaximisedState(!maximisedState); }} sx={{ diff --git a/src/components/Generic/LoadingScreen.tsx b/src/components/Generic/LoadingScreen.tsx new file mode 100644 index 0000000..f74f25e --- /dev/null +++ b/src/components/Generic/LoadingScreen.tsx @@ -0,0 +1,25 @@ +import { Box, Typography, LinearProgress } from "@mui/material"; +import { FC } from "react"; + +interface LoadingScreenProps { + loadingText?: string; +} + +export const LoadingScreen: FC = ({ loadingText }) => { + return ( + + + {loadingText} + + + + ); +}; diff --git a/src/components/HeaderBar/Settings/Settings.tsx b/src/components/HeaderBar/Settings/Settings.tsx index e69de29..d6c0f0e 100644 --- a/src/components/HeaderBar/Settings/Settings.tsx +++ b/src/components/HeaderBar/Settings/Settings.tsx @@ -0,0 +1,20 @@ +// import { IconButton, Typography, useTheme } from "@mui/material"; +// import { FloatingDialog } from "../../Generic/FloatingDialog"; +// import { SettingsCell, SettingsOutlined } from "@mui/icons-material"; + +// export const Settings = () => { +// // contexts +// const theme = useTheme(); +// const { settings, updateSettingsLocal } = useSettings(); + +// return ( +// Settings} +// openButton={ +// +// +// +// } +// /> +// ); +// }; diff --git a/src/lib/path.ts b/src/lib/path.ts new file mode 100644 index 0000000..4eac8c6 --- /dev/null +++ b/src/lib/path.ts @@ -0,0 +1,40 @@ +export const getConfigDirectory = async () => { + const { configDir } = await import("@tauri-apps/api/path"); + return (await configDir()) + "stort/"; +}; + +const pathBase = "stort/"; + +export const getPaths = async () => { + const { + cacheDir, + configDir, + dataDir, + desktopDir, + documentDir, + downloadDir, + executableDir, + fontDir, + homeDir, + logDir, + pictureDir, + templateDir, + videoDir, + } = await import("@tauri-apps/api/path"); + + return { + cacheDirectory: (await cacheDir()) + pathBase, + configDirectory: (await configDir()) + pathBase, + dataDirectory: (await dataDir()) + pathBase, + desktopDirectory: (await desktopDir()) + pathBase, + documentDirectory: (await documentDir()) + pathBase, + downloadDirectory: (await downloadDir()) + pathBase, + executableDirectory: (await executableDir()) + pathBase, + fontDirectory: (await fontDir()) + pathBase, + homeDirectory: (await homeDir()) + pathBase, + logDirectory: (await logDir()) + pathBase, + pictureDirectory: (await pictureDir()) + pathBase, + templateDirectory: (await templateDir()) + pathBase, + videoDirectory: (await videoDir()) + pathBase, + }; +}; diff --git a/src/lib/store/jotai/loading.ts b/src/lib/store/jotai/loading.ts new file mode 100644 index 0000000..31e3deb --- /dev/null +++ b/src/lib/store/jotai/loading.ts @@ -0,0 +1,3 @@ +import { atom } from "jotai"; + +export const loadingAtom = atom(false); diff --git a/src/lib/store/zustand/path.ts b/src/lib/store/zustand/path.ts new file mode 100644 index 0000000..1467f48 --- /dev/null +++ b/src/lib/store/zustand/path.ts @@ -0,0 +1,14 @@ +import { create } from "zustand"; + +type PathType = { + configDirectory: string; +}; + +export const getPaths = async () => { + const { configDir } = await import("@tauri-apps/api/path"); + return (await configDir()) + "stort/"; +}; + +export const usePathStore = create((set) => ({ + configDirectory: getPaths(), +})); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 2abcfc7..4f785f5 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,95 +1,19 @@ -import { Box, Button, TextField, Typography } from "@mui/material"; -import { - ConfirmDialogOptions, - DialogFilter, - MessageDialogOptions, - OpenDialogOptions, -} from "@tauri-apps/api/dialog"; -import { - isPermissionGranted, - Options, - requestPermission, - sendNotification, -} from "@tauri-apps/api/notification"; -import { useState } from "react"; +import { Box } from "@mui/material"; +import { useAtom } from "jotai"; +import { LoadingScreen } from "../components/Generic/LoadingScreen"; import { HeaderBar } from "../components/HeaderBar/HeaderBar"; +import { loadingAtom } from "../lib/store/jotai/loading"; export default function Home() { - const [content, setContent] = useState("Please enter your name"); + const [loading] = useAtom(loadingAtom); - const confirmDialogOptions: ConfirmDialogOptions = { - cancelLabel: "fuck no", - okLabel: "fuck yes", - title: "this is a title", - type: "error", - }; - - const dialogFilter: DialogFilter = { - extensions: ["png", "jpeg"], - name: "this is a name", - }; - - const messageDialogOptions: MessageDialogOptions = { - okLabel: "fuck yes", - title: "this is a title", - type: "warning", - }; - - const openDialogOptions: OpenDialogOptions = { - defaultPath: "/home/vomitblood/Downloads", - directory: false, - filters: [dialogFilter], - multiple: true, - }; - - const notificationOptions: Options = { - // body: "hello this is the body", - // icon: "/home/vomitblood/Downloads/Screenshot 2024-07-14 212730.png", - // sound: "Alerts", - title: "hello this is the title", - }; - - const bruh = async () => { - let permissionGranted = await isPermissionGranted(); - if (!permissionGranted) { - const permission = await requestPermission(); - permissionGranted = permission === "granted"; - } - if (permissionGranted) { - sendNotification("Tauri is awesome!"); - sendNotification({ title: "TAURI", body: "Tauri is awesome!" }); - } - }; - - async function handleClick() { - console.log("bruh"); - // let permissionGranted = await isPermissionGranted(); - // console.log(permissionGranted); - // const permission = await requestPermission(); - // if (!permissionGranted) { - // const permission = await requestPermission(); - // permissionGranted = permission === "granted"; - // } - // if (permissionGranted) { - sendNotification(notificationOptions); - // } + if (loading) { + return ; + } else { + return ( + + + + ); } - - return ( - - - setContent(e.target.value)} - size="small" - variant="outlined" - /> - - - Response: {content} - - - ); } diff --git a/src/pages/testing.tsx b/src/pages/testing.tsx index 377f099..534deda 100644 --- a/src/pages/testing.tsx +++ b/src/pages/testing.tsx @@ -4,19 +4,22 @@ import { BugReport } from "@mui/icons-material"; import { Box, Button, IconButton, Typography } from "@mui/material"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; +import { getConfigDirectory } from "../lib/path"; +import { usePathStore } from "../lib/store/zustand/path"; export default function Testing() { const router = useRouter(); - const [configDir, setConfigDir] = useState(""); + const configPath = usePathStore((state) => state.configDirectory); + const dataPath = usePathStore((state) => state.dataDirectory); + const cachePath = usePathStore((state) => state.cacheDirectory); - const initializeConfigDir = async () => { - const { appConfigDir } = await import("@tauri-apps/api/path"); - setConfigDir(await appConfigDir()); - }; + const [text, setText] = useState(""); useEffect(() => { - initializeConfigDir(); + getConfigDirectory().then((configDirectory) => { + setText(configDirectory); + }); }); return ( @@ -30,12 +33,15 @@ export default function Testing() { - {configDir} + {text} ); }