Browse Source

Picker
marginBottom:20

sxoinas12 5 years ago
parent
commit
751033b48b
3 changed files with 70 additions and 42 deletions
  1. 62 36
      Components/ActionEditor.js
  2. 1 1
      yalc.lock
  3. 7 5
      yarn.lock

+ 62 - 36
Components/ActionEditor.js

@@ -1,55 +1,81 @@
 import React, { useState } from 'react';
-import {View, Text, TextInput, StyleSheet} from 'react-native';
+import { View, Text, TextInput, StyleSheet } from 'react-native';
+import InjectionSystem from 'trapilib/dist/lib/systems/InjectionSystem';
+import { Picker } from 'react-native';
+
+
 
 export default function ActionEditor(props) {
 	let [action, setAction] = useState(props.value || {});
-	if(!action.data || typeof action.data !== "object") action.data = {};
+
+	let ActionSystem = InjectionSystem.inject('Actions');
+	let RoutingSystem = InjectionSystem.inject('Routing');
+	let Routes = RoutingSystem.topology.nodes
+	if (!action.data || typeof action.data !== "object") action.data = {};
+	if (!action.type) action.type = ActionSystem.constructor.Actions[0].id
 	return (
-			<View style={styles.container}>
-				<Text>{props.title}</Text>
-				<View style={styles.row}>
-					<Text style={[styles.title, styles.capFirst]}>Type</Text>
-					<TextInput style={styles.defaultInput} 
-						onChangeText={(text) => {
-							action.type = text;
-							props.onChange && props.onChange(action);
-							setAction(action);
-						}}
-	    				value={action.type}/>
-	    		</View>
-	    		<View style={styles.row}>
-					<Text style={[styles.title, styles.capFirst]}>Data</Text>
-					<TextInput style={styles.defaultInput} 
-						onChangeText={(text) => {
-							action.data.route = text;
-							props.onChange && props.onChange(action);
-							setAction(action);
-						}}
-	    				value={action.data.route}/>
-	    		</View>
+		<View style={styles.container}>
+
+			<Text>{props.title}</Text>
+
+			<View style={styles.row}>
+			<Text>Action</Text>
+			<Picker
+				selectedValue={action.name}
+				style={styles.picker}
+				onValueChange={(itemValue, itemIndex) => {
+					action.type = itemValue;
+					props.onChange && props.onChange(action);
+					setAction(action)
+				}}>
+				{ActionSystem.constructor.Actions.map((itemAction, index) => {
+					return <Picker.Item label={itemAction.name} value={itemAction.id} key={index} />
+				})}
+				<Picker.Item label="java" value="java" />
+			</Picker>
+			</View>
+
+
+			<View style={styles.row}>
+
+			<Text>Page</Text>
+			<Picker
+				selectedValue={action.data.route}
+				style={styles.picker}
+				onValueChange={(itemValue, itemIndex) => {
+					action.data.route = itemValue;
+					props.onChange && props.onChange(action);
+					setAction(action)
+				}}>
+				{Object.keys(Routes).map((k, index) => {
+					return <Picker.Item label={k} value={k} key={index} />
+				})}
+			</Picker>
+
 			</View>
-		);
+		</View>
+	);
 }
 
 const styles = StyleSheet.create({
-	container:{
+	container: {
 		flexDirection: 'column',
 		borderBottomWidth: 1,
-		borderColor: '#cecece'
-	},
-	row: {
-		flexDirection: 'row',
-		alignItems: 'baseline',
-		justifyContent: 'space-between',
+		borderColor: '#cecece',
 	},
 	capFirst: {
-		fontSize: 14, 
+		fontSize: 14,
 		fontFamily: 'roboto-light',
 		textTransform: 'capitalize'
 	},
-	defaultInput: {
-		marginTop:6,
-		borderWidth:1,
+	row:{
+		flexDirection:'row',
+		justifyContent:"space-between",
+		alignItems:"center"
+	},
+	picker: {
+		marginTop: 6,
+		borderWidth: 1,
 		backgroundColor: 'white',
 		boxShadow: '0px 3px 6px #00000029',
 		borderColor: '#FFFFFF66',

+ 1 - 1
yalc.lock

@@ -2,7 +2,7 @@
   "version": "v1",
   "packages": {
     "trapilib": {
-      "signature": "cf96fc6204772a75bdfad98acff332df",
+      "signature": "ae902bb0a77423399c9515e6e0c67522",
       "file": true,
       "replaced": "http://git.onarbooks.com/Klapi/TrapiLib.git"
     }

+ 7 - 5
yarn.lock

@@ -5306,9 +5306,9 @@ scheduler@^0.15.0:
     object-assign "^4.1.1"
 
 schema-utils@^2.0.1:
-  version "2.2.0"
-  resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.2.0.tgz#48a065ce219e0cacf4631473159037b2c1ae82da"
-  integrity sha512-5EwsCNhfFTZvUreQhx/4vVQpJ/lnCAkgoIHLhSpp4ZirE+4hzFvdJi0FMub6hxbFVBJYSpeVVmon+2e7uEGRrA==
+  version "2.4.0"
+  resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.4.0.tgz#44947c4da4d798a3080ec2343249f9d8e4231fd6"
+  integrity sha512-VJEKOvjynJweKWFgxaikuP22zl9JwvmylH/cW1dIKZyp3DS1adBGaYPtZ6CdBSxtfP0LwQY1gNA4rIMJsnammQ==
   dependencies:
     ajv "^6.10.2"
     ajv-keywords "^3.4.1"
@@ -5780,7 +5780,7 @@ [email protected]:
   integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
 
 "trapilib@file:.yalc/trapilib":
-  version "1.1.1-cf96fc62"
+  version "1.1.1-ae902bb0"
   dependencies:
     css "^2.2.4"
     expo "^33.0.0"
@@ -5795,11 +5795,13 @@ [email protected]:
 
 "trapilib@http://git.onarbooks.com/Klapi/TrapiLib.git":
   version "1.1.1"
-  resolved "http://git.onarbooks.com/Klapi/TrapiLib.git#b6826b13bb24ff1b724d34da493ea4d3582d1a20"
+  resolved "http://git.onarbooks.com/Klapi/TrapiLib.git#812767711c6dca07676573f2e619071d01b736dd"
   dependencies:
+    css "^2.2.4"
     expo "^33.0.0"
     native-base "^2.13.8"
     prop-types "^15.7.2"
+    raw-loader "^3.1.0"
     react "16.8.3"
     react-dom "^16.8.6"
     react-native "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz"