UNPKG

react-navigation-stack

Version:
2 lines 2.4 kB
import _extends from"@babel/runtime/helpers/extends";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";var _jsxFileName="/Users/satya/Workspace/Callstack/react-navigation-stack/src/views/BorderlessButton.tsx";import*as React from'react';import{Animated,Platform}from'react-native';import{BaseButton}from'react-native-gesture-handler';var AnimatedBaseButton=Animated.createAnimatedComponent(BaseButton);var USE_NATIVE_DRIVER=Platform.OS==='android'||Platform.OS==='ios';var BorderlessButton=function(_React$Component){_inherits(BorderlessButton,_React$Component);function BorderlessButton(){var _getPrototypeOf2;var _this;_classCallCheck(this,BorderlessButton);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_possibleConstructorReturn(this,(_getPrototypeOf2=_getPrototypeOf(BorderlessButton)).call.apply(_getPrototypeOf2,[this].concat(args)));_this.opacity=new Animated.Value(1);_this.handleActiveStateChange=function(active){if(Platform.OS!=='android'){Animated.spring(_this.opacity,{stiffness:1000,damping:500,mass:3,overshootClamping:true,restDisplacementThreshold:0.01,restSpeedThreshold:0.01,toValue:active?_this.props.activeOpacity:1,useNativeDriver:USE_NATIVE_DRIVER}).start();}_this.props.onActiveStateChange&&_this.props.onActiveStateChange(active);};return _this;}_createClass(BorderlessButton,[{key:"render",value:function render(){var _this$props=this.props,children=_this$props.children,style=_this$props.style,enabled=_this$props.enabled,rest=_objectWithoutProperties(_this$props,["children","style","enabled"]);return React.createElement(AnimatedBaseButton,_extends({},rest,{onActiveStateChange:this.handleActiveStateChange,style:[style,Platform.OS==='ios'&&enabled&&{opacity:this.opacity}],__source:{fileName:_jsxFileName,lineNumber:42}}),children);}}]);return BorderlessButton;}(React.Component);BorderlessButton.defaultProps={activeOpacity:0.3,borderless:true};export{BorderlessButton as default}; //# sourceMappingURL=BorderlessButton.js.map