feat: add window controls & screen creation util
This commit is contained in:
parent
96c43fba05
commit
a4822948d1
20 changed files with 149 additions and 61 deletions
|
|
@ -4,24 +4,25 @@
|
|||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./context": "./src/context.tsx"
|
||||
"./context": "./src/context.tsx",
|
||||
"./controls": "./src/windowControls.tsx"
|
||||
},
|
||||
"scripts": {
|
||||
"dev:mobile:raw": "tauri android dev",
|
||||
"build:mobile:raw": "tauri android build",
|
||||
"dev:mobile": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:mobile:raw; else bun dev:mobile:raw; fi",
|
||||
"build:mobile": "if command -v nix >/dev/null 2>&1; then nix develop --command bun build:mobile:raw; else bun build:mobile:raw; fi",
|
||||
|
||||
"dev:desktop:raw": "tauri dev",
|
||||
"build:desktop:raw": "tauri build",
|
||||
"dev:desktop": "if command -v nix >/dev/null 2>&1; then nix develop --command bun dev:desktop:raw; else bun dev:desktop:raw; fi",
|
||||
"build:desktop": "if command -v nix >/dev/null 2>&1; then nix develop --command bun build:desktop:raw; else bun build:desktop:raw; fi",
|
||||
|
||||
"gen-icons": "tauri icon ./logo.png"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2",
|
||||
"@tauri-apps/plugin-opener": "^2",
|
||||
"@tensamin/ui": "workspace:*",
|
||||
"lucide-react": "^1.7.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# Outputs
|
||||
|
||||
- ./src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
|
||||
- ./src-tauri/target/release/bundle/deb/Tensamin_{version}_{arch}.deb
|
||||
- ./src-tauri/target/release/bundle/deb/Tensamin*{version}*{arch}.deb
|
||||
- ./src-tauri/target/release/bundle/rpm/Tensamin-{version}-1.{arch}.rpm
|
||||
|
|
|
|||
|
|
@ -2,6 +2,16 @@
|
|||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": ["core:default", "opener:default"]
|
||||
}
|
||||
"windows": [
|
||||
"main"
|
||||
],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"opener:default",
|
||||
"core:window:default",
|
||||
"core:window:allow-start-dragging",
|
||||
"core:window:allow-close",
|
||||
"core:window:allow-toggle-maximize",
|
||||
"core:window:allow-minimize"
|
||||
]
|
||||
}
|
||||
53
apps/tauri/src/windowControls.tsx
Normal file
53
apps/tauri/src/windowControls.tsx
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { Maximize, Minus, X } from "lucide-react";
|
||||
import { Button, buttonVariants } from "@tensamin/ui/cmp/button";
|
||||
|
||||
import { isTauri } from "@tauri-apps/api/core";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { cn, useIsMobile } from "@tensamin/ui/utils";
|
||||
import { Card } from "@tensamin/ui/cmp/card";
|
||||
|
||||
export default function Controls({
|
||||
className,
|
||||
notPresentClassName,
|
||||
}: {
|
||||
className?: string;
|
||||
notPresentClassName?: string;
|
||||
}) {
|
||||
const isMobile = useIsMobile();
|
||||
if (!isTauri() || isMobile) return <div className={notPresentClassName} />;
|
||||
|
||||
const currentWindow = getCurrentWindow();
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={cn(
|
||||
"flex flex-row py-0 px-0 p-0.5 gap-0 rounded-lg",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="w-9 h-9 aspect-square rounded-lg"
|
||||
onClick={() => currentWindow.minimize()}
|
||||
>
|
||||
<Minus />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="w-9 h-9 aspect-square rounded-lg"
|
||||
onClick={() => currentWindow.toggleMaximize()}
|
||||
>
|
||||
<Maximize />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="w-9 h-9 aspect-square rounded-lg"
|
||||
onClick={() => currentWindow.close()}
|
||||
>
|
||||
<X />
|
||||
</Button>
|
||||
</>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue