ActionEditor.js 1.3 KB

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