Second Updates from Wed 25 Mar

- [MAdMan][Android] Make things look more Androidy | Philipp von Weitershausen
- flowified Libraries from Avik | Basil Hosmer
- flowify some Libraries | Basil Hosmer
- [ReactKit] Add shake development menu | Alex Kotliarskyi
- [ReactNative] Add debugger and change SampleApp files structure | Alex Kotliarskyi
- Flowify ReactIOSEventEmitter | Marshall Roch
- [react_native] JS files from D1941151: Allow fontWeight to be 100,200,...,900 | Krzysztof Magiera
This commit is contained in:
Christopher Chedeau
2015-03-25 15:36:50 -07:00
parent b331a34af6
commit 53f791ed91
45 changed files with 455 additions and 134 deletions

View File

@@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule TouchableBounce
* @flow
*/
'use strict';
@@ -20,6 +21,10 @@ var merge = require('merge');
var copyProperties = require('copyProperties');
var onlyChild = require('onlyChild');
type State = {
animationID: ?number;
};
/**
* When the scroll view is disabled, this defines how far your touch may move
* off of the button, before deactivating the button. Once deactivated, try
@@ -47,11 +52,17 @@ var TouchableBounce = React.createClass({
onPressAnimationComplete: React.PropTypes.func,
},
getInitialState: function() {
getInitialState: function(): State {
return merge(this.touchableGetInitialState(), {animationID: null});
},
bounceTo: function(value, velocity, bounciness, fromValue, callback) {
bounceTo: function(
value: number,
velocity: number,
bounciness: number,
fromValue?: ?Function | number,
callback?: ?Function
) {
if (POPAnimation) {
this.state.animationID && this.removeAnimation(this.state.animationID);
var anim = {
@@ -60,6 +71,7 @@ var TouchableBounce = React.createClass({
toValue: [value, value],
velocity: [velocity, velocity],
springBounciness: bounciness,
fromValue: (undefined: ?any),
};
if (fromValue) {
anim.fromValue = [fromValue, fromValue];
@@ -90,8 +102,9 @@ var TouchableBounce = React.createClass({
},
touchableHandlePress: function() {
if (this.props.onPressWithCompletion) {
this.props.onPressWithCompletion(
var onPressWithCompletion = this.props.onPressWithCompletion;
if (onPressWithCompletion) {
onPressWithCompletion(
this.bounceTo.bind(this, 1, 10, 10, 0.93, this.props.onPressAnimationComplete)
);
return;
@@ -101,11 +114,11 @@ var TouchableBounce = React.createClass({
this.props.onPress && this.props.onPress();
},
touchableGetPressRectOffset: function() {
touchableGetPressRectOffset: function(): typeof PRESS_RECT_OFFSET {
return PRESS_RECT_OFFSET; // Always make sure to predeclare a constant!
},
touchableGetHighlightDelayMS: function() {
touchableGetHighlightDelayMS: function(): number {
return 0;
},

View File

@@ -10,6 +10,8 @@
*/
'use strict';
// Note (avik): add @flow when Flow supports spread properties in propTypes
var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');

View File

@@ -10,6 +10,8 @@
*/
'use strict';
// Note (avik): add @flow when Flow supports spread properties in propTypes
var NativeMethodsMixin = require('NativeMethodsMixin');
var POPAnimationMixin = require('POPAnimationMixin');
var React = require('React');

View File

@@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule TouchableWithoutFeedback
* @flow
*/
'use strict';
@@ -23,6 +24,7 @@ var onlyChild = require('onlyChild');
*/
var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
type Event = Object;
/**
* Do not use unless you have a very good reason. All the elements that
@@ -51,7 +53,7 @@ var TouchableWithoutFeedback = React.createClass({
* `Touchable.Mixin` self callbacks. The mixin will invoke these if they are
* defined on your component.
*/
touchableHandlePress: function(e) {
touchableHandlePress: function(e: Event) {
this.props.onPress && this.props.onPress(e);
},
@@ -67,18 +69,19 @@ var TouchableWithoutFeedback = React.createClass({
this.props.onLongPress && this.props.onLongPress();
},
touchableGetPressRectOffset: function() {
touchableGetPressRectOffset: function(): typeof PRESS_RECT_OFFSET {
return PRESS_RECT_OFFSET; // Always make sure to predeclare a constant!
},
touchableGetHighlightDelayMS: function() {
touchableGetHighlightDelayMS: function(): number {
return 0;
},
render: function() {
render: function(): ReactElement {
// Note(vjeux): use cloneWithProps once React has been upgraded
var child = onlyChild(this.props.children);
return React.cloneElement(child, {
// Note(avik): remove dynamic typecast once Flow has been upgraded
return (React: any).cloneElement(child, {
accessible: true,
testID: this.props.testID,
onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder,

View File

@@ -7,12 +7,13 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ensureComponentIsNative
* @flow
*/
'use strict';
var invariant = require('invariant');
var ensureComponentIsNative = function(component) {
var ensureComponentIsNative = function(component: any) {
invariant(
component && typeof component.setNativeProps === 'function',
'Touchable child must either be native or forward setNativeProps to a ' +