소스 검색

Import Export

Nikatlas 5 년 전
부모
커밋
ac52dbe944
6개의 변경된 파일42개의 추가작업 그리고 23개의 파일을 삭제
  1. 3 1
      App.css
  2. 2 1
      Components/TypeHandler.js
  3. 1 11
      Systems/Environment.js
  4. 7 8
      Systems/Gui.js
  5. 28 1
      Systems/SideBar.js
  6. 1 1
      yarn.lock

+ 3 - 1
App.css

@@ -61,7 +61,7 @@
   height: calc(100vh - 50px);
   background: #F1F1F1 0% 0% no-repeat padding-box;
   opacity: 1;
-
+  overflow: scroll;
 }
 
 
@@ -77,6 +77,8 @@
 
 .phone{
   margin:0 auto;
+  overflow-x: hidden;
+  overflow-y: hidden;
 }
 
  .pageNav{

+ 2 - 1
Components/TypeHandler.js

@@ -10,7 +10,8 @@ export default function(Type) {
 				return Editors.ColorEditor;
 			return Editors.TextEditor;
 		case Types.Number: 
-		case Types.Integer: 
+		case Types.Bool:
+		case Types.Integer:
 			return Editors.Numbers;
 		default: 
 			return Editors.TextEditor;

+ 1 - 11
Systems/Environment.js

@@ -85,17 +85,7 @@ export default class Environment extends BaseSystem {
 
 		return <View style={styles.container}>
           	<View style={styles.row}>
-              <View style={styles.button}>
-                <Button 
-                color="#D2691E"
-                onPress = {() => this.addRow()}
-                title={
-                  <Icon  name='add'
-                    color="#606060"
-                    containerStyle={{height:10}}
-                  />}
-                />
-              </View>
+              
             </View>
             <View style={[styles.row, styles.colHolders]}>
               {

+ 7 - 8
Systems/Gui.js

@@ -10,7 +10,7 @@ import Library from 'trapilib/dist/lib';
 import SideBar from './SideBar';
 import MainBar from  './MainBar';
 import ModuleBar from './ModuleBar';
-import { ViewNode } from 'trapilib/dist/lib/systems/ViewSystem';
+import { ViewNode, Node } from 'trapilib/dist/lib/systems/ViewSystem';
 import Environment from './Environment';
 import BaseSystem from './System';
 
@@ -122,15 +122,14 @@ export default class Gui extends BaseSystem {
 
   dropContent({event, data}) {
     data = JSON.parse(data);
-    let Node = this.CoreSystem.ray({event});
-    // Node.content
-    Node.props.selected = true;
-    console.log(Node, data);
+    let targetNode = this.CoreSystem.ray({event});
+    // targetNode.content
+    targetNode.props.selected = true;
+    console.log(targetNode, data);
     let node = new ViewNode(Math.random(), data.ctor, {}, data.namespace);
-    Node.content = node;
+    let containerNode = new Node(Math.random(), {}, node);
     let View = this.CoreSystem.getCurrentView();
-    //Node.isCol && Node.depth === 3 && View.addGrid(Node, 3,3);
-
+    View.addViewNode(containerNode, targetNode);
     console.log(node);
 
     this.forceUpdate();

+ 28 - 1
Systems/SideBar.js

@@ -1,7 +1,7 @@
 import React from 'react';
 import {StyleSheet, View, Text} from 'react-native';
 import Library from 'trapilib/dist/lib';
-import { TextInput, Image } from 'react-native';
+import { TextInput, Image, Button } from 'react-native';
 
 import TextEditor from '../Components/TextEditor';
 // import Numbers from '../Components/Numbers';
@@ -19,7 +19,18 @@ let {
 	ViewNode,
 	DataTypes
 } = Library; 
+function download(filename, text) {
+  var element = document.createElement('a');
+  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
+  element.setAttribute('download', filename);
 
+  element.style.display = 'none';
+  document.body.appendChild(element);
+
+  element.click();
+
+  document.body.removeChild(element);
+}
 export default class SideBar extends BaseSystem {
 	constructor(CoreSystem, ToolBox){
 		super();
@@ -27,6 +38,19 @@ export default class SideBar extends BaseSystem {
 		this.ToolBox = ToolBox;
 	}
 
+	import() {
+		let CurrentView = this.CoreSystem.getCurrentView();
+		let text = window.prompt("Feed me plz");
+		if(text) {
+			CurrentView.import(JSON.parse(text), this.ContainerNode.id);
+		}
+	}
+	export() {
+		let CurrentView = this.CoreSystem.getCurrentView();
+		let data = CurrentView.export();
+		download("Export_" + new Date().toISOString()+".txt", JSON.stringify(data));
+	}
+
 	removeNode(node) {
 		let CurrentView = this.CoreSystem.getCurrentView();
 		console.log(node)
@@ -52,6 +76,7 @@ export default class SideBar extends BaseSystem {
 		};
 		switch(Structure.type){
 			case DataTypes.Types.Integer:
+			case DataTypes.Types.Bool:
 				editorProps.number = viewNodeProps[key];
 				break;
 			case DataTypes.Types.Text:
@@ -105,6 +130,8 @@ export default class SideBar extends BaseSystem {
   				<View>
   					{this.ContainerNode && <View key={this.ContainerNode.id}>
   						<Text>Container</Text>
+  						<Button onPress={() => this.import()} title={'Import'}/>
+  						<Button onPress={() => this.export()} title={'Export'}/>
   						<TextEditor title="Inner Columns" 
   						text={this.ContainerNode && CurrentView.getChildren(this.ContainerNode).length +''} 
   						onChange={(cols) => {

+ 1 - 1
yarn.lock

@@ -5678,7 +5678,7 @@ [email protected]:
 
 "trapilib@git+http://git.onarbooks.com/Klapi/TrapiLib.git":
   version "1.0.7"
-  resolved "git+http://git.onarbooks.com/Klapi/TrapiLib.git#4aa88a69234c36d35f5607e193699d34471f8fbc"
+  resolved "git+http://git.onarbooks.com/Klapi/TrapiLib.git#911220acc05039b547251a4ef5d605de8540f5e2"
   dependencies:
     expo "^34.0.0-experiment.8"
     prop-types "^15.7.2"