mirror of
https://github.com/zhigang1992/react-native-paper.git
synced 2026-06-11 08:13:29 +08:00
59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
/* @flow */
|
|
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
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';
|
|
static propTypes = {
|
|
theme: PropTypes.object.isRequired,
|
|
};
|
|
|
|
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);
|