Files
react-native-paper/example/src/TextInputExample.js
2018-02-26 13:17:25 +01:00

55 lines
1.1 KiB
JavaScript

/* @flow */
import * as React from 'react';
import { ScrollView, StyleSheet } from 'react-native';
import { TextInput, withTheme } from 'react-native-paper';
import type { Theme } from 'react-native-paper/types';
type Props = {
theme: Theme,
};
type State = {
text: string,
};
class TextInputExample extends React.Component<Props, State> {
static title = 'TextInput';
state = {
text: '',
};
render() {
const { theme: { colors: { background } } } = this.props;
return (
<ScrollView style={[styles.container, { backgroundColor: background }]}>
<TextInput
style={styles.inputContainerStyle}
label="Normal input"
placeholder="Type something"
value={this.state.text}
onChangeText={text => this.setState({ text })}
/>
<TextInput
disabled
style={styles.inputContainerStyle}
label="Disabled Input"
/>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 8,
},
inputContainerStyle: {
margin: 8,
},
});
export default withTheme(TextInputExample);