/** * The examples provided by Facebook are for non-commercial testing and * evaluation purposes only. * * Facebook reserves all rights not expressly granted. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * @flow */ 'use strict'; var React = require('react-native'); var { Text, TextInput, View, StyleSheet, } = React; var TextEventsExample = React.createClass({ getInitialState: function() { return { curText: '', prevText: '', prev2Text: '', }; }, updateText: function(text) { this.setState((state) => { return { curText: text, prevText: state.curText, prev2Text: state.prevText, }; }); }, render: function() { return ( this.updateText('onFocus')} onBlur={() => this.updateText('onBlur')} onChange={(event) => this.updateText( 'onChange text: ' + event.nativeEvent.text )} onEndEditing={(event) => this.updateText( 'onEndEditing text: ' + event.nativeEvent.text )} onSubmitEditing={(event) => this.updateText( 'onSubmitEditing text: ' + event.nativeEvent.text )} style={styles.singleLine} /> {this.state.curText}{'\n'} (prev: {this.state.prevText}){'\n'} (prev2: {this.state.prev2Text}) ); } }); class RewriteExample extends React.Component { constructor(props) { super(props); this.state = {text: ''}; } render() { return ( { text = text.replace(/ /g, '_'); this.setState({text}); }} style={styles.singleLine} value={this.state.text} /> ); } } var styles = StyleSheet.create({ multiline: { height: 60, fontSize: 16, padding: 4, marginBottom: 10, }, eventLabel: { margin: 3, fontSize: 12, }, singleLine: { fontSize: 16, padding: 4, }, singleLineWithHeightTextInput: { height: 30, }, }); exports.title = ''; exports.description = 'Single and multi-line text inputs.'; exports.examples = [ { title: 'Auto-focus', render: function() { return ; } }, { title: "Live Re-Write ( -> '_')", render: function() { return ; } }, { title: 'Auto-capitalize', render: function() { var autoCapitalizeTypes = [ 'none', 'sentences', 'words', 'characters', ]; var examples = autoCapitalizeTypes.map((type) => { return ( ); }); return {examples}; } }, { title: 'Auto-correct', render: function() { return ( ); } }, { title: 'Keyboard types', render: function() { var keyboardTypes = [ 'default', 'email-address', 'numeric', ]; var examples = keyboardTypes.map((type) => { return ( ); }); return {examples}; } }, { title: 'Event handling', render: function(): ReactElement { return ; }, }, { title: 'Colors and text inputs', render: function() { return ( Darker backgroundColor ); } }, { title: 'Text input, themes and heights', render: function() { return ( ); } }, { title: 'Passwords', render: function() { return ( ); } }, { title: 'Editable', render: function() { return ( ); } }, { title: 'Multiline', render: function() { return ( multiline with children, aligned bottom-right ); } }, { title: 'Fixed number of lines', platform: 'android', render: function() { return ( ); } }, ];