|
@@ -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) => {
|