ActionEditor.js 1.5 KB

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