Prepare for Puppet to work on Editor Window

This commit is contained in:
Lncvrt committed 2025-08-15 20:09:41 -07:00
1 parent b0ae3a9978
commit 827449f670
13 files changed
+140 -80

No files matched your search

+3 -1
View File
@@ -4,7 +4,8 @@
"description": "Capability for the main window",
"windows": [
"projectmanager",
"newprojectpopup"
"newprojectpopup",
"editor"
],
"permissions": [
"core:default",
@@ -12,6 +13,7 @@
"core:window:allow-set-enabled",
"core:window:allow-set-focus",
"core:window:allow-set-closable",
"core:window:allow-close",
"dialog:default"
]
}
+44 -12
View File
@@ -1,10 +1,50 @@
use serde_json::Value;
use std::{io::Cursor, path::Path};
use tauri::{AppHandle, Emitter};
use tauri::{AppHandle, Emitter, WebviewWindowBuilder};
use tauri_plugin_dialog::{DialogExt, MessageDialogKind};
use tokio::fs;
use zip::ZipArchive;
#[tauri::command]
fn create_window(app: AppHandle, window_type: i32) {
match window_type {
0 => {
let _ = WebviewWindowBuilder::new(
&app,
"projectmanager",
tauri::WebviewUrl::App("projectmanager/projects".into()),
)
.resizable(false)
.maximizable(false)
.title("PHP Fly: Project Manager")
.inner_size(800.0, 500.0)
.build();
}
1 => {
let _ = WebviewWindowBuilder::new(
&app,
"newprojectpopup",
tauri::WebviewUrl::App("newproject".into()),
)
.resizable(false)
.maximizable(false)
.title("PHP Fly: New Project")
.inner_size(400.0, 500.0)
.build();
}
2 => {
let _ =
WebviewWindowBuilder::new(&app, "editor", tauri::WebviewUrl::App("editor".into()))
.maximized(true)
.title("PHP Fly: Editor")
.inner_size(800.0, 600.0)
.min_inner_size(600.0, 400.0)
.build();
}
_ => {}
}
}
#[tauri::command]
async fn create_project(
app: AppHandle,
@@ -111,18 +151,10 @@ pub fn run() {
.title("Warning")
.blocking_show();
}))
.invoke_handler(tauri::generate_handler![create_project])
.invoke_handler(tauri::generate_handler![create_project, create_window])
.setup(|app| {
tauri::webview::WebviewWindowBuilder::new(
app,
"projectmanager",
tauri::WebviewUrl::App("projectmanager/projects".into()),
)
.resizable(false)
.maximizable(false)
.title("PHP Fly: Project Manager")
.inner_size(800.0, 500.0)
.build()?;
let handle = app.handle();
create_window(handle.clone(), 0);
Ok(())
})
.run(tauri::generate_context!())
+1 -1
View File
@@ -1,4 +1,4 @@
@import 'tailwindcss';
@import "tailwindcss";
body {
@apply bg-[rgb(16,16,24)] text-white select-none;
+1
View File
@@ -0,0 +1 @@
@import "tailwindcss";
+11
View File
@@ -0,0 +1,11 @@
'use client'
import './Editor_Globals.css'
export default function Editor_page () {
return (
<>
<p>Editor page</p>
</>
)
}
@@ -1,4 +1,4 @@
@import 'tailwindcss';
@import "tailwindcss";
.sidebar {
@apply w-50 h-screen bg-[rgb(24,24,36)] flex flex-col items-center justify-start border-r border-r-[rgb(48,48,72)] z-1;
@@ -0,0 +1,48 @@
'use client'
import Image from 'next/image'
import './Sidebar.css'
import { useEffect, useState } from 'react'
import { app } from '@tauri-apps/api'
import Link from 'next/link'
export default function Sidebar () {
const [version, setVersion] = useState<string | null>(null)
const [rotation, setRotation] = useState<number>(0)
useEffect(() => {
;(async () => {
const tempVersion = await app.getVersion()
setVersion(tempVersion)
})()
}, [])
return (
<div className='sidebar'>
<Image
src='/Icon.png'
width={64}
height={64}
alt='CodeFly Logo'
className='m-2 transition-transform duration-[1.5s]'
draggable={false}
style={{
rotate: `${rotation}deg`
}}
onClick={() => {
setRotation(rotation + 1800)
}}
onContextMenu={() => {
setRotation(rotation - 1800)
}}
></Image>
<Link href='/projectmanager/projects'>Projects</Link>
<Link href='/projectmanager/settings'>Settings</Link>
{version != null && (
<p className='mt-auto mr-auto ml-2 mb-2 text-gray-400'>
PHP Fly v{version}
</p>
)}
</div>
)
}
+2 -43
View File
@@ -1,55 +1,14 @@
'use client'
import { useEffect, useState } from 'react'
import './ProjectManager_layout.css'
import { app } from '@tauri-apps/api'
import Image from 'next/image'
import Link from 'next/link'
import Sidebar from './components/Sidebar'
export default function ProjectManageR_Layout ({
children
}: {
children: React.ReactNode
}) {
const [version, setVersion] = useState<string | null>(null)
const [rotation, setRotation] = useState<number>(0)
useEffect(() => {
;(async () => {
const tempVersion = await app.getVersion()
setVersion(tempVersion)
})()
}, [])
return (
<>
<div className='flex'>
<div className='sidebar'>
<Image
src='/Icon.png'
width={64}
height={64}
alt='CodeFly Logo'
className='m-2 transition-transform duration-[1.5s]'
draggable={false}
style={{
rotate: `${rotation}deg`
}}
onClick={() => {
setRotation(rotation + 1800)
}}
onContextMenu={() => {
setRotation(rotation - 1800)
}}
></Image>
<Link href='/projectmanager/projects'>Projects</Link>
<Link href='/projectmanager/settings'>Settings</Link>
{version != null && (
<p className='mt-auto mr-auto ml-2 mb-2 text-gray-400'>
PHP Fly v{version}
</p>
)}
</div>
<Sidebar />
<div className='relative z-0 flex-1'>
<main>{children}</main>
</div>
@@ -1,4 +1,4 @@
@import 'tailwindcss';
@import "tailwindcss";
.topbar {
@apply bg-[rgb(24,24,36)] m-2 p-2 border border-[rgb(48,48,72)] rounded-lg justify-center mx-auto w-fit flex gap-2;
+27 -16
View File
@@ -2,6 +2,7 @@
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
import './ProjecftManager_projects.css'
import { invoke } from '@tauri-apps/api/core'
export default function ProjectManager_Projects () {
return (
@@ -13,24 +14,20 @@ export default function ProjectManager_Projects () {
'newprojectpopup'
)
if (windowExists) return
const mainWindow = await WebviewWindow.getByLabel('projectmanager')
if (!mainWindow) return
const popup = new WebviewWindow('newprojectpopup', {
title: 'PHP Fly: New Project',
url: '/newproject',
width: 400,
height: 500,
resizable: false,
maximizable: false,
parent: mainWindow
})
await mainWindow.setClosable(false)
await mainWindow.setEnabled(false)
const projectManager = await WebviewWindow.getByLabel(
'projectmanager'
)
if (!projectManager) return
invoke('create_window', { windowType: 1 })
const popup = await WebviewWindow.getByLabel('newprojectpopup')
if (!popup) return
await projectManager.setClosable(false)
await projectManager.setEnabled(false)
await popup.setFocus()
popup.once('tauri://destroyed', async () => {
await mainWindow.setEnabled(true)
await mainWindow.setClosable(true)
await mainWindow.setFocus()
await projectManager.setEnabled(true)
await projectManager.setClosable(true)
await projectManager.setFocus()
})
}}
>
@@ -38,6 +35,20 @@ export default function ProjectManager_Projects () {
</button>
<button>Open</button>
<button>Clone Repository</button>
<button
onClick={async () => {
const projectManager = await WebviewWindow.getByLabel(
'projectmanager'
)
if (!projectManager) return
invoke('create_window', { windowType: 2 })
const editor = await WebviewWindow.getByLabel('editor')
if (!editor) return
projectManager.close()
}}
>
dbg: open editor
</button>
</div>
<div className='content'></div>
</>
-2
View File
@@ -1,5 +1,3 @@
'use client'
export default function ProjectManager_Settings () {
return (
<>
+1 -1
View File
@@ -1,4 +1,4 @@
@import 'tailwindcss';
@import "tailwindcss";
button {
@apply bg-[rgb(54,54,72)] hover:bg-[rgb(72,72,96)];
-2
View File
@@ -1,5 +1,3 @@
'use client'
import { JSX } from 'react'
import './OptionButtons.css'