From 687f12f6bf82a97ba55a8039fbcbf3ecacaa8200 Mon Sep 17 00:00:00 2001 From: aleclarson Date: Tue, 26 Feb 2019 16:35:14 -0500 Subject: [PATCH] test: sync TextInputExample with upstream/0.54-stable --- RNTester/js/TextInputExample.macos.js | 1115 +++++++++++++++---------- 1 file changed, 662 insertions(+), 453 deletions(-) diff --git a/RNTester/js/TextInputExample.macos.js b/RNTester/js/TextInputExample.macos.js index 7246a025a1..c2a73781a7 100644 --- a/RNTester/js/TextInputExample.macos.js +++ b/RNTester/js/TextInputExample.macos.js @@ -1,24 +1,20 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * + * @format * @flow - * @providesModule TextInputExample */ + 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var { - Text, - TextInput, - View, - StyleSheet, -} = ReactNative; +const Button = require('Button'); +const InputAccessoryView = require('InputAccessoryView'); +const React = require('react'); +const ReactNative = require('react-native'); +const {Text, TextInput, View, StyleSheet, Slider, Switch, Alert} = ReactNative; class WithLabel extends React.Component<$FlowFixMeProps> { render() { @@ -41,8 +37,8 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> { prev3Text: '', }; - updateText = (text) => { - this.setState((state) => { + updateText = text => { + this.setState(state => { return { curText: text, prevText: state.curText, @@ -56,32 +52,36 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> { 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 - )} - onSelectionChange={(event) => this.updateText( - 'onSelectionChange range: ' + - event.nativeEvent.selection.start + ',' + - event.nativeEvent.selection.end - )} - onKeyPress={(event) => { + 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) + } + onSelectionChange={event => + this.updateText( + 'onSelectionChange range: ' + + event.nativeEvent.selection.start + + ',' + + (event.nativeEvent.selection.end || ''), + ) + } + onKeyPress={event => { this.updateText('onKeyPress key: ' + event.nativeEvent.key); }} style={styles.default} /> - {this.state.curText}{'\n'} + {this.state.curText} + {'\n'} (prev: {this.state.prevText}){'\n'} (prev2: {this.state.prev2Text}){'\n'} (prev3: {this.state.prev3Text}) @@ -91,21 +91,56 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> { } } +class TextInputAccessoryViewExample extends React.Component<{}, *> { + /* $FlowFixMe(>=0.85.0 site=react_native_ios_fb) This comment suppresses an + * error found when Flow v0.85 was deployed. To see the error, delete this + * comment and run Flow. */ + constructor(props) { + super(props); + this.state = {text: 'Placeholder Text'}; + } + + render() { + const inputAccessoryViewID = 'inputAccessoryView1'; + return ( + + this.setState({text})} + value={this.state.text} + /> + + +