Authored by 王海元

修改脚本文件

... ... @@ -240,6 +240,12 @@ var ListView = createReactClass({
enableEmptySections: PropTypes.bool,
},
yh_updateVisibleSubViews: function() {
if (this._scrollComponent && this._scrollComponent.yh_updateVisibleSubViews) {
this._scrollComponent.yh_updateVisibleSubViews();
}
},
/**
* Exports some data, e.g. for perf investigations or analytics.
*/
... ... @@ -335,7 +341,7 @@ var ListView = createReactClass({
renderScrollComponent: props => <ScrollView {...props} />,
scrollRenderAheadDistance: DEFAULT_SCROLL_RENDER_AHEAD,
onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD,
stickySectionHeadersEnabled: Platform.OS === 'ios',
stickySectionHeadersEnabled: true,
stickyHeaderIndices: [],
};
},
... ...
... ... @@ -418,6 +418,19 @@ var ScrollResponderMixin = {
);
},
/****
*设置刷新事件
*
*
**/
scrollResponderStartPullToRefresh: function() {
UIManager.dispatchViewManagerCommand(
this.scrollResponderGetScrollableNode(),
UIManager.RCTScrollView.Commands.startPullToRefresh,
[],
);
},
/**
* Scrolls to the end of the ScrollView, either immediately or with a smooth
* animation.
... ...
... ... @@ -36,7 +36,7 @@ const requireNativeComponent = require('requireNativeComponent');
const warning = require('fbjs/lib/warning');
import type {NativeMethodsMixinType} from 'ReactNativeTypes';
const RCTScrollViewManager = require('NativeModules').ScrollViewManager;
/**
* Component that wraps platform ScrollView while providing
* integration with touch locking "responder" system.
... ... @@ -423,6 +423,22 @@ const ScrollView = createReactClass({
'never',
]),
/**
pull to refresh
*/
enablePullToRefresh: PropTypes.bool,
isOnPullToRefresh: PropTypes.bool,
onRefreshData: PropTypes.func,
onFinishRefreshData: PropTypes.func,
/**
埋点
*/
yh_exposureData: PropTypes.any,
yh_viewVisible: PropTypes.bool,
/**
* When true, ScrollView will emit updateChildFrames data in scroll events,
* otherwise will not compute or emit child frame data. This only exists
* to support legacy issues, `onLayout` should be used instead to retrieve
... ... @@ -439,6 +455,25 @@ const ScrollView = createReactClass({
_scrollAnimatedValueAttachment: (null: ?{detach: () => void}),
_stickyHeaderRefs: (new Map(): Map<number, ScrollViewStickyHeader>),
_headerLayoutYs: (new Map(): Map<string, number>),
yh_updateVisibleSubViews: function() {
RCTScrollViewManager.yh_updateVisibleSubViews(
ReactNative.findNodeHandle(this._scrollViewRef)
);
},
startPullToRefresh: function() {
RCTScrollViewManager.startPullToRefresh(
ReactNative.findNodeHandle(this._scrollViewRef)
);
},
stopPullToRefresh: function() {
RCTScrollViewManager.stopPullToRefresh(
ReactNative.findNodeHandle(this._scrollViewRef)
);
},
getInitialState: function() {
return this.scrollResponderMixinGetInitialState();
},
... ...
... ... @@ -192,7 +192,7 @@ type Props<SectionT> = RequiredProps<SectionT> &
const defaultProps = {
...VirtualizedSectionList.defaultProps,
stickySectionHeadersEnabled: Platform.OS === 'ios',
stickySectionHeadersEnabled: true,
};
type DefaultProps = typeof defaultProps;
... ... @@ -279,6 +279,12 @@ class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
this._wrapperListRef.scrollToLocation(params);
}
setNativeProps(props: Object) {
if (this._wrapperListRef) {
this._wrapperListRef.setNativeProps(props);
}
}
/**
* Tells the list an interaction has occured, which should trigger viewability calculations, e.g.
* if `waitForInteractions` is true and the user has not scrolled. This is typically called by
... ...
... ... @@ -108,6 +108,8 @@ var TouchableHighlight = createReactClass({
* @platform ios
*/
tvParallaxProperties: PropTypes.object,
yh_exposureData: PropTypes.object,
},
mixins: [NativeMethodsMixin, TimerMixin, Touchable.Mixin],
... ... @@ -273,6 +275,7 @@ var TouchableHighlight = createReactClass({
render: function() {
return (
<View
yh_exposureData={this.props.yh_exposureData}
accessible={this.props.accessible !== false}
/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
* comment suppresses an error when upgrading Flow's support for React.
... ...
... ... @@ -67,6 +67,8 @@ var TouchableOpacity = createReactClass({
* Apple TV parallax effects
*/
tvParallaxProperties: PropTypes.object,
yh_exposureData: PropTypes.object,
},
getDefaultProps: function() {
... ... @@ -171,6 +173,7 @@ var TouchableOpacity = createReactClass({
render: function() {
return (
<Animated.View
yh_exposureData={this.props.yh_exposureData}
accessible={this.props.accessible !== false}
accessibilityLabel={this.props.accessibilityLabel}
accessibilityComponentType={this.props.accessibilityComponentType}
... ...
... ... @@ -86,7 +86,13 @@ const View = createReactClass({
// exists for DEV mode. However it's important for them to be declared.
// If the object passed to `createClass` specifies `propTypes`, Flow will
// create a static type from it.
propTypes: ViewPropTypes,
propTypes: {
yh_exposureData: PropTypes.object,
yh_viewVisible: PropTypes.bool,
...ViewPropTypes
},
/**
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
... ...
... ... @@ -464,4 +464,8 @@ module.exports = {
* @platform android
*/
needsOffscreenAlphaCompositing: PropTypes.bool,
yh_exposureData: PropTypes.object,
yh_viewVisible: PropTypes.bool,
};
... ...
... ... @@ -141,6 +141,12 @@ class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
state: State;
setNativeProps(props: Object) {
if (this._listRef) {
this._listRef.setNativeProps(props);
}
}
static defaultProps: DefaultProps = {
...VirtualizedList.defaultProps,
data: [],
... ...
... ... @@ -33,6 +33,8 @@ var WebViewState = keyMirror({
ERROR: null,
});
type Event = Object;
var defaultRenderLoading = () => (
<View style={styles.loadingView}>
<ActivityIndicator
... ... @@ -60,6 +62,7 @@ class WebView extends React.Component {
onContentSizeChange: PropTypes.func,
startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load
style: ViewPropTypes.style,
onShouldStartLoadWithRequest: PropTypes.func,
html: deprecatedPropType(
PropTypes.string,
... ... @@ -260,6 +263,15 @@ class WebView extends React.Component {
console.warn('WebView: `source.body` is not supported when using GET.');
}
var onShouldOverrideUrlLoading = this.props.onShouldStartLoadWithRequest
&& ((event: Event) => {
var shouldOverride = !this.props.onShouldStartLoadWithRequest(event.nativeEvent);
UIManager.dispatchViewManagerCommandSync(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.shouldOverrideWithResult,
[shouldOverride]);
});
var webView =
<RCTWebView
ref={RCT_WEBVIEW_REF}
... ... @@ -286,6 +298,7 @@ class WebView extends React.Component {
mixedContentMode={this.props.mixedContentMode}
saveFormDataDisabled={this.props.saveFormDataDisabled}
urlPrefixesForDefaultIntent={this.props.urlPrefixesForDefaultIntent}
onShouldOverrideUrlLoading={onShouldOverrideUrlLoading}
/>;
return (
... ...
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactNative = require('react-native');
var _propTypes = require('prop-types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function noop() {}
var animationFnPropType = _propTypes.PropTypes.oneOf([_reactNative.Animated.decay, _reactNative.Animated.spring, _reactNative.Animated.timing]);
var Swipeable = function (_PureComponent) {
_inherits(Swipeable, _PureComponent);
function Swipeable() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, Swipeable);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Swipeable.__proto__ || Object.getPrototypeOf(Swipeable)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
pan: new _reactNative.Animated.ValueXY(),
width: 0,
lastOffset: { x: 0, y: 0 },
leftActionActivated: false,
leftButtonsActivated: false,
leftButtonsOpen: false,
rightActionActivated: false,
rightButtonsActivated: false,
rightButtonsOpen: false
}, _this.recenter = function () {
var animationFn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.swipeReleaseAnimationFn;
var animationConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.swipeReleaseAnimationConfig;
var onDone = arguments[2];
var pan = _this.state.pan;
_this.setState({
lastOffset: { x: 0, y: 0 },
leftActionActivated: false,
leftButtonsActivated: false,
leftButtonsOpen: false,
rightActionActivated: false,
rightButtonsActivated: false,
rightButtonsOpen: false
});
pan.flattenOffset();
animationFn(pan, animationConfig).start(onDone);
}, _this._unmounted = false, _this._handlePan = _reactNative.Animated.event([null, {
dx: _this.state.pan.x,
dy: _this.state.pan.y
}]), _this._handleMoveShouldSetPanResponder = function (event, gestureState) {
return Math.abs(gestureState.dx) > _this.props.swipeStartMinDistance;
}, _this._handlePanResponderStart = function (event, gestureState) {
var _this$state = _this.state,
lastOffset = _this$state.lastOffset,
pan = _this$state.pan;
pan.setOffset(lastOffset);
_this.props.onSwipeStart(event, gestureState, _this);
}, _this._handlePanResponderMove = function (event, gestureState) {
var _this$props = _this.props,
leftActionActivationDistance = _this$props.leftActionActivationDistance,
leftButtonsActivationDistance = _this$props.leftButtonsActivationDistance,
onLeftActionActivate = _this$props.onLeftActionActivate,
onLeftActionDeactivate = _this$props.onLeftActionDeactivate,
onLeftButtonsActivate = _this$props.onLeftButtonsActivate,
onLeftButtonsDeactivate = _this$props.onLeftButtonsDeactivate,
rightActionActivationDistance = _this$props.rightActionActivationDistance,
rightButtonsActivationDistance = _this$props.rightButtonsActivationDistance,
onRightActionActivate = _this$props.onRightActionActivate,
onRightActionDeactivate = _this$props.onRightActionDeactivate,
onRightButtonsActivate = _this$props.onRightButtonsActivate,
onRightButtonsDeactivate = _this$props.onRightButtonsDeactivate,
onSwipeMove = _this$props.onSwipeMove;
var _this$state2 = _this.state,
lastOffset = _this$state2.lastOffset,
leftActionActivated = _this$state2.leftActionActivated,
leftButtonsActivated = _this$state2.leftButtonsActivated,
rightActionActivated = _this$state2.rightActionActivated,
rightButtonsActivated = _this$state2.rightButtonsActivated;
var dx = gestureState.dx,
vx = gestureState.vx;
var x = dx + lastOffset.x;
var canSwipeRight = _this._canSwipeRight();
var canSwipeLeft = _this._canSwipeLeft();
var hasLeftButtons = _this._hasLeftButtons();
var hasRightButtons = _this._hasRightButtons();
var isSwipingLeft = vx < 0;
var isSwipingRight = vx > 0;
var nextLeftActionActivated = leftActionActivated;
var nextLeftButtonsActivated = leftButtonsActivated;
var nextRightActionActivated = rightActionActivated;
var nextRightButtonsActivated = rightButtonsActivated;
_this._handlePan(event, gestureState);
onSwipeMove(event, gestureState, _this);
if (!leftActionActivated && canSwipeRight && x >= leftActionActivationDistance) {
nextLeftActionActivated = true;
onLeftActionActivate(event, gestureState, _this);
}
if (leftActionActivated && canSwipeRight && x < leftActionActivationDistance) {
nextLeftActionActivated = false;
onLeftActionDeactivate(event, gestureState, _this);
}
if (!rightActionActivated && canSwipeLeft && x <= -rightActionActivationDistance) {
nextRightActionActivated = true;
onRightActionActivate(event, gestureState, _this);
}
if (rightActionActivated && canSwipeLeft && x > -rightActionActivationDistance) {
nextRightActionActivated = false;
onRightActionDeactivate(event, gestureState, _this);
}
if (!leftButtonsActivated && hasLeftButtons && !isSwipingLeft && x >= leftButtonsActivationDistance) {
nextLeftButtonsActivated = true;
onLeftButtonsActivate(event, gestureState, _this);
}
if (leftButtonsActivated && hasLeftButtons && isSwipingLeft) {
nextLeftButtonsActivated = false;
onLeftButtonsDeactivate(event, gestureState, _this);
}
if (!rightButtonsActivated && hasRightButtons && !isSwipingRight && x <= -rightButtonsActivationDistance) {
nextRightButtonsActivated = true;
onRightButtonsActivate(event, gestureState, _this);
}
if (rightButtonsActivated && hasRightButtons && isSwipingRight) {
nextRightButtonsActivated = false;
onRightButtonsDeactivate(event, gestureState, _this);
}
var needsUpdate = nextLeftActionActivated !== leftActionActivated || nextLeftButtonsActivated !== leftButtonsActivated || nextRightActionActivated !== rightActionActivated || nextRightButtonsActivated !== rightButtonsActivated;
if (needsUpdate) {
_this.setState({
leftActionActivated: nextLeftActionActivated,
leftButtonsActivated: nextLeftButtonsActivated,
rightActionActivated: nextRightActionActivated,
rightButtonsActivated: nextRightButtonsActivated
});
}
}, _this._handlePanResponderEnd = function (event, gestureState) {
var _this$props2 = _this.props,
onLeftActionRelease = _this$props2.onLeftActionRelease,
onLeftActionDeactivate = _this$props2.onLeftActionDeactivate,
onLeftButtonsOpenRelease = _this$props2.onLeftButtonsOpenRelease,
onLeftButtonsCloseRelease = _this$props2.onLeftButtonsCloseRelease,
onRightActionRelease = _this$props2.onRightActionRelease,
onRightActionDeactivate = _this$props2.onRightActionDeactivate,
onRightButtonsOpenRelease = _this$props2.onRightButtonsOpenRelease,
onRightButtonsCloseRelease = _this$props2.onRightButtonsCloseRelease,
onSwipeRelease = _this$props2.onSwipeRelease;
var _this$state3 = _this.state,
leftActionActivated = _this$state3.leftActionActivated,
leftButtonsOpen = _this$state3.leftButtonsOpen,
leftButtonsActivated = _this$state3.leftButtonsActivated,
rightActionActivated = _this$state3.rightActionActivated,
rightButtonsOpen = _this$state3.rightButtonsOpen,
rightButtonsActivated = _this$state3.rightButtonsActivated,
pan = _this$state3.pan;
var animationFn = _this._getReleaseAnimationFn();
var animationConfig = _this._getReleaseAnimationConfig();
onSwipeRelease(event, gestureState, _this);
if (leftActionActivated) {
onLeftActionRelease(event, gestureState, _this);
}
if (rightActionActivated) {
onRightActionRelease(event, gestureState, _this);
}
if (leftButtonsActivated && !leftButtonsOpen) {
onLeftButtonsOpenRelease(event, gestureState, _this);
}
if (!leftButtonsActivated && leftButtonsOpen) {
onLeftButtonsCloseRelease(event, gestureState, _this);
}
if (rightButtonsActivated && !rightButtonsOpen) {
onRightButtonsOpenRelease(event, gestureState, _this);
}
if (!rightButtonsActivated && rightButtonsOpen) {
onRightButtonsCloseRelease(event, gestureState, _this);
}
_this.setState({
lastOffset: { x: animationConfig.toValue.x, y: animationConfig.toValue.y },
leftActionActivated: false,
rightActionActivated: false,
leftButtonsOpen: leftButtonsActivated,
rightButtonsOpen: rightButtonsActivated
});
pan.flattenOffset();
animationFn(pan, animationConfig).start(function () {
if (_this._unmounted) {
return;
}
var _this$props3 = _this.props,
onLeftActionComplete = _this$props3.onLeftActionComplete,
onLeftButtonsOpenComplete = _this$props3.onLeftButtonsOpenComplete,
onLeftButtonsCloseComplete = _this$props3.onLeftButtonsCloseComplete,
onRightActionComplete = _this$props3.onRightActionComplete,
onRightButtonsOpenComplete = _this$props3.onRightButtonsOpenComplete,
onRightButtonsCloseComplete = _this$props3.onRightButtonsCloseComplete,
onSwipeComplete = _this$props3.onSwipeComplete;
onSwipeComplete(event, gestureState, _this);
if (leftActionActivated) {
onLeftActionComplete(event, gestureState, _this);
onLeftActionDeactivate(event, gestureState, _this);
}
if (rightActionActivated) {
onRightActionComplete(event, gestureState, _this);
onRightActionDeactivate(event, gestureState, _this);
}
if (leftButtonsActivated && !leftButtonsOpen) {
onLeftButtonsOpenComplete(event, gestureState, _this);
}
if (!leftButtonsActivated && leftButtonsOpen) {
onLeftButtonsCloseComplete(event, gestureState, _this);
}
if (rightButtonsActivated && !rightButtonsOpen) {
onRightButtonsOpenComplete(event, gestureState, _this);
}
if (!rightButtonsActivated && rightButtonsOpen) {
onRightButtonsCloseComplete(event, gestureState, _this);
}
});
}, _this._panResponder = _reactNative.PanResponder.create({
onMoveShouldSetPanResponder: _this._handleMoveShouldSetPanResponder,
onMoveShouldSetPanResponderCapture: _this._handleMoveShouldSetPanResponder,
onPanResponderGrant: _this._handlePanResponderStart,
onPanResponderMove: _this._handlePanResponderMove,
onPanResponderRelease: _this._handlePanResponderEnd,
onPanResponderTerminate: _this._handlePanResponderEnd,
onPanResponderTerminationRequest: _this._handlePanResponderEnd
}), _this._handleLayout = function (_ref2) {
var width = _ref2.nativeEvent.layout.width;
return _this.setState({ width: width });
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(Swipeable, [{
key: 'componentWillMount',
value: function componentWillMount() {
var _props = this.props,
onPanAnimatedValueRef = _props.onPanAnimatedValueRef,
onRef = _props.onRef;
onRef(this);
onPanAnimatedValueRef(this.state.pan);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this._unmounted = true;
}
}, {
key: '_canSwipeRight',
value: function _canSwipeRight() {
return this.props.leftContent || this._hasLeftButtons();
}
}, {
key: '_canSwipeLeft',
value: function _canSwipeLeft() {
return this.props.rightContent || this._hasRightButtons();
}
}, {
key: '_hasLeftButtons',
value: function _hasLeftButtons() {
var _props2 = this.props,
leftButtons = _props2.leftButtons,
leftContent = _props2.leftContent;
return !leftContent && leftButtons && leftButtons.length;
}
}, {
key: '_hasRightButtons',
value: function _hasRightButtons() {
var _props3 = this.props,
rightButtons = _props3.rightButtons,
rightContent = _props3.rightContent;
return !rightContent && rightButtons && rightButtons.length;
}
}, {
key: '_getReleaseAnimationFn',
value: function _getReleaseAnimationFn() {
var _props4 = this.props,
leftActionReleaseAnimationFn = _props4.leftActionReleaseAnimationFn,
leftButtonsOpenReleaseAnimationFn = _props4.leftButtonsOpenReleaseAnimationFn,
leftButtonsCloseReleaseAnimationFn = _props4.leftButtonsCloseReleaseAnimationFn,
rightActionReleaseAnimationFn = _props4.rightActionReleaseAnimationFn,
rightButtonsOpenReleaseAnimationFn = _props4.rightButtonsOpenReleaseAnimationFn,
rightButtonsCloseReleaseAnimationFn = _props4.rightButtonsCloseReleaseAnimationFn,
swipeReleaseAnimationFn = _props4.swipeReleaseAnimationFn;
var _state = this.state,
leftActionActivated = _state.leftActionActivated,
leftButtonsActivated = _state.leftButtonsActivated,
leftButtonsOpen = _state.leftButtonsOpen,
rightActionActivated = _state.rightActionActivated,
rightButtonsActivated = _state.rightButtonsActivated,
rightButtonsOpen = _state.rightButtonsOpen;
if (leftActionActivated && leftActionReleaseAnimationFn) {
return leftActionReleaseAnimationFn;
}
if (rightActionActivated && rightActionReleaseAnimationFn) {
return rightActionReleaseAnimationFn;
}
if (leftButtonsActivated && leftButtonsOpenReleaseAnimationFn) {
return leftButtonsOpenReleaseAnimationFn;
}
if (!leftButtonsActivated && leftButtonsOpen && leftButtonsCloseReleaseAnimationFn) {
return leftButtonsCloseReleaseAnimationFn;
}
if (rightButtonsActivated && rightButtonsOpenReleaseAnimationFn) {
return rightButtonsOpenReleaseAnimationFn;
}
if (!rightButtonsActivated && rightButtonsOpen && rightButtonsCloseReleaseAnimationFn) {
return rightButtonsCloseReleaseAnimationFn;
}
return swipeReleaseAnimationFn;
}
}, {
key: '_getReleaseAnimationConfig',
value: function _getReleaseAnimationConfig() {
var _props5 = this.props,
leftActionReleaseAnimationConfig = _props5.leftActionReleaseAnimationConfig,
leftButtons = _props5.leftButtons,
leftButtonsOpenReleaseAnimationConfig = _props5.leftButtonsOpenReleaseAnimationConfig,
leftButtonsCloseReleaseAnimationConfig = _props5.leftButtonsCloseReleaseAnimationConfig,
leftButtonWidth = _props5.leftButtonWidth,
rightActionReleaseAnimationConfig = _props5.rightActionReleaseAnimationConfig,
rightButtons = _props5.rightButtons,
rightButtonsOpenReleaseAnimationConfig = _props5.rightButtonsOpenReleaseAnimationConfig,
rightButtonsCloseReleaseAnimationConfig = _props5.rightButtonsCloseReleaseAnimationConfig,
rightButtonWidth = _props5.rightButtonWidth,
swipeReleaseAnimationConfig = _props5.swipeReleaseAnimationConfig;
var _state2 = this.state,
leftActionActivated = _state2.leftActionActivated,
leftButtonsActivated = _state2.leftButtonsActivated,
leftButtonsOpen = _state2.leftButtonsOpen,
rightActionActivated = _state2.rightActionActivated,
rightButtonsActivated = _state2.rightButtonsActivated,
rightButtonsOpen = _state2.rightButtonsOpen;
if (leftActionActivated && leftActionReleaseAnimationConfig) {
return leftActionReleaseAnimationConfig;
}
if (rightActionActivated && rightActionReleaseAnimationConfig) {
return rightActionReleaseAnimationConfig;
}
if (leftButtonsActivated) {
return _extends({}, swipeReleaseAnimationConfig, {
toValue: {
x: leftButtons.length * leftButtonWidth,
y: 0
}
}, leftButtonsOpenReleaseAnimationConfig);
}
if (rightButtonsActivated) {
return _extends({}, swipeReleaseAnimationConfig, {
toValue: {
x: rightButtons.length * rightButtonWidth * -1,
y: 0
}
}, rightButtonsOpenReleaseAnimationConfig);
}
if (!leftButtonsActivated && leftButtonsOpen && leftButtonsCloseReleaseAnimationConfig) {
return leftButtonsCloseReleaseAnimationConfig;
}
if (!rightButtonsActivated && rightButtonsOpen && rightButtonsCloseReleaseAnimationConfig) {
return rightButtonsCloseReleaseAnimationConfig;
}
return swipeReleaseAnimationConfig;
}
}, {
key: '_renderButtons',
value: function _renderButtons(buttons, isLeftButtons) {
var _props6 = this.props,
leftButtonContainerStyle = _props6.leftButtonContainerStyle,
rightButtonContainerStyle = _props6.rightButtonContainerStyle;
var _state3 = this.state,
pan = _state3.pan,
width = _state3.width;
var canSwipeLeft = this._canSwipeLeft();
var canSwipeRight = this._canSwipeRight();
var count = buttons.length;
var leftEnd = canSwipeLeft ? -width : 0;
var rightEnd = canSwipeRight ? width : 0;
var inputRange = isLeftButtons ? [0, rightEnd] : [leftEnd, 0];
return buttons.map(function (buttonContent, index) {
var outputMultiplier = -index / count;
var outputRange = isLeftButtons ? [0, rightEnd * outputMultiplier] : [leftEnd * outputMultiplier, 0];
var transform = [{
translateX: pan.x.interpolate({
inputRange: inputRange,
outputRange: outputRange,
extrapolate: 'clamp'
})
}];
var buttonStyle = [_reactNative.StyleSheet.absoluteFill, { width: width, transform: transform }, isLeftButtons ? leftButtonContainerStyle : rightButtonContainerStyle];
return _react2.default.createElement(
_reactNative.Animated.View,
{ key: index, style: buttonStyle },
buttonContent
);
});
}
}, {
key: 'render',
value: function render() {
var _props7 = this.props,
children = _props7.children,
contentContainerStyle = _props7.contentContainerStyle,
leftButtons = _props7.leftButtons,
leftContainerStyle = _props7.leftContainerStyle,
leftContent = _props7.leftContent,
rightButtons = _props7.rightButtons,
rightContainerStyle = _props7.rightContainerStyle,
rightContent = _props7.rightContent,
style = _props7.style,
props = _objectWithoutProperties(_props7, ['children', 'contentContainerStyle', 'leftButtons', 'leftContainerStyle', 'leftContent', 'rightButtons', 'rightContainerStyle', 'rightContent', 'style']);
var _state4 = this.state,
pan = _state4.pan,
width = _state4.width;
var canSwipeLeft = this._canSwipeLeft();
var canSwipeRight = this._canSwipeRight();
var transform = [{
translateX: pan.x.interpolate({
inputRange: [canSwipeLeft ? -width : 0, canSwipeRight ? width : 0],
outputRange: [canSwipeLeft ? -width + _reactNative.StyleSheet.hairlineWidth : 0, canSwipeRight ? width - _reactNative.StyleSheet.hairlineWidth : 0],
extrapolate: 'clamp'
})
}];
return _react2.default.createElement(
_reactNative.View,
_extends({ onLayout: this._handleLayout, style: [styles.container, style] }, this._panResponder.panHandlers, props),
canSwipeRight && _react2.default.createElement(
_reactNative.Animated.View,
{ style: [{ transform: transform, marginLeft: -width, width: width }, leftContainerStyle] },
leftContent || this._renderButtons(leftButtons, true)
),
_react2.default.createElement(
_reactNative.Animated.View,
{ style: [{ transform: transform }, styles.content, contentContainerStyle] },
children
),
canSwipeLeft && _react2.default.createElement(
_reactNative.Animated.View,
{ style: [{ transform: transform, marginRight: -width, width: width }, rightContainerStyle] },
rightContent || this._renderButtons(rightButtons, false)
)
);
}
}]);
return Swipeable;
}(_react.PureComponent);
Swipeable.propTypes = {
// elements
children: _propTypes.PropTypes.any,
leftContent: _propTypes.PropTypes.any,
rightContent: _propTypes.PropTypes.any,
leftButtons: _propTypes.PropTypes.array,
rightButtons: _propTypes.PropTypes.array,
// left action lifecycle
onLeftActionActivate: _propTypes.PropTypes.func,
onLeftActionDeactivate: _propTypes.PropTypes.func,
onLeftActionRelease: _propTypes.PropTypes.func,
onLeftActionComplete: _propTypes.PropTypes.func,
leftActionActivationDistance: _propTypes.PropTypes.number,
leftActionReleaseAnimationFn: animationFnPropType,
leftActionReleaseAnimationConfig: _propTypes.PropTypes.object,
// right action lifecycle
onRightActionActivate: _propTypes.PropTypes.func,
onRightActionDeactivate: _propTypes.PropTypes.func,
onRightActionRelease: _propTypes.PropTypes.func,
onRightActionComplete: _propTypes.PropTypes.func,
rightActionActivationDistance: _propTypes.PropTypes.number,
rightActionReleaseAnimationFn: animationFnPropType,
rightActionReleaseAnimationConfig: _propTypes.PropTypes.object,
// left buttons lifecycle
onLeftButtonsActivate: _propTypes.PropTypes.func,
onLeftButtonsDeactivate: _propTypes.PropTypes.func,
onLeftButtonsOpenRelease: _propTypes.PropTypes.func,
onLeftButtonsOpenComplete: _propTypes.PropTypes.func,
onLeftButtonsCloseRelease: _propTypes.PropTypes.func,
onLeftButtonsCloseComplete: _propTypes.PropTypes.func,
leftButtonWidth: _propTypes.PropTypes.number,
leftButtonsActivationDistance: _propTypes.PropTypes.number,
leftButtonsOpenReleaseAnimationFn: animationFnPropType,
leftButtonsOpenReleaseAnimationConfig: _propTypes.PropTypes.object,
leftButtonsCloseReleaseAnimationFn: animationFnPropType,
leftButtonsCloseReleaseAnimationConfig: _propTypes.PropTypes.object,
// right buttons lifecycle
onRightButtonsActivate: _propTypes.PropTypes.func,
onRightButtonsDeactivate: _propTypes.PropTypes.func,
onRightButtonsOpenRelease: _propTypes.PropTypes.func,
onRightButtonsOpenComplete: _propTypes.PropTypes.func,
onRightButtonsCloseRelease: _propTypes.PropTypes.func,
onRightButtonsCloseComplete: _propTypes.PropTypes.func,
rightButtonWidth: _propTypes.PropTypes.number,
rightButtonsActivationDistance: _propTypes.PropTypes.number,
rightButtonsOpenReleaseAnimationFn: animationFnPropType,
rightButtonsOpenReleaseAnimationConfig: _propTypes.PropTypes.object,
rightButtonsCloseReleaseAnimationFn: animationFnPropType,
rightButtonsCloseReleaseAnimationConfig: _propTypes.PropTypes.object,
// base swipe lifecycle
onSwipeStart: _propTypes.PropTypes.func,
onSwipeMove: _propTypes.PropTypes.func,
onSwipeRelease: _propTypes.PropTypes.func,
onSwipeComplete: _propTypes.PropTypes.func,
swipeReleaseAnimationFn: animationFnPropType,
swipeReleaseAnimationConfig: _propTypes.PropTypes.object,
// misc
onRef: _propTypes.PropTypes.func,
onPanAnimatedValueRef: _propTypes.PropTypes.func,
swipeStartMinDistance: _propTypes.PropTypes.number,
// styles
style: _reactNative.View.propTypes.style,
leftContainerStyle: _reactNative.View.propTypes.style,
leftButtonContainerStyle: _reactNative.View.propTypes.style,
rightContainerStyle: _reactNative.View.propTypes.style,
rightButtonContainerStyle: _reactNative.View.propTypes.style,
contentContainerStyle: _reactNative.View.propTypes.style
};
Swipeable.defaultProps = {
leftContent: null,
rightContent: null,
leftButtons: null,
rightButtons: null,
// left action lifecycle
onLeftActionActivate: noop,
onLeftActionDeactivate: noop,
onLeftActionRelease: noop,
onLeftActionComplete: noop,
leftActionActivationDistance: 125,
leftActionReleaseAnimationFn: null,
leftActionReleaseAnimationConfig: null,
// right action lifecycle
onRightActionActivate: noop,
onRightActionDeactivate: noop,
onRightActionRelease: noop,
onRightActionComplete: noop,
rightActionActivationDistance: 125,
rightActionReleaseAnimationFn: null,
rightActionReleaseAnimationConfig: null,
// left buttons lifecycle
onLeftButtonsActivate: noop,
onLeftButtonsDeactivate: noop,
onLeftButtonsOpenRelease: noop,
onLeftButtonsOpenComplete: noop,
onLeftButtonsCloseRelease: noop,
onLeftButtonsCloseComplete: noop,
leftButtonWidth: 75,
leftButtonsActivationDistance: 75,
leftButtonsOpenReleaseAnimationFn: null,
leftButtonsOpenReleaseAnimationConfig: null,
leftButtonsCloseReleaseAnimationFn: null,
leftButtonsCloseReleaseAnimationConfig: null,
// right buttons lifecycle
onRightButtonsActivate: noop,
onRightButtonsDeactivate: noop,
onRightButtonsOpenRelease: noop,
onRightButtonsOpenComplete: noop,
onRightButtonsCloseRelease: noop,
onRightButtonsCloseComplete: noop,
rightButtonWidth: 75,
rightButtonsActivationDistance: 75,
rightButtonsOpenReleaseAnimationFn: null,
rightButtonsOpenReleaseAnimationConfig: null,
rightButtonsCloseReleaseAnimationFn: null,
rightButtonsCloseReleaseAnimationConfig: null,
// base swipe lifecycle
onSwipeStart: noop,
onSwipeMove: noop,
onSwipeRelease: noop,
onSwipeComplete: noop,
swipeReleaseAnimationFn: _reactNative.Animated.timing,
swipeReleaseAnimationConfig: {
toValue: { x: 0, y: 0 },
duration: 250,
easing: _reactNative.Easing.elastic(0.5)
},
// misc
onRef: noop,
onPanAnimatedValueRef: noop,
swipeStartMinDistance: 15
};
exports.default = Swipeable;
var styles = _reactNative.StyleSheet.create({
container: {
flexDirection: 'row'
},
content: {
flex: 1
}
});
... ...
... ... @@ -525,20 +525,20 @@ export default class extends Component {
let dots = []
const ActiveDot = this.props.activeDot || <View style={[{
backgroundColor: this.props.activeDotColor || '#007aff',
width: 8,
height: 8,
borderRadius: 4,
backgroundColor: this.props.activeDotColor || 'white',
width: 6,
height: 6,
borderRadius: 3,
marginLeft: 3,
marginRight: 3,
marginTop: 3,
marginBottom: 3
}, this.props.activeDotStyle]} />
const Dot = this.props.dot || <View style={[{
backgroundColor: this.props.dotColor || 'rgba(0,0,0,.2)',
width: 8,
height: 8,
borderRadius: 4,
backgroundColor: this.props.dotColor || 'rgba(237, 237, 237, 0.5)',
width: 6,
height: 6,
borderRadius: 3,
marginLeft: 3,
marginRight: 3,
marginTop: 3,
... ...
#!/usr/bin/env bash
echo "Replace custom components!!!"
echo "Replace View.js..."
cp -f ./js/common/components/customComponents/View.js.bak ./node_modules/react-native/Libraries/Components/View/View.js
echo "Replace ScrollView.js..."
cp -f ./js/common/components/customComponents/android_0.35/ScrollView.js.bak ./node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js
echo "Replace ListView.js..."
cp -f ./js/common/components/customComponents/ListView.js.bak ./node_modules/react-native/Libraries/CustomComponents/ListView/ListView.js
cp -f ./js/common/components/customComponents/android_0.49.5/ListView.js.bak ./node_modules/react-native/Libraries/Lists/ListView/ListView.js
echo "Replace SectionList.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/SectionList.js.bak ./node_modules/react-native/Libraries/Lists/SectionList.js
echo "Replace VirtualizedSectionList.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/VirtualizedSectionList.js.bak ./node_modules/react-native/Libraries/Lists/VirtualizedSectionList.js
echo "Replace ScrollView.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/ScrollView.js.bak ./node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js
echo "Replace ScrollResponder.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/ScrollResponder.js.bak ./node_modules/react-native/Libraries/Components/ScrollResponder.js
echo "Replace TouchableOpacity.js..."
cp -f ./js/common/components/customComponents/TouchableOpacity.js.bak ./node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js
cp -f ./js/common/components/customComponents/android_0.49.5/TouchableOpacity.js.bak ./node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js
echo "Replace TouchableHighlight.js..."
cp -f ./js/common/components/customComponents/TouchableHighlight.js.bak ./node_modules/react-native/Libraries/Components/Touchable/TouchableHighlight.js
cp -f ./js/common/components/customComponents/android_0.49.5/TouchableHighlight.js.bak ./node_modules/react-native/Libraries/Components/Touchable/TouchableHighlight.js
echo "Replace View.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/View.js.bak ./node_modules/react-native/Libraries/Components/View/View.js
echo "Replace ViewPropTypes.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/ViewPropTypes.js.bak ./node_modules/react-native/Libraries/Components/View/ViewPropTypes.js
echo "Replace WebView.android.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/WebView.android.js.bak ./node_modules/react-native/Libraries/Components/WebView/WebView.android.js
echo "Replace react-native-swipeable.js..."
cp -f ./js/common/components/customComponents/android_0.49.5/react-native-swipeable.js.bak ./node_modules/react-native-swipeable/lib/index.js
echo "Replace react-native-swiper.js..."
cp -f ./js/common/components/customComponents/android_0.35/react-native-swiper.js.bak ./node_modules/react-native-swiper/src/index.js
echo "Replace ScrollResponder.js..."
cp -f ./js/common/components/customComponents/android_0.35/ScrollResponder.js.bak ./node_modules/react-native/Libraries/Components/ScrollResponder.js
echo "\n"
\ No newline at end of file
cp -f ./js/common/components/customComponents/android_0.49.5/react-native-swiper.js.bak ./node_modules/react-native-swiper/src/index.js
echo "\n"
... ...