Text.js 710 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from 'react';
  2. import Module from '../lib/Module';
  3. import {StyleSheet ,TextInput, View, Text } from 'react-native';
  4. import Types from '../lib/Types';
  5. export default class TextComp extends Module {
  6. constructor(props) {
  7. super(props);
  8. this.state = {
  9. text: props.text || ""
  10. }
  11. }
  12. display() {
  13. let {
  14. color,
  15. fontSize
  16. } = this.props;
  17. return (
  18. <View>
  19. <TextInput
  20. style={{color, fontSize}]}
  21. onChangeText={(text) => this.setState({
  22. text
  23. })}
  24. value={this.state.text || 'Default Text'}/>
  25. {this.props.children}
  26. </View>)
  27. }
  28. }
  29. TextComp.Inputs = {
  30. color: new Types.Text(),
  31. fontSize: new Types.Integer().default(22)
  32. }