11import { useEffect , useState } from 'react' ;
2- import { QWebChannel } from '@/qwebchannel'
32import { Tabs , Tab } from '@heroui/tabs' ;
43import { User } from '@heroui/user' ;
54import { Form } from '@heroui/form' ;
6- import { Button , PressEvent } from '@heroui/button' ;
5+ import { Button , PressEvent } from '@heroui/button' ;
76import { Input } from '@heroui/input' ;
87import { Chip } from '@heroui/chip' ;
98import { Listbox , ListboxItem } from '@heroui/listbox' ;
109import { Avatar } from '@heroui/avatar' ;
11- import { ScrollShadow } from " @heroui/scroll-shadow" ;
10+ import { ScrollShadow } from ' @heroui/scroll-shadow' ;
1211import { Select , SelectItem } from '@heroui/react' ;
12+ import { QWebChannel } from '@/qwebchannel' ;
1313
1414interface RecentProjectInfo {
1515 name : string ;
@@ -27,78 +27,86 @@ export default function ProjectHubPage() {
2727 const [ projectTemplates , setProjectTemplates ] = useState ( Array < ProjectTemplateInfo > ) ;
2828
2929 useEffect ( ( ) => {
30- new QWebChannel ( window . qt . webChannelTransport , ( channel : QWebChannel ) : void => {
30+ new QWebChannel ( window . qt . webChannelTransport , ( channel : QWebChannel ) : void => {
3131 window . backend = channel . objects . backend ;
3232 setEngineVersion ( window . backend . engineVersion ) ;
3333 setRecentProjects ( window . backend . recentProjects ) ;
3434 setProjectTemplates ( window . backend . projectTemplates ) ;
35- } )
35+ } ) ;
3636 } , [ ] ) ;
3737
38- function onCreateProject ( ) : void
39- {
38+ function onCreateProject ( ) : void {
39+ // TODO
40+ console . error ( "onCreateProject()" ) ;
4041 window . backend . CreateProject ( ) ;
4142 }
4243
43- function onOpenProject ( e : PressEvent ) : void
44- {
44+ function onOpenProject ( e : PressEvent ) : void {
4545 // TODO
4646 const index = parseInt ( e . target . getAttribute ( 'data-key' ) as string ) ;
4747 console . error ( 'onOpenProject:' , index ) ;
4848 }
4949
50+ async function onBrowseProjectPath ( ) : Promise < void > {
51+ // TODO
52+ const dirHandle = await window . showDirectoryPicker ( { startIn : 'desktop' } ) ;
53+ console . error ( dirHandle ) ;
54+ }
55+
5056 return (
5157 < div className = 'h-screen p-6' >
5258 < div className = 'mb-4' >
5359 < User
54- avatarProps = { {
55- src : '/logo.png'
56- } }
60+ avatarProps = { { src : '/logo.png' } }
5761 description = {
5862 < div className = 'mt-1' >
59- < Chip className = 'ml-1' size = 'sm' color = 'secondary' variant = 'flat' > { engineVersion } </ Chip >
63+ < Chip className = 'ml-1' color = 'secondary' size = 'sm' variant = 'flat' >
64+ { engineVersion }
65+ </ Chip >
6066 </ div >
6167 }
62- name = 'Explosion Game Engine' />
68+ name = 'Explosion Game Engine'
69+ />
6370 </ div >
6471
6572 < Tabs isVertical = { true } >
66- < Tab title = 'Recently Projects' className = 'w-full pr-6' >
67- < ScrollShadow
68- hideScrollBar
69- className = 'h-[450px]'
70- size = { 60 } >
71- < Listbox
72- items = { recentProjects }
73- variant = 'flat' >
73+ < Tab className = 'w-full pr-6' title = 'Recently Projects' >
74+ < ScrollShadow hideScrollBar className = 'h-[450px]' size = { 60 } >
75+ < Listbox items = { recentProjects } variant = 'flat' >
7476 { recentProjects . map ( ( item , i ) => (
75- < ListboxItem key = { i } onPress = { onOpenProject } textValue = { item . name } >
76- < div className = 'flex gap-2 items-center' >
77- < Avatar alt = { item . name } className = 'shrink-0' size = 'sm' name = { item . name } />
78- < div className = 'flex flex-col' >
79- < span className = 'text-small' > { item . name } </ span >
80- < span className = 'text-tiny text-default-400' > { item . path } </ span >
81- </ div >
77+ < ListboxItem key = { i } textValue = { item . name } onPress = { onOpenProject } >
78+ < div className = 'flex gap-2 items-center' >
79+ < Avatar alt = { item . name } className = 'shrink-0' name = { item . name } size = 'sm' />
80+ < div className = 'flex flex-col' >
81+ < span className = 'text-small' > { item . name } </ span >
82+ < span className = 'text-tiny text-default-400' > { item . path } </ span >
8283 </ div >
83- </ ListboxItem >
84+ </ div >
85+ </ ListboxItem >
8486 ) ) }
8587 </ Listbox >
8688 </ ScrollShadow >
8789 </ Tab >
88- < Tab title = 'New Project' className = 'w-full pr-6' >
90+ < Tab className = 'w-full pr-6' title = 'New Project '>
8991 < Form className = 'w-full ml-4' >
90- < Input fullWidth isRequired label = 'Project Name' labelPlacement = 'outside' placeholder = 'HelloExplosion' />
91- < Input fullWidth isRequired label = 'Project Description' labelPlacement = 'outside' placeholder = 'A simple explosion game project.' />
92- < Input fullWidth isRequired label = 'Project Path' labelPlacement = 'outside' placeholder = '/path/to/your/project' />
93- < Select fullWidth isRequired label = 'Project Template' labelPlacement = 'outside' defaultSelectedKeys = { [ '0' ] } >
92+ < Input fullWidth isRequired label = 'Project Name' labelPlacement = 'outside' placeholder = 'HelloExplosion' />
93+ < div className = 'flex w-full' >
94+ < Input isRequired label = 'Project Path' labelPlacement = 'outside' placeholder = '/path/to/your/project' />
95+ < Button className = 'ml-2 mt-6' onPress = { ( ) => onBrowseProjectPath ( ) } >
96+ Browse
97+ </ Button >
98+ </ div >
99+ < Select fullWidth isRequired defaultSelectedKeys = { [ '0' ] } label = 'Project Template' labelPlacement = 'outside' >
94100 { projectTemplates . map ( ( item , i ) => (
95101 < SelectItem key = { i } > { item . name } </ SelectItem >
96102 ) ) }
97103 </ Select >
98- < Button color = 'primary' onPress = { onCreateProject } > Create</ Button >
104+ < Button color = 'primary' onPress = { onCreateProject } >
105+ Create
106+ </ Button >
99107 </ Form >
100108 </ Tab >
101109 </ Tabs >
102110 </ div >
103111 ) ;
104- } ;
112+ }
0 commit comments