@@ -10,6 +10,8 @@ import {
1010 FaUndo ,
1111 FaCopy ,
1212 FaChevronLeft ,
13+ FaLaptopCode ,
14+ FaMobileAlt ,
1315} from "react-icons/fa" ;
1416
1517import { AiFillCodepenCircle } from "react-icons/ai" ;
@@ -25,7 +27,7 @@ import toast from "react-hot-toast";
2527import { UploadFileContext } from './contexts/UploadFileContext' ;
2628import { SettingContext } from './contexts/SettingContext' ;
2729import { HistoryContext } from './contexts/HistoryContext' ;
28- import { EditorContext } from './contexts/EditorContext' ;
30+ import { EditorContext , deviceType } from './contexts/EditorContext' ;
2931import NativePreview from './components/NativeMobile' ;
3032import { TemplateContext } from './contexts/TemplateContext' ;
3133import UpdateChatInput from './components/chatInput/Update' ;
@@ -78,7 +80,7 @@ function App() {
7880 const { settings, setSettings, initCreate, setInitCreate, initCreateText, setInitCreateText} = useContext ( SettingContext ) ;
7981
8082 const { history, addHistory, currentVersion, setCurrentVersion, resetHistory, updateHistoryCode} = useContext ( HistoryContext ) ;
81- const { enableEdit, setEnableEdit } = useContext ( EditorContext )
83+ const { enableEdit, setEnableEdit, device , setDevice } = useContext ( EditorContext )
8284 const [ tabValue , setTabValue ] = useState < string > ( settings . generatedCodeConfig == GeneratedCodeConfig . REACT_NATIVE ? 'native' : 'desktop' )
8385 const [ template , setTemplate ] = useState < any > ( { } ) ;
8486 const [ openDialog , setOpenDialog ] = useState < boolean > ( false ) ;
@@ -520,6 +522,25 @@ ${error.stack}
520522 >
521523 < FaDownload />
522524 </ span >
525+ < span
526+ className = "hover:bg-slate-200 rounded-sm w-[36px] h-[36px] flex items-center justify-center border-black border-2"
527+ onClick = { ( ) => {
528+ if ( device === deviceType . PC ) {
529+ setDevice ( deviceType . MOBILE )
530+ } else {
531+ setDevice ( deviceType . PC )
532+ }
533+ } }
534+ >
535+ {
536+ device === deviceType . PC ? (
537+ < FaLaptopCode className = "w-[20px]" />
538+ ) : (
539+ < FaMobileAlt className = "h-[20px]" />
540+ )
541+ }
542+
543+ </ span >
523544 < span
524545 className = { classNames (
525546 "hover:bg-slate-200 rounded-full border-black border-2 w-[36px] h-[36px] flex items-center justify-center" ,
@@ -583,11 +604,19 @@ ${error.stack}
583604
584605 < div
585606 className = {
586- classNames ( 'h-full' , {
607+ classNames ( 'h-full flex justify-center ' , {
587608 'hidden' : tabValue !== 'desktop'
588609 } )
589610 }
590- >
611+ >
612+ < div
613+ className = {
614+ classNames ( "h-full" , {
615+ "w-full" : device === deviceType . PC ,
616+ "w-[375px]" : device === deviceType . MOBILE
617+ }
618+ ) }
619+ >
591620 < PreviewBox
592621 code = { generatedCode }
593622 appState = { appState }
@@ -598,6 +627,8 @@ ${error.stack}
598627 history = { history }
599628 fixBug = { fixBug }
600629 />
630+ </ div >
631+
601632 { /* <Preview code={generatedCode} device="desktop" appState={appState} fixBug={fixBug}/> */ }
602633 </ div >
603634 < div
0 commit comments