mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +00:00
Converting Libraries/Components to not use var
Reviewed By: sahrens Differential Revision: D7117137 fbshipit-source-id: a55a04928a0073a17e0709e851aa8b11678042ba
This commit is contained in:
parent
f7343576fc
commit
3152e93095
@ -9,18 +9,18 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var NativeModules = require('NativeModules');
|
||||
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
const NativeModules = require('NativeModules');
|
||||
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
|
||||
var RCTAccessibilityInfo = NativeModules.AccessibilityInfo;
|
||||
const RCTAccessibilityInfo = NativeModules.AccessibilityInfo;
|
||||
|
||||
var TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange';
|
||||
const TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange';
|
||||
|
||||
type ChangeEventName = $Enum<{
|
||||
change: string,
|
||||
}>;
|
||||
|
||||
var _subscriptions = new Map();
|
||||
const _subscriptions = new Map();
|
||||
|
||||
/**
|
||||
* Sometimes it's useful to know whether or not the device has a screen reader
|
||||
@ -32,7 +32,7 @@ var _subscriptions = new Map();
|
||||
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html
|
||||
*/
|
||||
|
||||
var AccessibilityInfo = {
|
||||
const AccessibilityInfo = {
|
||||
|
||||
fetch: function(): Promise {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -48,7 +48,7 @@ var AccessibilityInfo = {
|
||||
eventName: ChangeEventName,
|
||||
handler: Function
|
||||
): void {
|
||||
var listener = RCTDeviceEventEmitter.addListener(
|
||||
const listener = RCTDeviceEventEmitter.addListener(
|
||||
TOUCH_EXPLORATION_EVENT,
|
||||
(enabled) => {
|
||||
handler(enabled);
|
||||
@ -61,7 +61,7 @@ var AccessibilityInfo = {
|
||||
eventName: ChangeEventName,
|
||||
handler: Function
|
||||
): void {
|
||||
var listener = _subscriptions.get(handler);
|
||||
const listener = _subscriptions.get(handler);
|
||||
if (!listener) {
|
||||
return;
|
||||
}
|
||||
|
@ -9,21 +9,21 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var NativeModules = require('NativeModules');
|
||||
var Promise = require('Promise');
|
||||
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
const NativeModules = require('NativeModules');
|
||||
const Promise = require('Promise');
|
||||
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
|
||||
var AccessibilityManager = NativeModules.AccessibilityManager;
|
||||
const AccessibilityManager = NativeModules.AccessibilityManager;
|
||||
|
||||
var VOICE_OVER_EVENT = 'voiceOverDidChange';
|
||||
var ANNOUNCEMENT_DID_FINISH_EVENT = 'announcementDidFinish';
|
||||
const VOICE_OVER_EVENT = 'voiceOverDidChange';
|
||||
const ANNOUNCEMENT_DID_FINISH_EVENT = 'announcementDidFinish';
|
||||
|
||||
type ChangeEventName = $Enum<{
|
||||
change: string,
|
||||
announcementFinished: string
|
||||
}>;
|
||||
|
||||
var _subscriptions = new Map();
|
||||
const _subscriptions = new Map();
|
||||
|
||||
/**
|
||||
* Sometimes it's useful to know whether or not the device has a screen reader
|
||||
@ -34,7 +34,7 @@ var _subscriptions = new Map();
|
||||
*
|
||||
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html
|
||||
*/
|
||||
var AccessibilityInfo = {
|
||||
const AccessibilityInfo = {
|
||||
|
||||
/**
|
||||
* Query whether a screen reader is currently enabled.
|
||||
@ -72,7 +72,7 @@ var AccessibilityInfo = {
|
||||
eventName: ChangeEventName,
|
||||
handler: Function
|
||||
): Object {
|
||||
var listener;
|
||||
let listener;
|
||||
|
||||
if (eventName === 'change') {
|
||||
listener = RCTDeviceEventEmitter.addListener(
|
||||
@ -127,7 +127,7 @@ var AccessibilityInfo = {
|
||||
eventName: ChangeEventName,
|
||||
handler: Function
|
||||
): void {
|
||||
var listener = _subscriptions.get(handler);
|
||||
const listener = _subscriptions.get(handler);
|
||||
if (!listener) {
|
||||
return;
|
||||
}
|
||||
|
@ -8,12 +8,12 @@
|
||||
* @flow
|
||||
*/
|
||||
'use strict';
|
||||
var PropTypes = require('prop-types');
|
||||
const PropTypes = require('prop-types');
|
||||
|
||||
/**
|
||||
* Additional View properties for Apple TV
|
||||
*/
|
||||
var TVViewPropTypes = {
|
||||
const TVViewPropTypes = {
|
||||
/**
|
||||
* *(Apple TV only)* When set to true, this view will be focusable
|
||||
* and navigable using the Apple TV remote.
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var Text = require('Text');
|
||||
var View = require('View');
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
const View = require('View');
|
||||
|
||||
class DummyDatePickerIOS extends React.Component {
|
||||
render() {
|
||||
@ -24,7 +24,7 @@ class DummyDatePickerIOS extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
dummyDatePickerIOS: {
|
||||
height: 100,
|
||||
width: 300,
|
||||
|
@ -8,28 +8,28 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var Platform = require('Platform');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNative = require('ReactNative');
|
||||
var StatusBar = require('StatusBar');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var UIManager = require('UIManager');
|
||||
var View = require('View');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNative = require('ReactNative');
|
||||
const StatusBar = require('StatusBar');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const UIManager = require('UIManager');
|
||||
const View = require('View');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var DrawerConsts = UIManager.AndroidDrawerLayout.Constants;
|
||||
const DrawerConsts = UIManager.AndroidDrawerLayout.Constants;
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var dismissKeyboard = require('dismissKeyboard');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const createReactClass = require('create-react-class');
|
||||
const dismissKeyboard = require('dismissKeyboard');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
var RK_DRAWER_REF = 'drawerlayout';
|
||||
var INNERVIEW_REF = 'innerView';
|
||||
const RK_DRAWER_REF = 'drawerlayout';
|
||||
const INNERVIEW_REF = 'innerView';
|
||||
|
||||
var DRAWER_STATES = [
|
||||
const DRAWER_STATES = [
|
||||
'Idle',
|
||||
'Dragging',
|
||||
'Settling',
|
||||
@ -66,7 +66,7 @@ var DRAWER_STATES = [
|
||||
* },
|
||||
* ```
|
||||
*/
|
||||
var DrawerLayoutAndroid = createReactClass({
|
||||
const DrawerLayoutAndroid = createReactClass({
|
||||
displayName: 'DrawerLayoutAndroid',
|
||||
statics: {
|
||||
positions: DrawerConsts.DrawerPosition,
|
||||
@ -169,8 +169,8 @@ var DrawerLayoutAndroid = createReactClass({
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var drawStatusBar = Platform.Version >= 21 && this.props.statusBarBackgroundColor;
|
||||
var drawerViewWrapper =
|
||||
const drawStatusBar = Platform.Version >= 21 && this.props.statusBarBackgroundColor;
|
||||
const drawerViewWrapper =
|
||||
<View
|
||||
style={[
|
||||
styles.drawerSubview,
|
||||
@ -180,7 +180,7 @@ var DrawerLayoutAndroid = createReactClass({
|
||||
{this.props.renderNavigationView()}
|
||||
{drawStatusBar && <View style={styles.drawerStatusBar} />}
|
||||
</View>;
|
||||
var childrenWrapper =
|
||||
const childrenWrapper =
|
||||
<View ref={INNERVIEW_REF} style={styles.mainSubview} collapsable={false}>
|
||||
{drawStatusBar &&
|
||||
<StatusBar
|
||||
@ -282,7 +282,7 @@ var DrawerLayoutAndroid = createReactClass({
|
||||
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
base: {
|
||||
flex: 1,
|
||||
elevation: 16,
|
||||
@ -313,6 +313,6 @@ var styles = StyleSheet.create({
|
||||
});
|
||||
|
||||
// The View that contains both the actual drawer and the main view
|
||||
var AndroidDrawerLayout = requireNativeComponent('AndroidDrawerLayout', DrawerLayoutAndroid);
|
||||
const AndroidDrawerLayout = requireNativeComponent('AndroidDrawerLayout', DrawerLayoutAndroid);
|
||||
|
||||
module.exports = DrawerLayoutAndroid;
|
||||
|
@ -8,12 +8,12 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
var createReactClass = require('create-react-class');
|
||||
var PropTypes = require('prop-types');
|
||||
var TimerMixin = require('react-timer-mixin');
|
||||
const React = require('React');
|
||||
const createReactClass = require('create-react-class');
|
||||
const PropTypes = require('prop-types');
|
||||
const TimerMixin = require('react-timer-mixin');
|
||||
|
||||
var LazyRenderer = createReactClass({
|
||||
const LazyRenderer = createReactClass({
|
||||
displayName: 'LazyRenderer',
|
||||
mixin: [TimerMixin],
|
||||
|
||||
|
@ -9,30 +9,30 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var EventEmitter = require('EventEmitter');
|
||||
var Image = require('Image');
|
||||
var RCTNavigatorManager = require('NativeModules').NavigatorManager;
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNative = require('ReactNative');
|
||||
var StaticContainer = require('StaticContainer.react');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var TVEventHandler = require('TVEventHandler');
|
||||
var View = require('View');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
const EventEmitter = require('EventEmitter');
|
||||
const Image = require('Image');
|
||||
const RCTNavigatorManager = require('NativeModules').NavigatorManager;
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNative = require('ReactNative');
|
||||
const StaticContainer = require('StaticContainer.react');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const TVEventHandler = require('TVEventHandler');
|
||||
const View = require('View');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const createReactClass = require('create-react-class');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
const keyMirror = require('fbjs/lib/keyMirror');
|
||||
|
||||
var TRANSITIONER_REF = 'transitionerRef';
|
||||
const TRANSITIONER_REF = 'transitionerRef';
|
||||
|
||||
var __uid = 0;
|
||||
let __uid = 0;
|
||||
function getuid() {
|
||||
return __uid++;
|
||||
}
|
||||
@ -305,7 +305,7 @@ type Event = Object;
|
||||
* is pushed.
|
||||
*
|
||||
*/
|
||||
var NavigatorIOS = createReactClass({
|
||||
const NavigatorIOS = createReactClass({
|
||||
displayName: 'NavigatorIOS',
|
||||
|
||||
propTypes: {
|
||||
@ -584,7 +584,7 @@ var NavigatorIOS = createReactClass({
|
||||
|
||||
_getFocusEmitter: function(): EventEmitter {
|
||||
// Flow not yet tracking assignments to instance fields.
|
||||
var focusEmitter = this._focusEmitter;
|
||||
let focusEmitter = this._focusEmitter;
|
||||
if (!focusEmitter) {
|
||||
focusEmitter = new EventEmitter();
|
||||
this._focusEmitter = focusEmitter;
|
||||
@ -614,13 +614,13 @@ var NavigatorIOS = createReactClass({
|
||||
},
|
||||
|
||||
_handleNavigatorStackChanged: function(e: Event) {
|
||||
var newObservedTopOfStack = e.nativeEvent.stackLength - 1;
|
||||
const newObservedTopOfStack = e.nativeEvent.stackLength - 1;
|
||||
|
||||
invariant(
|
||||
newObservedTopOfStack <= this.state.requestedTopOfStack,
|
||||
'No navigator item should be pushed without JS knowing about it %s %s', newObservedTopOfStack, this.state.requestedTopOfStack
|
||||
);
|
||||
var wasWaitingForConfirmation =
|
||||
const wasWaitingForConfirmation =
|
||||
this.state.requestedTopOfStack !== this.state.observedTopOfStack;
|
||||
if (wasWaitingForConfirmation) {
|
||||
invariant(
|
||||
@ -638,7 +638,7 @@ var NavigatorIOS = createReactClass({
|
||||
// Progress isn't always 0 or 1 at the end, the system rounds
|
||||
// If the Navigator is offscreen these values won't be updated
|
||||
// TOOD: Revisit this decision when no longer relying on native navigator.
|
||||
var nextState = {
|
||||
const nextState = {
|
||||
observedTopOfStack: newObservedTopOfStack,
|
||||
makingNavigatorRequest: false,
|
||||
updatingAllIndicesAtOrBeyond: null,
|
||||
@ -653,7 +653,7 @@ var NavigatorIOS = createReactClass({
|
||||
// Updating the indices that we're deleting and that's all. (Truth: Nothing
|
||||
// even uses the indices in this case, but let's make this describe the
|
||||
// truth anyways).
|
||||
var updatingAllIndicesAtOrBeyond =
|
||||
const updatingAllIndicesAtOrBeyond =
|
||||
this.state.routeStack.length > this.state.observedTopOfStack + 1 ?
|
||||
this.state.observedTopOfStack + 1 :
|
||||
null;
|
||||
@ -677,8 +677,8 @@ var NavigatorIOS = createReactClass({
|
||||
if (this.state.requestedTopOfStack === this.state.observedTopOfStack) {
|
||||
this._tryLockNavigator(() => {
|
||||
|
||||
var nextStack = this.state.routeStack.concat([route]);
|
||||
var nextIDStack = this.state.idStack.concat([getuid()]);
|
||||
const nextStack = this.state.routeStack.concat([route]);
|
||||
const nextIDStack = this.state.idStack.concat([getuid()]);
|
||||
this.setState({
|
||||
// We have to make sure that we've also supplied enough views to
|
||||
// satisfy our request to adjust the `requestedTopOfStack`.
|
||||
@ -704,7 +704,7 @@ var NavigatorIOS = createReactClass({
|
||||
if (this.state.requestedTopOfStack === this.state.observedTopOfStack) {
|
||||
if (this.state.requestedTopOfStack > 0) {
|
||||
this._tryLockNavigator(() => {
|
||||
var newRequestedTopOfStack = this.state.requestedTopOfStack - n;
|
||||
const newRequestedTopOfStack = this.state.requestedTopOfStack - n;
|
||||
invariant(newRequestedTopOfStack >= 0, 'Cannot pop below 0');
|
||||
this.setState({
|
||||
requestedTopOfStack: newRequestedTopOfStack,
|
||||
@ -742,8 +742,8 @@ var NavigatorIOS = createReactClass({
|
||||
|
||||
// I don't believe we need to lock for a replace since there's no
|
||||
// navigation actually happening
|
||||
var nextIDStack = this.state.idStack.slice();
|
||||
var nextRouteStack = this.state.routeStack.slice();
|
||||
const nextIDStack = this.state.idStack.slice();
|
||||
const nextRouteStack = this.state.routeStack.slice();
|
||||
nextIDStack[index] = getuid();
|
||||
nextRouteStack[index] = route;
|
||||
|
||||
@ -785,12 +785,12 @@ var NavigatorIOS = createReactClass({
|
||||
* @param route The new route to navigate to.
|
||||
*/
|
||||
popToRoute: function(route: Route) {
|
||||
var indexOfRoute = this.state.routeStack.indexOf(route);
|
||||
const indexOfRoute = this.state.routeStack.indexOf(route);
|
||||
invariant(
|
||||
indexOfRoute !== -1,
|
||||
'Calling pop to route for a route that doesn\'t exist!'
|
||||
);
|
||||
var numToPop = this.state.routeStack.length - indexOfRoute - 1;
|
||||
const numToPop = this.state.routeStack.length - indexOfRoute - 1;
|
||||
this.popN(numToPop);
|
||||
},
|
||||
|
||||
@ -841,12 +841,12 @@ var NavigatorIOS = createReactClass({
|
||||
},
|
||||
|
||||
_routeToStackItem: function(routeArg: Route, i: number) {
|
||||
var {component, wrapperStyle, passProps, ...route} = routeArg;
|
||||
var {itemWrapperStyle, ...props} = this.props;
|
||||
var shouldUpdateChild =
|
||||
const {component, wrapperStyle, passProps, ...route} = routeArg;
|
||||
const {itemWrapperStyle, ...props} = this.props;
|
||||
const shouldUpdateChild =
|
||||
this.state.updatingAllIndicesAtOrBeyond != null &&
|
||||
this.state.updatingAllIndicesAtOrBeyond >= i;
|
||||
var Component = component;
|
||||
const Component = component;
|
||||
return (
|
||||
<StaticContainer key={'nav' + i} shouldUpdate={shouldUpdateChild}>
|
||||
<RCTNavigatorItem
|
||||
@ -868,12 +868,12 @@ var NavigatorIOS = createReactClass({
|
||||
},
|
||||
|
||||
_renderNavigationStackItems: function() {
|
||||
var shouldRecurseToNavigator =
|
||||
const shouldRecurseToNavigator =
|
||||
this.state.makingNavigatorRequest ||
|
||||
this.state.updatingAllIndicesAtOrBeyond !== null;
|
||||
// If not recursing update to navigator at all, may as well avoid
|
||||
// computation of navigator children.
|
||||
var items = shouldRecurseToNavigator ?
|
||||
const items = shouldRecurseToNavigator ?
|
||||
this.state.routeStack.map(this._routeToStackItem) : null;
|
||||
return (
|
||||
<StaticContainer shouldUpdate={shouldRecurseToNavigator}>
|
||||
@ -919,7 +919,7 @@ var NavigatorIOS = createReactClass({
|
||||
},
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
stackItem: {
|
||||
backgroundColor: 'white',
|
||||
overflow: 'hidden',
|
||||
@ -934,7 +934,7 @@ var styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
var RCTNavigator = requireNativeComponent('RCTNavigator');
|
||||
var RCTNavigatorItem = requireNativeComponent('RCTNavItem');
|
||||
const RCTNavigator = requireNativeComponent('RCTNavigator');
|
||||
const RCTNavigatorItem = requireNativeComponent('RCTNavItem');
|
||||
|
||||
module.exports = NavigatorIOS;
|
||||
|
@ -10,27 +10,27 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var PickerIOS = require('PickerIOS');
|
||||
var PickerAndroid = require('PickerAndroid');
|
||||
var Platform = require('Platform');
|
||||
var React = require('React');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const PickerIOS = require('PickerIOS');
|
||||
const PickerAndroid = require('PickerAndroid');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
var StyleSheetPropType = require('StyleSheetPropType');
|
||||
var TextStylePropTypes = require('TextStylePropTypes');
|
||||
var UnimplementedView = require('UnimplementedView');
|
||||
const StyleSheetPropType = require('StyleSheetPropType');
|
||||
const TextStylePropTypes = require('TextStylePropTypes');
|
||||
const UnimplementedView = require('UnimplementedView');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
var ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
const ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
|
||||
var itemStylePropType = StyleSheetPropType(TextStylePropTypes);
|
||||
const itemStylePropType = StyleSheetPropType(TextStylePropTypes);
|
||||
|
||||
var pickerStyleType = StyleSheetPropType({
|
||||
const pickerStyleType = StyleSheetPropType({
|
||||
...ViewStylePropTypes,
|
||||
color: ColorPropType,
|
||||
});
|
||||
|
||||
var MODE_DIALOG = 'dialog';
|
||||
var MODE_DROPDOWN = 'dropdown';
|
||||
const MODE_DIALOG = 'dialog';
|
||||
const MODE_DROPDOWN = 'dropdown';
|
||||
|
||||
/**
|
||||
* Individual selectable item in a Picker.
|
||||
|
@ -10,21 +10,21 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var React = require('React');
|
||||
var ReactPropTypes = require('prop-types');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var StyleSheetPropType = require('StyleSheetPropType');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const React = require('React');
|
||||
const ReactPropTypes = require('prop-types');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const StyleSheetPropType = require('StyleSheetPropType');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
var ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
const ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
|
||||
var processColor = require('processColor');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const processColor = require('processColor');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
var REF_PICKER = 'picker';
|
||||
var MODE_DROPDOWN = 'dropdown';
|
||||
const REF_PICKER = 'picker';
|
||||
const MODE_DROPDOWN = 'dropdown';
|
||||
|
||||
var pickerStyleType = StyleSheetPropType({
|
||||
const pickerStyleType = StyleSheetPropType({
|
||||
...ViewStylePropTypes,
|
||||
color: ColorPropType,
|
||||
});
|
||||
@ -56,7 +56,7 @@ class PickerAndroid extends React.Component<{
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
var state = this._stateFromProps(props);
|
||||
const state = this._stateFromProps(props);
|
||||
|
||||
this.state = {
|
||||
...state,
|
||||
@ -70,7 +70,7 @@ class PickerAndroid extends React.Component<{
|
||||
|
||||
// Translate prop and children into stuff that the native picker understands.
|
||||
_stateFromProps = (props) => {
|
||||
var selectedIndex = 0;
|
||||
let selectedIndex = 0;
|
||||
const items = React.Children.map(props.children, (child, index) => {
|
||||
if (child.props.value === props.selectedValue) {
|
||||
selectedIndex = index;
|
||||
@ -88,9 +88,9 @@ class PickerAndroid extends React.Component<{
|
||||
};
|
||||
|
||||
render() {
|
||||
var Picker = this.props.mode === MODE_DROPDOWN ? DropdownPicker : DialogPicker;
|
||||
const Picker = this.props.mode === MODE_DROPDOWN ? DropdownPicker : DialogPicker;
|
||||
|
||||
var nativeProps = {
|
||||
const nativeProps = {
|
||||
enabled: this.props.enabled,
|
||||
items: this.state.items,
|
||||
mode: this.props.mode,
|
||||
@ -107,10 +107,10 @@ class PickerAndroid extends React.Component<{
|
||||
|
||||
_onChange = (event: Event) => {
|
||||
if (this.props.onValueChange) {
|
||||
var position = event.nativeEvent.position;
|
||||
const position = event.nativeEvent.position;
|
||||
if (position >= 0) {
|
||||
var children = React.Children.toArray(this.props.children);
|
||||
var value = children[position].props.value;
|
||||
const children = React.Children.toArray(this.props.children);
|
||||
const value = children[position].props.value;
|
||||
this.props.onValueChange(value, position);
|
||||
} else {
|
||||
this.props.onValueChange(null, position);
|
||||
@ -138,7 +138,7 @@ class PickerAndroid extends React.Component<{
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
pickerAndroid: {
|
||||
// The picker will conform to whatever width is given, but we do
|
||||
// have to set the component's height explicitly on the
|
||||
@ -149,14 +149,14 @@ var styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
var cfg = {
|
||||
const cfg = {
|
||||
nativeOnly: {
|
||||
items: true,
|
||||
selected: true,
|
||||
}
|
||||
};
|
||||
|
||||
var DropdownPicker = requireNativeComponent('AndroidDropdownPicker', PickerAndroid, cfg);
|
||||
var DialogPicker = requireNativeComponent('AndroidDialogPicker', PickerAndroid, cfg);
|
||||
const DropdownPicker = requireNativeComponent('AndroidDropdownPicker', PickerAndroid, cfg);
|
||||
const DialogPicker = requireNativeComponent('AndroidDialogPicker', PickerAndroid, cfg);
|
||||
|
||||
module.exports = PickerAndroid;
|
||||
|
@ -10,21 +10,21 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var React = require('React');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var StyleSheetPropType = require('StyleSheetPropType');
|
||||
var TextStylePropTypes = require('TextStylePropTypes');
|
||||
var View = require('View');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const StyleSheetPropType = require('StyleSheetPropType');
|
||||
const TextStylePropTypes = require('TextStylePropTypes');
|
||||
const View = require('View');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
var processColor = require('processColor');
|
||||
const processColor = require('processColor');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var itemStylePropType = StyleSheetPropType(TextStylePropTypes);
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const createReactClass = require('create-react-class');
|
||||
const itemStylePropType = StyleSheetPropType(TextStylePropTypes);
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
var PickerIOS = createReactClass({
|
||||
const PickerIOS = createReactClass({
|
||||
displayName: 'PickerIOS',
|
||||
mixins: [NativeMethodsMixin],
|
||||
|
||||
@ -45,8 +45,8 @@ var PickerIOS = createReactClass({
|
||||
|
||||
// Translate PickerIOS prop and children into stuff that RCTPickerIOS understands.
|
||||
_stateFromProps: function(props) {
|
||||
var selectedIndex = 0;
|
||||
var items = [];
|
||||
let selectedIndex = 0;
|
||||
const items = [];
|
||||
React.Children.toArray(props.children).forEach(function (child, index) {
|
||||
if (child.props.value === props.selectedValue) {
|
||||
selectedIndex = index;
|
||||
@ -111,7 +111,7 @@ PickerIOS.Item = class extends React.Component {
|
||||
}
|
||||
};
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
pickerIOS: {
|
||||
// The picker will conform to whatever width is given, but we do
|
||||
// have to set the component's height explicitly on the
|
||||
@ -120,7 +120,7 @@ var styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
var RCTPickerIOS = requireNativeComponent('RCTPicker', {
|
||||
const RCTPickerIOS = requireNativeComponent('RCTPicker', {
|
||||
propTypes: {
|
||||
style: itemStylePropType,
|
||||
},
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var Text = require('Text');
|
||||
var View = require('View');
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
const View = require('View');
|
||||
|
||||
class DummyProgressViewIOS extends React.Component {
|
||||
render() {
|
||||
@ -27,7 +27,7 @@ class DummyProgressViewIOS extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
dummy: {
|
||||
width: 120,
|
||||
height: 20,
|
||||
|
@ -9,20 +9,20 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Image = require('Image');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
const Image = require('Image');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const createReactClass = require('create-react-class');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
/**
|
||||
* Use `ProgressViewIOS` to render a UIProgressView on iOS.
|
||||
*/
|
||||
var ProgressViewIOS = createReactClass({
|
||||
const ProgressViewIOS = createReactClass({
|
||||
displayName: 'ProgressViewIOS',
|
||||
mixins: [NativeMethodsMixin],
|
||||
|
||||
@ -69,13 +69,13 @@ var ProgressViewIOS = createReactClass({
|
||||
}
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
progressView: {
|
||||
height: 2,
|
||||
},
|
||||
});
|
||||
|
||||
var RCTProgressView = requireNativeComponent(
|
||||
const RCTProgressView = requireNativeComponent(
|
||||
'RCTProgressView',
|
||||
ProgressViewIOS
|
||||
);
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var Text = require('Text');
|
||||
var View = require('View');
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
const View = require('View');
|
||||
|
||||
class DummySegmentedControlIOS extends React.Component {
|
||||
render() {
|
||||
@ -27,7 +27,7 @@ class DummySegmentedControlIOS extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
dummy: {
|
||||
width: 120,
|
||||
height: 50,
|
||||
|
@ -9,21 +9,21 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const createReactClass = require('create-react-class');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
type DefaultProps = {
|
||||
values: Array<string>,
|
||||
enabled: boolean,
|
||||
};
|
||||
|
||||
var SEGMENTED_CONTROL_REFERENCE = 'segmentedcontrol';
|
||||
const SEGMENTED_CONTROL_REFERENCE = 'segmentedcontrol';
|
||||
|
||||
type Event = Object;
|
||||
|
||||
@ -47,7 +47,7 @@ type Event = Object;
|
||||
* />
|
||||
* ````
|
||||
*/
|
||||
var SegmentedControlIOS = createReactClass({
|
||||
const SegmentedControlIOS = createReactClass({
|
||||
displayName: 'SegmentedControlIOS',
|
||||
mixins: [NativeMethodsMixin],
|
||||
|
||||
@ -117,13 +117,13 @@ var SegmentedControlIOS = createReactClass({
|
||||
}
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
segmentedControl: {
|
||||
height: 28,
|
||||
},
|
||||
});
|
||||
|
||||
var RCTSegmentedControl = requireNativeComponent(
|
||||
const RCTSegmentedControl = requireNativeComponent(
|
||||
'RCTSegmentedControl',
|
||||
SegmentedControlIOS
|
||||
);
|
||||
|
@ -9,18 +9,18 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Image = require('Image');
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
||||
var Platform = require('Platform');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
const Image = require('Image');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const createReactClass = require('create-react-class');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
type Event = Object;
|
||||
|
||||
@ -84,7 +84,7 @@ type Event = Object;
|
||||
*```
|
||||
*
|
||||
*/
|
||||
var Slider = createReactClass({
|
||||
const Slider = createReactClass({
|
||||
displayName: 'Slider',
|
||||
mixins: [NativeMethodsMixin],
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
const React = require('React');
|
||||
|
||||
var PropTypes = require('prop-types');
|
||||
const PropTypes = require('prop-types');
|
||||
|
||||
class StaticRenderer extends React.Component<{
|
||||
shouldUpdate: boolean,
|
||||
|
@ -19,7 +19,7 @@ import type EventEmitter from 'EventEmitter';
|
||||
* React Core
|
||||
*/
|
||||
|
||||
var Subscribable = {};
|
||||
const Subscribable = {};
|
||||
|
||||
Subscribable.Mixin = {
|
||||
|
||||
|
@ -9,16 +9,16 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var Platform = require('Platform');
|
||||
var React = require('React');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const createReactClass = require('create-react-class');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
type DefaultProps = {
|
||||
value: boolean,
|
||||
@ -36,7 +36,7 @@ type DefaultProps = {
|
||||
* @keyword checkbox
|
||||
* @keyword toggle
|
||||
*/
|
||||
var Switch = createReactClass({
|
||||
const Switch = createReactClass({
|
||||
displayName: 'Switch',
|
||||
propTypes: {
|
||||
...ViewPropTypes,
|
||||
@ -98,7 +98,7 @@ var Switch = createReactClass({
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var props = {...this.props};
|
||||
const props = {...this.props};
|
||||
props.onStartShouldSetResponder = () => true;
|
||||
props.onResponderTerminationRequest = () => false;
|
||||
if (Platform.OS === 'android') {
|
||||
@ -122,7 +122,7 @@ var Switch = createReactClass({
|
||||
},
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
rctSwitchIOS: {
|
||||
height: 31,
|
||||
width: 51,
|
||||
|
@ -9,14 +9,14 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var React = require('React');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var TabBarItemIOS = require('TabBarItemIOS');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const TabBarItemIOS = require('TabBarItemIOS');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
import type {StyleObj} from 'StyleSheetTypes';
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
@ -92,12 +92,12 @@ class TabBarIOS extends React.Component<ViewProps & {
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
tabGroup: {
|
||||
flex: 1,
|
||||
}
|
||||
});
|
||||
|
||||
var RCTTabBar = requireNativeComponent('RCTTabBar', TabBarIOS);
|
||||
const RCTTabBar = requireNativeComponent('RCTTabBar', TabBarIOS);
|
||||
|
||||
module.exports = TabBarIOS;
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
var View = require('View');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
const React = require('React');
|
||||
const View = require('View');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
|
||||
class DummyTab extends React.Component {
|
||||
render() {
|
||||
@ -26,7 +26,7 @@ class DummyTab extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
tab: {
|
||||
// TODO(5405356): Implement overflow: visible so position: absolute isn't useless
|
||||
// position: 'absolute',
|
||||
|
@ -9,17 +9,17 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var Image = require('Image');
|
||||
var React = require('React');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const Image = require('Image');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
var StaticContainer = require('StaticContainer.react');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var View = require('View');
|
||||
const StaticContainer = require('StaticContainer.react');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const View = require('View');
|
||||
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
class TabBarItemIOS extends React.Component {
|
||||
static propTypes = {
|
||||
@ -113,7 +113,7 @@ class TabBarItemIOS extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
var {style, children, ...props} = this.props;
|
||||
const {style, children, ...props} = this.props;
|
||||
|
||||
// if the tab has already been shown once, always continue to show it so we
|
||||
// preserve state between tab transitions
|
||||
@ -136,7 +136,7 @@ class TabBarItemIOS extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
tab: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
@ -146,6 +146,6 @@ var styles = StyleSheet.create({
|
||||
}
|
||||
});
|
||||
|
||||
var RCTTabBarItem = requireNativeComponent('RCTTabBarItem', TabBarItemIOS);
|
||||
const RCTTabBarItem = requireNativeComponent('RCTTabBarItem', TabBarItemIOS);
|
||||
|
||||
module.exports = TabBarItemIOS;
|
||||
|
@ -706,9 +706,9 @@ const TextInput = createReactClass({
|
||||
},
|
||||
|
||||
_renderIOSLegacy: function() {
|
||||
var textContainer;
|
||||
let textContainer;
|
||||
|
||||
var props = Object.assign({}, this.props);
|
||||
const props = Object.assign({}, this.props);
|
||||
props.style = [this.props.style];
|
||||
|
||||
if (props.selection && props.selection.end == null) {
|
||||
@ -720,7 +720,7 @@ const TextInput = createReactClass({
|
||||
|
||||
if (!props.multiline) {
|
||||
if (__DEV__) {
|
||||
for (var propKey in onlyMultiline) {
|
||||
for (const propKey in onlyMultiline) {
|
||||
if (props[propKey]) {
|
||||
const error = new Error(
|
||||
'TextInput prop `' +
|
||||
@ -744,8 +744,8 @@ const TextInput = createReactClass({
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
var children = props.children;
|
||||
var childCount = 0;
|
||||
let children = props.children;
|
||||
let childCount = 0;
|
||||
React.Children.forEach(children, () => ++childCount);
|
||||
invariant(
|
||||
!(props.value && childCount),
|
||||
@ -797,7 +797,7 @@ const TextInput = createReactClass({
|
||||
},
|
||||
|
||||
_renderIOS: function() {
|
||||
var props = Object.assign({}, this.props);
|
||||
const props = Object.assign({}, this.props);
|
||||
props.style = [this.props.style];
|
||||
|
||||
if (props.selection && props.selection.end == null) {
|
||||
@ -857,8 +857,8 @@ const TextInput = createReactClass({
|
||||
/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
|
||||
* suppresses an error when upgrading Flow's support for React. To see the
|
||||
* error delete this comment and run Flow. */
|
||||
var children = this.props.children;
|
||||
var childCount = 0;
|
||||
let children = this.props.children;
|
||||
let childCount = 0;
|
||||
React.Children.forEach(children, () => ++childCount);
|
||||
invariant(
|
||||
!(this.props.value && childCount),
|
||||
@ -932,7 +932,7 @@ const TextInput = createReactClass({
|
||||
});
|
||||
}
|
||||
|
||||
var text = event.nativeEvent.text;
|
||||
const text = event.nativeEvent.text;
|
||||
this.props.onChange && this.props.onChange(event);
|
||||
this.props.onChangeText && this.props.onChangeText(text);
|
||||
|
||||
@ -1016,7 +1016,7 @@ const TextInput = createReactClass({
|
||||
},
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
multilineInput: {
|
||||
// This default top inset makes RCTMultilineTextInputView seem as close as possible
|
||||
// to single-line RCTSinglelineTextInputView defaults, using the system defaults
|
||||
|
@ -13,10 +13,10 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Platform = require('Platform');
|
||||
var UIManager = require('UIManager');
|
||||
const Platform = require('Platform');
|
||||
const UIManager = require('UIManager');
|
||||
|
||||
var TextInputState = {
|
||||
const TextInputState = {
|
||||
/**
|
||||
* Internal state
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var RCTToastAndroid = require('NativeModules').ToastAndroid;
|
||||
const RCTToastAndroid = require('NativeModules').ToastAndroid;
|
||||
|
||||
/**
|
||||
* This exposes the native ToastAndroid module as a JS module. This has a function 'show'
|
||||
@ -33,7 +33,7 @@ var RCTToastAndroid = require('NativeModules').ToastAndroid;
|
||||
* ```
|
||||
*/
|
||||
|
||||
var ToastAndroid = {
|
||||
const ToastAndroid = {
|
||||
|
||||
// Toast duration constants
|
||||
SHORT: RCTToastAndroid.SHORT,
|
||||
|
@ -9,9 +9,9 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var warning = require('fbjs/lib/warning');
|
||||
const warning = require('fbjs/lib/warning');
|
||||
|
||||
var ToastAndroid = {
|
||||
const ToastAndroid = {
|
||||
|
||||
show: function (
|
||||
message: string,
|
||||
|
@ -9,20 +9,20 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var Image = require('Image');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
||||
var UIManager = require('UIManager');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
var ColorPropType = require('ColorPropType');
|
||||
const Image = require('Image');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
|
||||
const UIManager = require('UIManager');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
var resolveAssetSource = require('resolveAssetSource');
|
||||
const createReactClass = require('create-react-class');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
const resolveAssetSource = require('resolveAssetSource');
|
||||
|
||||
var optionalImageSource = PropTypes.oneOfType([
|
||||
const optionalImageSource = PropTypes.oneOfType([
|
||||
Image.propTypes.source,
|
||||
// Image.propTypes.source is required but we want it to be optional, so we OR
|
||||
// it with a nullable propType.
|
||||
@ -64,7 +64,7 @@ var optionalImageSource = PropTypes.oneOfType([
|
||||
*
|
||||
* [0]: https://developer.android.com/reference/android/support/v7/widget/Toolbar.html
|
||||
*/
|
||||
var ToolbarAndroid = createReactClass({
|
||||
const ToolbarAndroid = createReactClass({
|
||||
displayName: 'ToolbarAndroid',
|
||||
mixins: [NativeMethodsMixin],
|
||||
|
||||
@ -162,7 +162,7 @@ var ToolbarAndroid = createReactClass({
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var nativeProps = {
|
||||
const nativeProps = {
|
||||
...this.props,
|
||||
};
|
||||
if (this.props.logo) {
|
||||
@ -175,9 +175,9 @@ var ToolbarAndroid = createReactClass({
|
||||
nativeProps.overflowIcon = resolveAssetSource(this.props.overflowIcon);
|
||||
}
|
||||
if (this.props.actions) {
|
||||
var nativeActions = [];
|
||||
for (var i = 0; i < this.props.actions.length; i++) {
|
||||
var action = {
|
||||
const nativeActions = [];
|
||||
for (let i = 0; i < this.props.actions.length; i++) {
|
||||
const action = {
|
||||
...this.props.actions[i],
|
||||
};
|
||||
if (action.icon) {
|
||||
@ -195,7 +195,7 @@ var ToolbarAndroid = createReactClass({
|
||||
},
|
||||
|
||||
_onSelect: function(event) {
|
||||
var position = event.nativeEvent.position;
|
||||
const position = event.nativeEvent.position;
|
||||
if (position === -1) {
|
||||
this.props.onIconClicked && this.props.onIconClicked();
|
||||
} else {
|
||||
@ -204,7 +204,7 @@ var ToolbarAndroid = createReactClass({
|
||||
},
|
||||
});
|
||||
|
||||
var NativeToolbar = requireNativeComponent('ToolbarAndroid', ToolbarAndroid, {
|
||||
const NativeToolbar = requireNativeComponent('ToolbarAndroid', ToolbarAndroid, {
|
||||
nativeOnly: {
|
||||
nativeActions: true,
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var PooledClass = require('PooledClass');
|
||||
const PooledClass = require('PooledClass');
|
||||
|
||||
var twoArgumentPooler = PooledClass.twoArgumentPooler;
|
||||
const twoArgumentPooler = PooledClass.twoArgumentPooler;
|
||||
|
||||
/**
|
||||
* PooledClass representing the bounding rectangle of a region.
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
/**
|
||||
* Static poolers. Several custom versions for each potential number of
|
||||
@ -19,10 +19,10 @@ var invariant = require('fbjs/lib/invariant');
|
||||
* the Class itself, not an instance. If any others are needed, simply add them
|
||||
* here, or in their own files.
|
||||
*/
|
||||
var oneArgumentPooler = function(copyFieldsFrom) {
|
||||
var Klass = this;
|
||||
const oneArgumentPooler = function(copyFieldsFrom) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
const instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, copyFieldsFrom);
|
||||
return instance;
|
||||
} else {
|
||||
@ -30,10 +30,10 @@ var oneArgumentPooler = function(copyFieldsFrom) {
|
||||
}
|
||||
};
|
||||
|
||||
var twoArgumentPooler = function(a1, a2) {
|
||||
var Klass = this;
|
||||
const twoArgumentPooler = function(a1, a2) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
const instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2);
|
||||
return instance;
|
||||
} else {
|
||||
@ -41,10 +41,10 @@ var twoArgumentPooler = function(a1, a2) {
|
||||
}
|
||||
};
|
||||
|
||||
var threeArgumentPooler = function(a1, a2, a3) {
|
||||
var Klass = this;
|
||||
const threeArgumentPooler = function(a1, a2, a3) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
const instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2, a3);
|
||||
return instance;
|
||||
} else {
|
||||
@ -52,10 +52,10 @@ var threeArgumentPooler = function(a1, a2, a3) {
|
||||
}
|
||||
};
|
||||
|
||||
var fourArgumentPooler = function(a1, a2, a3, a4) {
|
||||
var Klass = this;
|
||||
const fourArgumentPooler = function(a1, a2, a3, a4) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
var instance = Klass.instancePool.pop();
|
||||
const instance = Klass.instancePool.pop();
|
||||
Klass.call(instance, a1, a2, a3, a4);
|
||||
return instance;
|
||||
} else {
|
||||
@ -63,8 +63,8 @@ var fourArgumentPooler = function(a1, a2, a3, a4) {
|
||||
}
|
||||
};
|
||||
|
||||
var standardReleaser = function(instance) {
|
||||
var Klass = this;
|
||||
const standardReleaser = function(instance) {
|
||||
const Klass = this;
|
||||
invariant(
|
||||
instance instanceof Klass,
|
||||
'Trying to release an instance into a pool of a different type.',
|
||||
@ -75,8 +75,8 @@ var standardReleaser = function(instance) {
|
||||
}
|
||||
};
|
||||
|
||||
var DEFAULT_POOL_SIZE = 10;
|
||||
var DEFAULT_POOLER = oneArgumentPooler;
|
||||
const DEFAULT_POOL_SIZE = 10;
|
||||
const DEFAULT_POOLER = oneArgumentPooler;
|
||||
|
||||
type Pooler = any;
|
||||
|
||||
@ -89,7 +89,7 @@ type Pooler = any;
|
||||
* @param {Function} CopyConstructor Constructor that can be used to reset.
|
||||
* @param {Function} pooler Customizable pooler.
|
||||
*/
|
||||
var addPoolingTo = function<T>(
|
||||
const addPoolingTo = function<T>(
|
||||
CopyConstructor: Class<T>,
|
||||
pooler: Pooler,
|
||||
): Class<T> & {
|
||||
@ -100,7 +100,7 @@ var addPoolingTo = function<T>(
|
||||
} {
|
||||
// Casting as any so that flow ignores the actual implementation and trusts
|
||||
// it to match the type we declared
|
||||
var NewKlass = (CopyConstructor: any);
|
||||
const NewKlass = (CopyConstructor: any);
|
||||
NewKlass.instancePool = [];
|
||||
NewKlass.getPooled = pooler || DEFAULT_POOLER;
|
||||
if (!NewKlass.poolSize) {
|
||||
@ -110,7 +110,7 @@ var addPoolingTo = function<T>(
|
||||
return NewKlass;
|
||||
};
|
||||
|
||||
var PooledClass = {
|
||||
const PooledClass = {
|
||||
addPoolingTo: addPoolingTo,
|
||||
oneArgumentPooler: (oneArgumentPooler: Pooler),
|
||||
twoArgumentPooler: (twoArgumentPooler: Pooler),
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var PooledClass = require('PooledClass');
|
||||
const PooledClass = require('PooledClass');
|
||||
|
||||
var twoArgumentPooler = PooledClass.twoArgumentPooler;
|
||||
const twoArgumentPooler = PooledClass.twoArgumentPooler;
|
||||
|
||||
/**
|
||||
* Position does not expose methods for construction via an `HTMLDOMElement`,
|
||||
|
@ -110,7 +110,7 @@ const normalizeColor = require('normalizeColor');
|
||||
/**
|
||||
* Touchable states.
|
||||
*/
|
||||
var States = keyMirror({
|
||||
const States = keyMirror({
|
||||
NOT_RESPONDER: null, // Not the responder
|
||||
RESPONDER_INACTIVE_PRESS_IN: null, // Responder, inactive, in the `PressRect`
|
||||
RESPONDER_INACTIVE_PRESS_OUT: null, // Responder, inactive, out of `PressRect`
|
||||
@ -124,7 +124,7 @@ var States = keyMirror({
|
||||
/**
|
||||
* Quick lookup map for states that are considered to be "active"
|
||||
*/
|
||||
var IsActive = {
|
||||
const IsActive = {
|
||||
RESPONDER_ACTIVE_PRESS_OUT: true,
|
||||
RESPONDER_ACTIVE_PRESS_IN: true
|
||||
};
|
||||
@ -133,20 +133,20 @@ var IsActive = {
|
||||
* Quick lookup for states that are considered to be "pressing" and are
|
||||
* therefore eligible to result in a "selection" if the press stops.
|
||||
*/
|
||||
var IsPressingIn = {
|
||||
const IsPressingIn = {
|
||||
RESPONDER_INACTIVE_PRESS_IN: true,
|
||||
RESPONDER_ACTIVE_PRESS_IN: true,
|
||||
RESPONDER_ACTIVE_LONG_PRESS_IN: true,
|
||||
};
|
||||
|
||||
var IsLongPressingIn = {
|
||||
const IsLongPressingIn = {
|
||||
RESPONDER_ACTIVE_LONG_PRESS_IN: true,
|
||||
};
|
||||
|
||||
/**
|
||||
* Inputs to the state machine.
|
||||
*/
|
||||
var Signals = keyMirror({
|
||||
const Signals = keyMirror({
|
||||
DELAY: null,
|
||||
RESPONDER_GRANT: null,
|
||||
RESPONDER_RELEASE: null,
|
||||
@ -159,7 +159,7 @@ var Signals = keyMirror({
|
||||
/**
|
||||
* Mapping from States x Signals => States
|
||||
*/
|
||||
var Transitions = {
|
||||
const Transitions = {
|
||||
NOT_RESPONDER: {
|
||||
DELAY: States.ERROR,
|
||||
RESPONDER_GRANT: States.RESPONDER_INACTIVE_PRESS_IN,
|
||||
@ -237,15 +237,15 @@ var Transitions = {
|
||||
// ==== Typical Constants for integrating into UI components ====
|
||||
// var HIT_EXPAND_PX = 20;
|
||||
// var HIT_VERT_OFFSET_PX = 10;
|
||||
var HIGHLIGHT_DELAY_MS = 130;
|
||||
const HIGHLIGHT_DELAY_MS = 130;
|
||||
|
||||
var PRESS_EXPAND_PX = 20;
|
||||
const PRESS_EXPAND_PX = 20;
|
||||
|
||||
var LONG_PRESS_THRESHOLD = 500;
|
||||
const LONG_PRESS_THRESHOLD = 500;
|
||||
|
||||
var LONG_PRESS_DELAY_MS = LONG_PRESS_THRESHOLD - HIGHLIGHT_DELAY_MS;
|
||||
const LONG_PRESS_DELAY_MS = LONG_PRESS_THRESHOLD - HIGHLIGHT_DELAY_MS;
|
||||
|
||||
var LONG_PRESS_ALLOWED_MOVEMENT = 10;
|
||||
const LONG_PRESS_ALLOWED_MOVEMENT = 10;
|
||||
|
||||
// Default amount "active" region protrudes beyond box
|
||||
|
||||
@ -313,7 +313,7 @@ var LONG_PRESS_ALLOWED_MOVEMENT = 10;
|
||||
*
|
||||
* @lends Touchable.prototype
|
||||
*/
|
||||
var TouchableMixin = {
|
||||
const TouchableMixin = {
|
||||
componentDidMount: function() {
|
||||
if (!Platform.isTVOS) {
|
||||
return;
|
||||
@ -321,7 +321,7 @@ var TouchableMixin = {
|
||||
|
||||
this._tvEventHandler = new TVEventHandler();
|
||||
this._tvEventHandler.enable(this, function(cmp, evt) {
|
||||
var myTag = ReactNative.findNodeHandle(cmp);
|
||||
const myTag = ReactNative.findNodeHandle(cmp);
|
||||
evt.dispatchConfig = {};
|
||||
if (myTag === evt.tag) {
|
||||
if (evt.eventType === 'focus') {
|
||||
@ -389,7 +389,7 @@ var TouchableMixin = {
|
||||
*
|
||||
*/
|
||||
touchableHandleResponderGrant: function(e) {
|
||||
var dispatchID = e.currentTarget;
|
||||
const dispatchID = e.currentTarget;
|
||||
// Since e is used in a callback invoked on another event loop
|
||||
// (as in setTimeout etc), we need to call e.persist() on the
|
||||
// event to make sure it doesn't get reused in the event object pool.
|
||||
@ -401,7 +401,7 @@ var TouchableMixin = {
|
||||
this.state.touchable.touchState = States.NOT_RESPONDER;
|
||||
this.state.touchable.responderID = dispatchID;
|
||||
this._receiveSignal(Signals.RESPONDER_GRANT, e);
|
||||
var delayMS =
|
||||
let delayMS =
|
||||
this.touchableGetHighlightDelayMS !== undefined ?
|
||||
Math.max(this.touchableGetHighlightDelayMS(), 0) : HIGHLIGHT_DELAY_MS;
|
||||
delayMS = isNaN(delayMS) ? HIGHLIGHT_DELAY_MS : delayMS;
|
||||
@ -414,7 +414,7 @@ var TouchableMixin = {
|
||||
this._handleDelay(e);
|
||||
}
|
||||
|
||||
var longDelayMS =
|
||||
let longDelayMS =
|
||||
this.touchableGetLongPressDelayMS !== undefined ?
|
||||
Math.max(this.touchableGetLongPressDelayMS(), 10) : LONG_PRESS_DELAY_MS;
|
||||
longDelayMS = isNaN(longDelayMS) ? LONG_PRESS_DELAY_MS : longDelayMS;
|
||||
@ -453,9 +453,9 @@ var TouchableMixin = {
|
||||
return;
|
||||
}
|
||||
|
||||
var positionOnActivate = this.state.touchable.positionOnActivate;
|
||||
var dimensionsOnActivate = this.state.touchable.dimensionsOnActivate;
|
||||
var pressRectOffset = this.touchableGetPressRectOffset ?
|
||||
const positionOnActivate = this.state.touchable.positionOnActivate;
|
||||
const dimensionsOnActivate = this.state.touchable.dimensionsOnActivate;
|
||||
const pressRectOffset = this.touchableGetPressRectOffset ?
|
||||
this.touchableGetPressRectOffset() : {
|
||||
left: PRESS_EXPAND_PX,
|
||||
right: PRESS_EXPAND_PX,
|
||||
@ -463,12 +463,12 @@ var TouchableMixin = {
|
||||
bottom: PRESS_EXPAND_PX
|
||||
};
|
||||
|
||||
var pressExpandLeft = pressRectOffset.left;
|
||||
var pressExpandTop = pressRectOffset.top;
|
||||
var pressExpandRight = pressRectOffset.right;
|
||||
var pressExpandBottom = pressRectOffset.bottom;
|
||||
let pressExpandLeft = pressRectOffset.left;
|
||||
let pressExpandTop = pressRectOffset.top;
|
||||
let pressExpandRight = pressRectOffset.right;
|
||||
let pressExpandBottom = pressRectOffset.bottom;
|
||||
|
||||
var hitSlop = this.touchableGetHitSlop ?
|
||||
const hitSlop = this.touchableGetHitSlop ?
|
||||
this.touchableGetHitSlop() : null;
|
||||
|
||||
if (hitSlop) {
|
||||
@ -478,18 +478,18 @@ var TouchableMixin = {
|
||||
pressExpandBottom += hitSlop.bottom;
|
||||
}
|
||||
|
||||
var touch = TouchEventUtils.extractSingleTouch(e.nativeEvent);
|
||||
var pageX = touch && touch.pageX;
|
||||
var pageY = touch && touch.pageY;
|
||||
const touch = TouchEventUtils.extractSingleTouch(e.nativeEvent);
|
||||
const pageX = touch && touch.pageX;
|
||||
const pageY = touch && touch.pageY;
|
||||
|
||||
if (this.pressInLocation) {
|
||||
var movedDistance = this._getDistanceBetweenPoints(pageX, pageY, this.pressInLocation.pageX, this.pressInLocation.pageY);
|
||||
const movedDistance = this._getDistanceBetweenPoints(pageX, pageY, this.pressInLocation.pageX, this.pressInLocation.pageY);
|
||||
if (movedDistance > LONG_PRESS_ALLOWED_MOVEMENT) {
|
||||
this._cancelLongPressDelayTimeout();
|
||||
}
|
||||
}
|
||||
|
||||
var isTouchWithinActive =
|
||||
const isTouchWithinActive =
|
||||
pageX > positionOnActivate.left - pressExpandLeft &&
|
||||
pageY > positionOnActivate.top - pressExpandTop &&
|
||||
pageX <
|
||||
@ -502,7 +502,7 @@ var TouchableMixin = {
|
||||
pressExpandBottom;
|
||||
if (isTouchWithinActive) {
|
||||
this._receiveSignal(Signals.ENTER_PRESS_RECT, e);
|
||||
var curState = this.state.touchable.touchState;
|
||||
const curState = this.state.touchable.touchState;
|
||||
if (curState === States.RESPONDER_INACTIVE_PRESS_IN) {
|
||||
// fix for t7967420
|
||||
this._cancelLongPressDelayTimeout();
|
||||
@ -620,7 +620,7 @@ var TouchableMixin = {
|
||||
|
||||
_handleLongDelay: function(e) {
|
||||
this.longPressDelayTimeout = null;
|
||||
var curState = this.state.touchable.touchState;
|
||||
const curState = this.state.touchable.touchState;
|
||||
if (curState !== States.RESPONDER_ACTIVE_PRESS_IN &&
|
||||
curState !== States.RESPONDER_ACTIVE_LONG_PRESS_IN) {
|
||||
console.error('Attempted to transition from state `' + curState + '` to `' +
|
||||
@ -640,9 +640,9 @@ var TouchableMixin = {
|
||||
* @sideeffects
|
||||
*/
|
||||
_receiveSignal: function(signal, e) {
|
||||
var responderID = this.state.touchable.responderID;
|
||||
var curState = this.state.touchable.touchState;
|
||||
var nextState = Transitions[curState] && Transitions[curState][signal];
|
||||
const responderID = this.state.touchable.responderID;
|
||||
const curState = this.state.touchable.touchState;
|
||||
const nextState = Transitions[curState] && Transitions[curState][signal];
|
||||
if (!responderID && signal === Signals.RESPONDER_RELEASE) {
|
||||
return;
|
||||
}
|
||||
@ -675,17 +675,17 @@ var TouchableMixin = {
|
||||
},
|
||||
|
||||
_savePressInLocation: function(e) {
|
||||
var touch = TouchEventUtils.extractSingleTouch(e.nativeEvent);
|
||||
var pageX = touch && touch.pageX;
|
||||
var pageY = touch && touch.pageY;
|
||||
var locationX = touch && touch.locationX;
|
||||
var locationY = touch && touch.locationY;
|
||||
const touch = TouchEventUtils.extractSingleTouch(e.nativeEvent);
|
||||
const pageX = touch && touch.pageX;
|
||||
const pageY = touch && touch.pageY;
|
||||
const locationX = touch && touch.locationX;
|
||||
const locationY = touch && touch.locationY;
|
||||
this.pressInLocation = {pageX, pageY, locationX, locationY};
|
||||
},
|
||||
|
||||
_getDistanceBetweenPoints: function (aX, aY, bX, bY) {
|
||||
var deltaX = aX - bX;
|
||||
var deltaY = aY - bY;
|
||||
const deltaX = aX - bX;
|
||||
const deltaY = aY - bY;
|
||||
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
},
|
||||
|
||||
@ -701,10 +701,10 @@ var TouchableMixin = {
|
||||
* @sideeffects
|
||||
*/
|
||||
_performSideEffectsForTransition: function(curState, nextState, signal, e) {
|
||||
var curIsHighlight = this._isHighlight(curState);
|
||||
var newIsHighlight = this._isHighlight(nextState);
|
||||
const curIsHighlight = this._isHighlight(curState);
|
||||
const newIsHighlight = this._isHighlight(nextState);
|
||||
|
||||
var isFinalSignal =
|
||||
const isFinalSignal =
|
||||
signal === Signals.RESPONDER_TERMINATED ||
|
||||
signal === Signals.RESPONDER_RELEASE;
|
||||
|
||||
@ -727,14 +727,14 @@ var TouchableMixin = {
|
||||
}
|
||||
|
||||
if (IsPressingIn[curState] && signal === Signals.RESPONDER_RELEASE) {
|
||||
var hasLongPressHandler = !!this.props.onLongPress;
|
||||
var pressIsLongButStillCallOnPress =
|
||||
const hasLongPressHandler = !!this.props.onLongPress;
|
||||
const pressIsLongButStillCallOnPress =
|
||||
IsLongPressingIn[curState] && ( // We *are* long pressing..
|
||||
!hasLongPressHandler || // But either has no long handler
|
||||
!this.touchableLongPressCancelsPress() // or we're told to ignore it.
|
||||
(// But either has no long handler
|
||||
!hasLongPressHandler || !this.touchableLongPressCancelsPress()) // or we're told to ignore it.
|
||||
);
|
||||
|
||||
var shouldInvokePress = !IsLongPressingIn[curState] || pressIsLongButStillCallOnPress;
|
||||
const shouldInvokePress = !IsLongPressingIn[curState] || pressIsLongButStillCallOnPress;
|
||||
if (shouldInvokePress && this.touchableHandlePress) {
|
||||
if (!newIsHighlight && !curIsHighlight) {
|
||||
// we never highlighted because of delay, but we should highlight now
|
||||
@ -768,7 +768,7 @@ var TouchableMixin = {
|
||||
|
||||
};
|
||||
|
||||
var Touchable = {
|
||||
const Touchable = {
|
||||
Mixin: TouchableMixin,
|
||||
TOUCH_TARGET_DEBUG: false, // Highlights all touchable targets. Toggle with Inspector.
|
||||
/**
|
||||
|
@ -10,13 +10,13 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Animated = require('Animated');
|
||||
var EdgeInsetsPropType = require('EdgeInsetsPropType');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var React = require('React');
|
||||
var createReactClass = require('create-react-class');
|
||||
var PropTypes = require('prop-types');
|
||||
var Touchable = require('Touchable');
|
||||
const Animated = require('Animated');
|
||||
const EdgeInsetsPropType = require('EdgeInsetsPropType');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const React = require('React');
|
||||
const createReactClass = require('create-react-class');
|
||||
const PropTypes = require('prop-types');
|
||||
const Touchable = require('Touchable');
|
||||
|
||||
type Event = Object;
|
||||
|
||||
@ -25,7 +25,7 @@ type State = {
|
||||
scale: Animated.Value,
|
||||
};
|
||||
|
||||
var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
|
||||
/**
|
||||
* Example of using the `TouchableMixin` to play well with other responder
|
||||
@ -34,7 +34,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
* `TouchableMixin` expects us to implement some abstract methods to handle
|
||||
* interesting interactions such as `handleTouchablePress`.
|
||||
*/
|
||||
var TouchableBounce = createReactClass({
|
||||
const TouchableBounce = createReactClass({
|
||||
displayName: 'TouchableBounce',
|
||||
mixins: [Touchable.Mixin, NativeMethodsMixin],
|
||||
|
||||
@ -115,7 +115,7 @@ var TouchableBounce = createReactClass({
|
||||
},
|
||||
|
||||
touchableHandlePress: function(e: Event) {
|
||||
var onPressWithCompletion = this.props.onPressWithCompletion;
|
||||
const onPressWithCompletion = this.props.onPressWithCompletion;
|
||||
if (onPressWithCompletion) {
|
||||
onPressWithCompletion(() => {
|
||||
this.state.scale.setValue(0.93);
|
||||
|
@ -8,37 +8,37 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Platform = require('Platform');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNative = require('ReactNative');
|
||||
var Touchable = require('Touchable');
|
||||
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
|
||||
var UIManager = require('UIManager');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNative = require('ReactNative');
|
||||
const Touchable = require('Touchable');
|
||||
const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
|
||||
const UIManager = require('UIManager');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var ensurePositiveDelayProps = require('ensurePositiveDelayProps');
|
||||
var processColor = require('processColor');
|
||||
const createReactClass = require('create-react-class');
|
||||
const ensurePositiveDelayProps = require('ensurePositiveDelayProps');
|
||||
const processColor = require('processColor');
|
||||
|
||||
var rippleBackgroundPropType = PropTypes.shape({
|
||||
const rippleBackgroundPropType = PropTypes.shape({
|
||||
type: PropTypes.oneOf(['RippleAndroid']),
|
||||
color: PropTypes.number,
|
||||
borderless: PropTypes.bool,
|
||||
});
|
||||
|
||||
var themeAttributeBackgroundPropType = PropTypes.shape({
|
||||
const themeAttributeBackgroundPropType = PropTypes.shape({
|
||||
type: PropTypes.oneOf(['ThemeAttrAndroid']),
|
||||
attribute: PropTypes.string.isRequired,
|
||||
});
|
||||
|
||||
var backgroundPropType = PropTypes.oneOfType([
|
||||
const backgroundPropType = PropTypes.oneOfType([
|
||||
rippleBackgroundPropType,
|
||||
themeAttributeBackgroundPropType,
|
||||
]);
|
||||
|
||||
type Event = Object;
|
||||
|
||||
var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
|
||||
/**
|
||||
* A wrapper for making views respond properly to touches (Android only).
|
||||
@ -69,7 +69,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
* ```
|
||||
*/
|
||||
|
||||
var TouchableNativeFeedback = createReactClass({
|
||||
const TouchableNativeFeedback = createReactClass({
|
||||
displayName: 'TouchableNativeFeedback',
|
||||
propTypes: {
|
||||
...TouchableWithoutFeedback.propTypes,
|
||||
@ -233,7 +233,7 @@ var TouchableNativeFeedback = createReactClass({
|
||||
this.props.useForeground && TouchableNativeFeedback.canUseNativeForeground()
|
||||
? 'nativeForegroundAndroid'
|
||||
: 'nativeBackgroundAndroid';
|
||||
var childProps = {
|
||||
const childProps = {
|
||||
...child.props,
|
||||
[drawableProp]: this.props.background,
|
||||
accessible: this.props.accessible !== false,
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var Text = require('Text');
|
||||
var View = require('View');
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
const View = require('View');
|
||||
|
||||
class DummyTouchableNativeFeedback extends React.Component {
|
||||
static SelectableBackground = () => ({});
|
||||
@ -29,7 +29,7 @@ class DummyTouchableNativeFeedback extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
height: 100,
|
||||
width: 300,
|
||||
|
@ -11,22 +11,22 @@
|
||||
|
||||
// Note (avik): add @flow when Flow supports spread properties in propTypes
|
||||
|
||||
var Animated = require('Animated');
|
||||
var Easing = require('Easing');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var TimerMixin = require('react-timer-mixin');
|
||||
var Touchable = require('Touchable');
|
||||
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
|
||||
const Animated = require('Animated');
|
||||
const Easing = require('Easing');
|
||||
const NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const TimerMixin = require('react-timer-mixin');
|
||||
const Touchable = require('Touchable');
|
||||
const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
|
||||
|
||||
var createReactClass = require('create-react-class');
|
||||
var ensurePositiveDelayProps = require('ensurePositiveDelayProps');
|
||||
var flattenStyle = require('flattenStyle');
|
||||
const createReactClass = require('create-react-class');
|
||||
const ensurePositiveDelayProps = require('ensurePositiveDelayProps');
|
||||
const flattenStyle = require('flattenStyle');
|
||||
|
||||
type Event = Object;
|
||||
|
||||
var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
|
||||
/**
|
||||
* A wrapper for making views respond properly to touches.
|
||||
@ -116,7 +116,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
var TouchableOpacity = createReactClass({
|
||||
const TouchableOpacity = createReactClass({
|
||||
displayName: 'TouchableOpacity',
|
||||
mixins: [TimerMixin, Touchable.Mixin, NativeMethodsMixin],
|
||||
|
||||
@ -234,7 +234,7 @@ var TouchableOpacity = createReactClass({
|
||||
},
|
||||
|
||||
_getChildStyleOpacityWithDefault: function() {
|
||||
var childStyle = flattenStyle(this.props.style) || {};
|
||||
const childStyle = flattenStyle(this.props.style) || {};
|
||||
return childStyle.opacity == undefined ? 1 : childStyle.opacity;
|
||||
},
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
var ensureComponentIsNative = function(component: any) {
|
||||
const ensureComponentIsNative = function(component: any) {
|
||||
invariant(
|
||||
component && typeof component.setNativeProps === 'function',
|
||||
'Touchable child must either be native or forward setNativeProps to a ' +
|
||||
|
@ -9,9 +9,9 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
var ensurePositiveDelayProps = function(props: any) {
|
||||
const ensurePositiveDelayProps = function(props: any) {
|
||||
invariant(
|
||||
!(props.delayPressIn < 0 || props.delayPressOut < 0 ||
|
||||
props.delayLongPress < 0),
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
const Platform = require('Platform');
|
||||
|
||||
var TVViewPropTypes = {};
|
||||
let TVViewPropTypes = {};
|
||||
if (Platform.isTVOS) {
|
||||
TVViewPropTypes = require('TVViewPropTypes');
|
||||
}
|
||||
|
@ -10,19 +10,19 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var ImageStylePropTypes = require('ImageStylePropTypes');
|
||||
var TextStylePropTypes = require('TextStylePropTypes');
|
||||
var ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
const ImageStylePropTypes = require('ImageStylePropTypes');
|
||||
const TextStylePropTypes = require('TextStylePropTypes');
|
||||
const ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
|
||||
* found when Flow v0.54 was deployed. To see the error delete this comment and
|
||||
* run Flow. */
|
||||
var keyMirror = require('fbjs/lib/keyMirror');
|
||||
var processColor = require('processColor');
|
||||
var processTransform = require('processTransform');
|
||||
var sizesDiffer = require('sizesDiffer');
|
||||
const keyMirror = require('fbjs/lib/keyMirror');
|
||||
const processColor = require('processColor');
|
||||
const processTransform = require('processTransform');
|
||||
const sizesDiffer = require('sizesDiffer');
|
||||
|
||||
var ReactNativeStyleAttributes = {
|
||||
const ReactNativeStyleAttributes = {
|
||||
...keyMirror(ViewStylePropTypes),
|
||||
...keyMirror(TextStylePropTypes),
|
||||
...keyMirror(ImageStylePropTypes),
|
||||
@ -31,7 +31,7 @@ var ReactNativeStyleAttributes = {
|
||||
ReactNativeStyleAttributes.transform = { process: processTransform };
|
||||
ReactNativeStyleAttributes.shadowOffset = { diff: sizesDiffer };
|
||||
|
||||
var colorAttributes = { process: processColor };
|
||||
const colorAttributes = { process: processColor };
|
||||
ReactNativeStyleAttributes.backgroundColor = colorAttributes;
|
||||
ReactNativeStyleAttributes.borderBottomColor = colorAttributes;
|
||||
ReactNativeStyleAttributes.borderColor = colorAttributes;
|
||||
|
@ -9,9 +9,9 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
|
||||
const ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
|
||||
|
||||
var ReactNativeViewAttributes = {};
|
||||
const ReactNativeViewAttributes = {};
|
||||
|
||||
ReactNativeViewAttributes.UIView = {
|
||||
pointerEvents: true,
|
||||
|
@ -9,16 +9,16 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ColorPropType = require('ColorPropType');
|
||||
var LayoutPropTypes = require('LayoutPropTypes');
|
||||
var ReactPropTypes = require('prop-types');
|
||||
var ShadowPropTypesIOS = require('ShadowPropTypesIOS');
|
||||
var TransformPropTypes = require('TransformPropTypes');
|
||||
const ColorPropType = require('ColorPropType');
|
||||
const LayoutPropTypes = require('LayoutPropTypes');
|
||||
const ReactPropTypes = require('prop-types');
|
||||
const ShadowPropTypesIOS = require('ShadowPropTypesIOS');
|
||||
const TransformPropTypes = require('TransformPropTypes');
|
||||
|
||||
/**
|
||||
* Warning: Some of these properties may not be supported in all releases.
|
||||
*/
|
||||
var ViewStylePropTypes = {
|
||||
const ViewStylePropTypes = {
|
||||
...LayoutPropTypes,
|
||||
...ShadowPropTypesIOS,
|
||||
...TransformPropTypes,
|
||||
|
@ -9,16 +9,16 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNative = require('ReactNative');
|
||||
var UIManager = require('UIManager');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNative = require('ReactNative');
|
||||
const UIManager = require('UIManager');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var dismissKeyboard = require('dismissKeyboard');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
const dismissKeyboard = require('dismissKeyboard');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
var VIEWPAGER_REF = 'viewPager';
|
||||
const VIEWPAGER_REF = 'viewPager';
|
||||
|
||||
type Event = Object;
|
||||
|
||||
@ -163,7 +163,7 @@ class ViewPagerAndroid extends React.Component<{
|
||||
if (!child) {
|
||||
return null;
|
||||
}
|
||||
var newProps = {
|
||||
const newProps = {
|
||||
...child.props,
|
||||
style: [child.props.style, {
|
||||
position: 'absolute',
|
||||
@ -246,6 +246,6 @@ class ViewPagerAndroid extends React.Component<{
|
||||
}
|
||||
}
|
||||
|
||||
var NativeAndroidViewPager = requireNativeComponent('AndroidViewPager', ViewPagerAndroid);
|
||||
const NativeAndroidViewPager = requireNativeComponent('AndroidViewPager', ViewPagerAndroid);
|
||||
|
||||
module.exports = ViewPagerAndroid;
|
||||
|
@ -8,30 +8,30 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var EdgeInsetsPropType = require('EdgeInsetsPropType');
|
||||
var ActivityIndicator = require('ActivityIndicator');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNative = require('ReactNative');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var UIManager = require('UIManager');
|
||||
var View = require('View');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
const EdgeInsetsPropType = require('EdgeInsetsPropType');
|
||||
const ActivityIndicator = require('ActivityIndicator');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNative = require('ReactNative');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const UIManager = require('UIManager');
|
||||
const View = require('View');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
|
||||
var deprecatedPropType = require('deprecatedPropType');
|
||||
var keyMirror = require('fbjs/lib/keyMirror');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
var resolveAssetSource = require('resolveAssetSource');
|
||||
const deprecatedPropType = require('deprecatedPropType');
|
||||
const keyMirror = require('fbjs/lib/keyMirror');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
const resolveAssetSource = require('resolveAssetSource');
|
||||
|
||||
var RCT_WEBVIEW_REF = 'webview';
|
||||
const RCT_WEBVIEW_REF = 'webview';
|
||||
|
||||
var WebViewState = keyMirror({
|
||||
const WebViewState = keyMirror({
|
||||
IDLE: null,
|
||||
LOADING: null,
|
||||
ERROR: null,
|
||||
});
|
||||
|
||||
var defaultRenderLoading = () => (
|
||||
const defaultRenderLoading = () => (
|
||||
<View style={styles.loadingView}>
|
||||
<ActivityIndicator
|
||||
style={styles.loadingProgressBar}
|
||||
@ -252,12 +252,12 @@ class WebView extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
var otherView = null;
|
||||
let otherView = null;
|
||||
|
||||
if (this.state.viewState === WebViewState.LOADING) {
|
||||
otherView = (this.props.renderLoading || defaultRenderLoading)();
|
||||
} else if (this.state.viewState === WebViewState.ERROR) {
|
||||
var errorEvent = this.state.lastErrorEvent;
|
||||
const errorEvent = this.state.lastErrorEvent;
|
||||
otherView = this.props.renderError && this.props.renderError(
|
||||
errorEvent.domain,
|
||||
errorEvent.code,
|
||||
@ -266,14 +266,14 @@ class WebView extends React.Component {
|
||||
console.error('RCTWebView invalid state encountered: ' + this.state.loading);
|
||||
}
|
||||
|
||||
var webViewStyles = [styles.container, this.props.style];
|
||||
const webViewStyles = [styles.container, this.props.style];
|
||||
if (this.state.viewState === WebViewState.LOADING ||
|
||||
this.state.viewState === WebViewState.ERROR) {
|
||||
// if we're in either LOADING or ERROR states, don't show the webView
|
||||
webViewStyles.push(styles.hidden);
|
||||
}
|
||||
|
||||
var source = this.props.source || {};
|
||||
const source = this.props.source || {};
|
||||
if (this.props.html) {
|
||||
source.html = this.props.html;
|
||||
} else if (this.props.url) {
|
||||
@ -290,7 +290,7 @@ class WebView extends React.Component {
|
||||
|
||||
let NativeWebView = nativeConfig.component || RCTWebView;
|
||||
|
||||
var webView =
|
||||
const webView =
|
||||
<NativeWebView
|
||||
ref={RCT_WEBVIEW_REF}
|
||||
key="webViewKey"
|
||||
@ -399,14 +399,14 @@ class WebView extends React.Component {
|
||||
};
|
||||
|
||||
onLoadingStart = (event) => {
|
||||
var onLoadStart = this.props.onLoadStart;
|
||||
const onLoadStart = this.props.onLoadStart;
|
||||
onLoadStart && onLoadStart(event);
|
||||
this.updateNavigationState(event);
|
||||
};
|
||||
|
||||
onLoadingError = (event) => {
|
||||
event.persist(); // persist this event because we need to store it
|
||||
var {onError, onLoadEnd} = this.props;
|
||||
const {onError, onLoadEnd} = this.props;
|
||||
onError && onError(event);
|
||||
onLoadEnd && onLoadEnd(event);
|
||||
console.warn('Encountered an error loading page', event.nativeEvent);
|
||||
@ -418,7 +418,7 @@ class WebView extends React.Component {
|
||||
};
|
||||
|
||||
onLoadingFinish = (event) => {
|
||||
var {onLoad, onLoadEnd} = this.props;
|
||||
const {onLoad, onLoadEnd} = this.props;
|
||||
onLoad && onLoad(event);
|
||||
onLoadEnd && onLoadEnd(event);
|
||||
this.setState({
|
||||
@ -428,14 +428,14 @@ class WebView extends React.Component {
|
||||
};
|
||||
|
||||
onMessage = (event: Event) => {
|
||||
var {onMessage} = this.props;
|
||||
const {onMessage} = this.props;
|
||||
onMessage && onMessage(event);
|
||||
}
|
||||
}
|
||||
|
||||
var RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig);
|
||||
const RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig);
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
},
|
||||
|
@ -9,31 +9,31 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ActivityIndicator = require('ActivityIndicator');
|
||||
var EdgeInsetsPropType = require('EdgeInsetsPropType');
|
||||
var React = require('React');
|
||||
var PropTypes = require('prop-types');
|
||||
var ReactNative = require('ReactNative');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var Text = require('Text');
|
||||
var UIManager = require('UIManager');
|
||||
var View = require('View');
|
||||
var ViewPropTypes = require('ViewPropTypes');
|
||||
var ScrollView = require('ScrollView');
|
||||
const ActivityIndicator = require('ActivityIndicator');
|
||||
const EdgeInsetsPropType = require('EdgeInsetsPropType');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const ReactNative = require('ReactNative');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
const UIManager = require('UIManager');
|
||||
const View = require('View');
|
||||
const ViewPropTypes = require('ViewPropTypes');
|
||||
const ScrollView = require('ScrollView');
|
||||
|
||||
var deprecatedPropType = require('deprecatedPropType');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var keyMirror = require('fbjs/lib/keyMirror');
|
||||
var processDecelerationRate = require('processDecelerationRate');
|
||||
var requireNativeComponent = require('requireNativeComponent');
|
||||
var resolveAssetSource = require('resolveAssetSource');
|
||||
const deprecatedPropType = require('deprecatedPropType');
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
const keyMirror = require('fbjs/lib/keyMirror');
|
||||
const processDecelerationRate = require('processDecelerationRate');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
const resolveAssetSource = require('resolveAssetSource');
|
||||
|
||||
var RCTWebViewManager = require('NativeModules').WebViewManager;
|
||||
const RCTWebViewManager = require('NativeModules').WebViewManager;
|
||||
|
||||
var BGWASH = 'rgba(255,255,255,0.8)';
|
||||
var RCT_WEBVIEW_REF = 'webview';
|
||||
const BGWASH = 'rgba(255,255,255,0.8)';
|
||||
const RCT_WEBVIEW_REF = 'webview';
|
||||
|
||||
var WebViewState = keyMirror({
|
||||
const WebViewState = keyMirror({
|
||||
IDLE: null,
|
||||
LOADING: null,
|
||||
ERROR: null,
|
||||
@ -67,12 +67,12 @@ const DataDetectorTypes = [
|
||||
'all',
|
||||
];
|
||||
|
||||
var defaultRenderLoading = () => (
|
||||
const defaultRenderLoading = () => (
|
||||
<View style={styles.loadingView}>
|
||||
<ActivityIndicator />
|
||||
</View>
|
||||
);
|
||||
var defaultRenderError = (errorDomain, errorCode, errorDesc) => (
|
||||
const defaultRenderError = (errorDomain, errorCode, errorDesc) => (
|
||||
<View style={styles.errorContainer}>
|
||||
<Text style={styles.errorTextTitle}>
|
||||
Error loading page
|
||||
@ -415,12 +415,12 @@ class WebView extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
var otherView = null;
|
||||
let otherView = null;
|
||||
|
||||
if (this.state.viewState === WebViewState.LOADING) {
|
||||
otherView = (this.props.renderLoading || defaultRenderLoading)();
|
||||
} else if (this.state.viewState === WebViewState.ERROR) {
|
||||
var errorEvent = this.state.lastErrorEvent;
|
||||
const errorEvent = this.state.lastErrorEvent;
|
||||
invariant(
|
||||
errorEvent != null,
|
||||
'lastErrorEvent expected to be non-null'
|
||||
@ -436,7 +436,7 @@ class WebView extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
var webViewStyles = [styles.container, styles.webView, this.props.style];
|
||||
const webViewStyles = [styles.container, styles.webView, this.props.style];
|
||||
if (this.state.viewState === WebViewState.LOADING ||
|
||||
this.state.viewState === WebViewState.ERROR) {
|
||||
// if we're in either LOADING or ERROR states, don't show the webView
|
||||
@ -447,15 +447,15 @@ class WebView extends React.Component {
|
||||
|
||||
const viewManager = nativeConfig.viewManager || RCTWebViewManager;
|
||||
|
||||
var onShouldStartLoadWithRequest = this.props.onShouldStartLoadWithRequest && ((event: Event) => {
|
||||
var shouldStart = this.props.onShouldStartLoadWithRequest &&
|
||||
const onShouldStartLoadWithRequest = this.props.onShouldStartLoadWithRequest && ((event: Event) => {
|
||||
const shouldStart = this.props.onShouldStartLoadWithRequest &&
|
||||
this.props.onShouldStartLoadWithRequest(event.nativeEvent);
|
||||
viewManager.startLoadWithResult(!!shouldStart, event.nativeEvent.lockIdentifier);
|
||||
});
|
||||
|
||||
var decelerationRate = processDecelerationRate(this.props.decelerationRate);
|
||||
const decelerationRate = processDecelerationRate(this.props.decelerationRate);
|
||||
|
||||
var source = this.props.source || {};
|
||||
const source = this.props.source || {};
|
||||
if (this.props.html) {
|
||||
source.html = this.props.html;
|
||||
} else if (this.props.url) {
|
||||
@ -466,7 +466,7 @@ class WebView extends React.Component {
|
||||
|
||||
const NativeWebView = nativeConfig.component || RCTWebView;
|
||||
|
||||
var webView =
|
||||
const webView =
|
||||
<NativeWebView
|
||||
ref={RCT_WEBVIEW_REF}
|
||||
key="webViewKey"
|
||||
@ -594,14 +594,14 @@ class WebView extends React.Component {
|
||||
};
|
||||
|
||||
_onLoadingStart = (event: Event) => {
|
||||
var onLoadStart = this.props.onLoadStart;
|
||||
const onLoadStart = this.props.onLoadStart;
|
||||
onLoadStart && onLoadStart(event);
|
||||
this._updateNavigationState(event);
|
||||
};
|
||||
|
||||
_onLoadingError = (event: Event) => {
|
||||
event.persist(); // persist this event because we need to store it
|
||||
var {onError, onLoadEnd} = this.props;
|
||||
const {onError, onLoadEnd} = this.props;
|
||||
onError && onError(event);
|
||||
onLoadEnd && onLoadEnd(event);
|
||||
console.warn('Encountered an error loading page', event.nativeEvent);
|
||||
@ -613,7 +613,7 @@ class WebView extends React.Component {
|
||||
};
|
||||
|
||||
_onLoadingFinish = (event: Event) => {
|
||||
var {onLoad, onLoadEnd} = this.props;
|
||||
const {onLoad, onLoadEnd} = this.props;
|
||||
onLoad && onLoad(event);
|
||||
onLoadEnd && onLoadEnd(event);
|
||||
this.setState({
|
||||
@ -623,14 +623,14 @@ class WebView extends React.Component {
|
||||
};
|
||||
|
||||
_onMessage = (event: Event) => {
|
||||
var {onMessage} = this.props;
|
||||
const {onMessage} = this.props;
|
||||
onMessage && onMessage(event);
|
||||
}
|
||||
}
|
||||
|
||||
var RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig);
|
||||
const RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig);
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user