Skip to content

Commit

Permalink
Merge pull request #1353 from a2/Update_Wed_20_May
Browse files Browse the repository at this point in the history
Updates from Wed 20 May
  • Loading branch information
a2 committed May 21, 2015
2 parents a1193b7 + 4cd5cad commit d20a6e9
Show file tree
Hide file tree
Showing 53 changed files with 294 additions and 64 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/node_modules/**/.*js
# node_modules ignored by default

**/staticBundle.js
**/main.js
Libraries/vendor/**/*
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"no-underscore-dangle": 0, // disallow dangling underscores in identifiers
"no-wrap-func": 1, // disallow wrapping of non-IIFE statements in parens
"no-mixed-spaces-and-tabs": 1, // disallow mixed spaces and tabs for indentation
"quotes": [1, "single"], // specify whether double or single quotes should be used
"quotes": [1, "single", "avoid-escape"], // specify whether double or single quotes should be used
"quote-props": 0, // require quotes around object literal property names (off by default)
"semi": 1, // require or disallow use of semicolons instead of ASI
"sort-vars": 0, // sort variables within the same declaration block (off by default)
Expand Down
62 changes: 62 additions & 0 deletions IntegrationTests/AppEventsTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* 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.
*
* @providesModule AppEventsTest
* @flow
*/
'use strict';

var React = require('react-native');
var {
NativeAppEventEmitter,
NativeModules,
StyleSheet,
Text,
View,
} = React;
var TestModule = NativeModules.TestModule || NativeModules.SnapshotTestManager;

var deepDiffer = require('deepDiffer');

var TEST_PAYLOAD = {foo: 'bar'};

var AppEventsTest = React.createClass({
getInitialState: function() {
return {sent: 'none', received: 'none'};
},
componentDidMount: function() {
NativeAppEventEmitter.addListener('testEvent', this.receiveEvent);
var event = {data: TEST_PAYLOAD, ts: Date.now()};
TestModule.sendAppEvent('testEvent', event);
this.setState({sent: event});
},
receiveEvent: function(event: any) {
if (deepDiffer(event.data, TEST_PAYLOAD)) {
throw new Error('Received wrong event: ' + JSON.stringify(event));
}
var elapsed = (Date.now() - event.ts) + 'ms';
this.setState({received: event, elapsed}, TestModule.markTestCompleted);
},
render: function() {
return (
<View style={styles.container}>
<Text>
{JSON.stringify(this.state, null, ' ')}
</Text>
</View>
);
}
});

var styles = StyleSheet.create({
container: {
margin: 40,
},
});

module.exports = AppEventsTest;
1 change: 1 addition & 0 deletions IntegrationTests/IntegrationTestsApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var TESTS = [
require('./TimersTest'),
require('./AsyncStorageTest'),
require('./LayoutEventsTest'),
require('./AppEventsTest'),
require('./SimpleSnapshotTest'),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ - (void)testLayoutEvents
[_runner runTest:_cmd module:@"LayoutEventsTest"];
}

- (void)testAppEvents
{
[_runner runTest:_cmd module:@"AppEventsTest"];
}

#pragma mark Snapshot Tests

- (void)testSimpleSnapshot
Expand Down
3 changes: 1 addition & 2 deletions Libraries/ART/ARTSerializablePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*
* @providesModule ARTSerializablePath
*/

"use strict";
'use strict';

// TODO: Move this into an ART mode called "serialized" or something

Expand Down
3 changes: 1 addition & 2 deletions Libraries/ART/ReactNativeART.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*
* @providesModule ReactNativeART
*/

"use strict";
'use strict';

var Color = require('art/core/color');
var Path = require('ARTSerializablePath');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
'use strict';

var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ var ScrollResponderMixin = {
var currentlyFocusedTextInput = TextInputState.currentlyFocusedField();
if (!this.props.keyboardShouldPersistTaps &&
currentlyFocusedTextInput != null &&
e.target != currentlyFocusedTextInput) {
e.target !== currentlyFocusedTextInput) {
return true;
}
return this.scrollResponderIsAnimating();
Expand Down Expand Up @@ -244,7 +244,7 @@ var ScrollResponderMixin = {
var currentlyFocusedTextInput = TextInputState.currentlyFocusedField();
if (!this.props.keyboardShouldPersistTaps &&
currentlyFocusedTextInput != null &&
e.target != currentlyFocusedTextInput &&
e.target !== currentlyFocusedTextInput &&
!this.state.observedScrollSinceBecomingResponder &&
!this.state.becameResponderWhileAnimating) {
this.props.onScrollResponderKeyboardDismissed &&
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Subscribable.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
'use strict';

var EventEmitter = require('EventEmitter');
import type EventEmitter from 'EventEmitter';

/**
* Subscribable provides a mixin for safely subscribing a component to an
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ var TextInput = React.createClass({
'number-pad',
'phone-pad',
'name-phone-pad',
'email-address',
'decimal-pad',
'twitter',
'web-search',
// Cross-platform
'numeric',
'email-address',
]),
/**
* Determines how the return key should look.
Expand Down
41 changes: 41 additions & 0 deletions Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ var createReactNativeComponentClass = require('createReactNativeComponentClass')

var stylePropType = StyleSheetPropType(ViewStylePropTypes);

var AccessibilityTraits = [
'none',
'button',
'link',
'header',
'search',
'image',
'selected',
'plays',
'key',
'text',
'summary',
'disabled',
'frequentUpdates',
'startsMedia',
'adjustable',
'allowsDirectInteraction',
'pageTurn',
];

/**
* The most fundamental component for building UI, `View` is a
* container that supports layout with flexbox, style, some touch handling, and
Expand Down Expand Up @@ -70,6 +90,27 @@ var View = React.createClass({
*/
accessibilityLabel: PropTypes.string,

/**
* Provides additional traits to screen reader. By default no traits are
* provided unless specified otherwise in element
*/
accessibilityTraits: PropTypes.oneOfType([
PropTypes.oneOf(AccessibilityTraits),
PropTypes.arrayOf(PropTypes.oneOf(AccessibilityTraits)),
]),

/**
* When `accessible` is true, the system will try to invoke this function
* when the user performs accessibility tap gesture.
*/
onAcccessibilityTap: PropTypes.func,

/**
* When `accessible` is true, the system will invoke this function when the
* user performs the magic tap gesture.
*/
onMagicTap: PropTypes.func,

/**
* Used to locate this view in end-to-end tests.
*/
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/WebView/WebView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var WebView = React.createClass({
errorEvent.code,
errorEvent.description);
} else if (this.state.viewState !== WebViewState.IDLE) {
console.error("RCTWebView invalid state encountered: " + this.state.loading);
console.error('RCTWebView invalid state encountered: ' + this.state.loading);
}

var webViewStyles = [styles.container, this.props.style];
Expand Down Expand Up @@ -152,7 +152,7 @@ var WebView = React.createClass({

onLoadingError: function(event) {
event.persist(); // persist this event because we need to store it
console.error("encountered an error loading page", event.nativeEvent);
console.error('Encountered an error loading page', event.nativeEvent);

this.setState({
lastErrorEvent: event.nativeEvent,
Expand Down
3 changes: 1 addition & 2 deletions Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
var ActivityIndicatorIOS = require('ActivityIndicatorIOS');
var EdgeInsetsPropType = require('EdgeInsetsPropType');
var React = require('React');
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
var StyleSheet = require('StyleSheet');
var Text = require('Text');
var View = require('View');
Expand Down Expand Up @@ -198,7 +197,7 @@ var WebView = React.createClass({

onLoadingError: function(event: Event) {
event.persist(); // persist this event because we need to store it
console.error("encountered an error loading page", event.nativeEvent);
console.error('Encountered an error loading page', event.nativeEvent);

this.setState({
lastErrorEvent: event.nativeEvent,
Expand Down
17 changes: 12 additions & 5 deletions Libraries/CustomComponents/Navigator/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*
* @providesModule Navigator
*/
/* eslint-disable no-extra-boolean-cast*/
'use strict';

var AnimationsDebugModule = require('NativeModules').AnimationsDebugModule;
Expand All @@ -48,8 +49,6 @@ var clamp = require('clamp');
var flattenStyle = require('flattenStyle');
var getNavigatorContext = require('getNavigatorContext');
var invariant = require('invariant');
var keyMirror = require('keyMirror');
var merge = require('merge');
var rebound = require('rebound');

var PropTypes = React.PropTypes;
Expand Down Expand Up @@ -689,7 +688,7 @@ var Navigator = React.createClass({
*/
_enableScene: function(sceneIndex) {
// First, determine what the defined styles are for scenes in this navigator
var sceneStyle = flattenStyle(this.props.sceneStyle);
var sceneStyle = flattenStyle([styles.baseScene, this.props.sceneStyle]);
// Then restore the left value for this scene
var enabledSceneNativeProps = {
left: sceneStyle.left,
Expand Down Expand Up @@ -745,7 +744,6 @@ var Navigator = React.createClass({
},

_handleMoveShouldSetPanResponder: function(e, gestureState) {
var currentRoute = this.state.routeStack[this.state.presentedIndex];
var sceneConfig = this.state.sceneConfigStack[this.state.presentedIndex];
this._expectingGestureGrant = this._matchGestureAction(this._eligibleGestures, sceneConfig.gestures, gestureState);
return !! this._expectingGestureGrant;
Expand Down Expand Up @@ -829,7 +827,16 @@ var Navigator = React.createClass({
}
} else {
// The gesture has enough velocity to complete, so we transition to the gesture's destination
this._transitionTo(destIndex, transitionVelocity);
this._transitionTo(
destIndex,
transitionVelocity,
null,
() => {
if (releaseGestureAction === 'pop') {
this._cleanScenesPastIndex(destIndex);
}
}
);
}
this._detachGesture();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ var FromTheLeft = {
translateX: {
from: -SCREEN_WIDTH,
to: 0,
min: 0,
min: 0,
max: 1,
type: 'linear',
extrapolate: true,
Expand Down
1 change: 1 addition & 0 deletions Libraries/Fetch/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @providesModule fetch
* @nolint
*/
/* eslint-disable */
'use strict';

var self = {};
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Geolocation/Geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ var Geolocation = {
subscriptions = [];
}
}
}
};

module.exports = Geolocation;
2 changes: 1 addition & 1 deletion Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var Image = React.createClass({
/**
* `uri` is a string representing the resource identifier for the image, which
* could be an http address, a local file path, or the name of a static image
* resource (which should be wrapped in the `required('image!name')` function).
* resource (which should be wrapped in the `require('image!name')` function).
*/
source: PropTypes.shape({
uri: PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions Libraries/JavaScriptAppEngine/Initialization/SourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* and wrapping resulting file into `wrapper` function.
*
*/
/*eslint-disable */

var scope = {};
wrapper.call(scope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* @nolint
*/
/* eslint-disable */

(function() {
var define = null; // Hack to make it work with our packager
Expand Down
1 change: 0 additions & 1 deletion Libraries/PushNotificationIOS/PushNotificationIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
'use strict';

var NativeModules = require('NativeModules');
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var RCTPushNotificationManager = require('NativeModules').PushNotificationManager;
var invariant = require('invariant');
Expand Down
6 changes: 6 additions & 0 deletions Libraries/RCTTest/RCTTestModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#import "FBSnapshotTestController.h"
#import "RCTAssert.h"
#import "RCTEventDispatcher.h"
#import "RCTLog.h"
#import "RCTUIManager.h"

Expand Down Expand Up @@ -63,4 +64,9 @@ - (instancetype)init
}];
}

RCT_EXPORT_METHOD(sendAppEvent:(NSString *)name body:(id)body)
{
[_bridge.eventDispatcher sendAppEventWithName:name body:body];
}

@end
1 change: 0 additions & 1 deletion Libraries/RKBackendNode/queryLayoutByID.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ var queryLayoutByID = function(
};

module.exports = queryLayoutByID;

Loading

0 comments on commit d20a6e9

Please sign in to comment.