//import CoreSystem from 'core-system'; import ToolBox from './ToolBox'; import Keyboard from './keyboard'; import Mouse from './mouse'; import React from 'react'; import {StyleSheet, View, Text} from 'react-native'; import Library from 'trapilib/dist/lib'; import SideBar from './SideBar'; import MainBar from './MainBar'; import ModuleBar from './ModuleBar'; let { CoreSystem, ViewSystem } = Library; export default class Gui { constructor() { this.ModuleBar = new ModuleBar(); this.Keyboard = new Keyboard(); this.phoneRef = React.createRef(); this.phone = this.phoneRef; this.toolboxRef = React.createRef(); this.toolbox = this.toolboxRef; this.CoreSystem = { render: () => null}; this.ToolBox = new ToolBox(); this.MainBar = new MainBar(); this.load(); this.__onUpdate = null; this.SideBar = new SideBar(); this.ToolBox.onUpdate( () =>{ let SideBarProps = { tool:this.ToolBox.activeTool } this.SideBar = new SideBar(SideBarProps) this.forceUpdate() }) this.MainBar.onSave( () => { this.saveEnv(); this.forceUpdate() }) } onMount() { if(this.phone){ // thats fine this.ToolBoxMouse = new Mouse(this.toolbox.current); this.phoneMouse = new Mouse(this.phone.current); } if(this.ToolBoxMouse !== undefined){ this.ToolBoxMouse.listen() .on('LeftDown',(e) => this.ToolManagement(e)) this.phoneMouse.listen() .on('LeftDown',(e) => this.ToolManagement(e)) } } saveEnv(){ let env = this.CoreSystem.export(); localStorage.setItem('environment', JSON.stringify(env)); this.forceUpdate(); try{ this.CoreSystem.import(JSON.parse(js)); this.forceUpdate(); } catch(e) { console.log(e); } } ToolManagement(e){ console.log("whattttt") if(this.ToolBox.activeTool === null){ return null; }else{ this.processElement(e) } } onUpdate(fn){ this.__onUpdate = fn } forceUpdate(){ this.__onUpdate && this.__onUpdate(); } load() { this.CoreSystem = new CoreSystem(); this.ToolBox = new ToolBox(this.CoreSystem.ViewSystem); try{ let env = localStorage.getItem('environment'); if( env === null){ this.CoreSystem.import(JSON.parse(jsLoad)); }else{ this.CoreSystem.import(JSON.parse(env)); } this.forceUpdate(); } catch(e) { console.log(e); } } processElement(event){ console.log(event) console.log('sdasdwd') let ViewNode = this.CoreSystem.ray({event}) let NewNode = this.ToolBox.editNode(ViewNode); this.forceUpdate(); } mobileRender(){ return (