TextEditor.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React, { useState } from 'react';
  2. import {View , Text, TextInput, Button,StyleSheet} from 'react-native';
  3. import { Icon } from 'react-native-elements'
  4. export default function TextEditor(props) {
  5. let [text, setText] = useState(props.text || '');
  6. let title = props.title || "Input";
  7. return (
  8. <View style={styles.container}>
  9. <Text style={[styles.title, styles.capFirst]}>{title}</Text>
  10. <TextInput style={styles.defaultInput}
  11. onChangeText={(text) => {
  12. props.onChange && props.onChange(text);
  13. setText(text);
  14. }}
  15. value={text}/>
  16. </View>
  17. );
  18. }
  19. const styles = StyleSheet.create({
  20. container:{
  21. padding:24,
  22. paddingTop: 0,
  23. flexDirection: 'row',
  24. justifyContent: 'space-between',
  25. alignItems: 'baseline'
  26. },
  27. capFirst: {
  28. fontSize: 14,
  29. fontFamily: 'roboto-light',
  30. textTransform: 'capitalize'
  31. },
  32. defaultInput: {
  33. marginTop:6,
  34. borderWidth:1,
  35. backgroundColor: 'white',
  36. boxShadow: '0px 3px 6px #00000029',
  37. borderColor: '#FFFFFF66',
  38. borderRadius: 14
  39. },
  40. title: {
  41. }
  42. })
  43. /*
  44. <View style={SideBarStyle.body}>
  45. <Text>{key}</Text>
  46. <TextInput
  47. style={{height: 40, borderColor: 'gray', borderWidth: 1}}
  48. onChangeText={(text) => this.editNode(text, key, Structure[key])}
  49. value={this.viewNode.props[key]}
  50. keyboardType={Structure[key].constructor.name === 'Interger' ? 'numeric':null}
  51. />
  52. </View>
  53. */