ActionEditor.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React, { useState } from 'react';
  2. import {View, Text, TextInput, StyleSheet} from 'react-native';
  3. export default function ActionEditor(props) {
  4. let [action, setAction] = useState(props.value || {});
  5. if(!action.data || typeof action.data !== "object") action.data = {};
  6. return (
  7. <View style={styles.container}>
  8. <Text>{props.title}</Text>
  9. <View style={styles.row}>
  10. <Text style={[styles.title, styles.capFirst]}>Type</Text>
  11. <TextInput style={styles.defaultInput}
  12. onChangeText={(text) => {
  13. action.type = text;
  14. props.onChange && props.onChange(action);
  15. setAction(action);
  16. }}
  17. value={action.type}/>
  18. </View>
  19. <View style={styles.row}>
  20. <Text style={[styles.title, styles.capFirst]}>Data</Text>
  21. <TextInput style={styles.defaultInput}
  22. onChangeText={(text) => {
  23. action.data.route = text;
  24. props.onChange && props.onChange(action);
  25. setAction(action);
  26. }}
  27. value={action.data.route}/>
  28. </View>
  29. </View>
  30. );
  31. }
  32. const styles = StyleSheet.create({
  33. container:{
  34. flexDirection: 'column',
  35. borderBottomWidth: 1,
  36. borderColor: '#cecece'
  37. },
  38. row: {
  39. flexDirection: 'row',
  40. alignItems: 'baseline',
  41. justifyContent: 'space-between',
  42. },
  43. capFirst: {
  44. fontSize: 14,
  45. fontFamily: 'roboto-light',
  46. textTransform: 'capitalize'
  47. },
  48. defaultInput: {
  49. marginTop:6,
  50. borderWidth:1,
  51. backgroundColor: 'white',
  52. boxShadow: '0px 3px 6px #00000029',
  53. borderColor: '#FFFFFF66',
  54. borderRadius: 14
  55. },
  56. title: {
  57. }
  58. })