TextEditor.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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}>{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:10
  22. },
  23. defaultInput: {
  24. marginTop:6,
  25. borderWidth:1,
  26. width:200
  27. },
  28. title: {
  29. }
  30. })
  31. /*
  32. <View style={SideBarStyle.body}>
  33. <Text>{key}</Text>
  34. <TextInput
  35. style={{height: 40, borderColor: 'gray', borderWidth: 1}}
  36. onChangeText={(text) => this.editNode(text, key, Structure[key])}
  37. value={this.viewNode.props[key]}
  38. keyboardType={Structure[key].constructor.name === 'Interger' ? 'numeric':null}
  39. />
  40. </View>
  41. */