text: var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireWildcard(require("react"));var _propTypes=_interopRequireDefault(require("prop-types"));var _reactNative=require("react-native");var _withTheme=_interopRequireDefault(require("../../../Theme/withTheme"));var _Fab=_interopRequireDefault(require("../Fab.js"));var _FabSpeedDial=_interopRequireDefault(require("./FabSpeedDial.styles"));var _jsxFileName="/Users/cody/projects/material-bread/src/Components/Fab/FabSpeedDial/FabSpeedDial.js";var FabSpeedDial=function(_Component){(0,_inherits2.default)(FabSpeedDial,_Component);function FabSpeedDial(props){var _this;(0,_classCallCheck2.default)(this,FabSpeedDial);_this=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(FabSpeedDial).call(this,props));(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(_this),"state",{open:false,fabIcon:'add',actionAnimationsScale:[new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0)],actionAnimationsOpacity:[new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0),new _reactNative.Animated.Value(0)]});return _this;}(0,_createClass2.default)(FabSpeedDial,[{key:"toggleSpeedDial",value:function toggleSpeedDial(){this.setState({open:!this.state.open});}},{key:"toggleFabIcon",value:function toggleFabIcon(){var fab=this.props.fab;var open=this.state.open;var fabIcon;if(typeof fab!='string'){fabIcon=open?'clear':fab.props.icon;}else{fabIcon=open?'clear':fab;}this.setState({fabIcon:fabIcon});}},{key:"animateActions",value:function animateActions(){var onPress=this.props.onPress;var open=this.state.open;this.setState({open:!open});if(!open){this.openAnimation();}else{this.closeAnimation();}this.toggleFabIcon();if(onPress)onPress();}},{key:"openAnimation",value:function openAnimation(){var _this$state=this.state,actionAnimationsScale=_this$state.actionAnimationsScale,actionAnimationsOpacity=_this$state.actionAnimationsOpacity;_reactNative.Animated.parallel([_reactNative.Animated.stagger(50,actionAnimationsScale.map(function(animation){return _reactNative.Animated.timing(animation,{toValue:1,duration:150,useNativeDriver:true});}).reverse()),_reactNative.Animated.stagger(50,actionAnimationsOpacity.map(function(animation){return _reactNative.Animated.timing(animation,{toValue:1,duration:150,useNativeDriver:true});}).reverse())]).start();}},{key:"closeAnimation",value:function closeAnimation(){var _this$state2=this.state,actionAnimationsScale=_this$state2.actionAnimationsScale,actionAnimationsOpacity=_this$state2.actionAnimationsOpacity;_reactNative.Animated.parallel([_reactNative.Animated.stagger(50,actionAnimationsScale.map(function(animation){return _reactNative.Animated.timing(animation,{toValue:0,duration:150,useNativeDriver:true});})),_reactNative.Animated.stagger(50,actionAnimationsOpacity.map(function(animation){return _reactNative.Animated.timing(animation,{toValue:0,duration:150,useNativeDriver:true});}))]).start();}},{key:"renderActions",value:function renderActions(){var _this2=this;var actions=this.props.actions;return _react.default.createElement(_reactNative.View,{style:{marginBottom:24,alignItems:'flex-end'},__source:{fileName:_jsxFileName,lineNumber:143}},actions.map(function(item,index){return _react.default.createElement(_reactNative.Animated.View,{useNativeDriver:false,key:index,style:{marginTop:16,transform:[{scale:_this2.state.actionAnimationsScale[index]}],opacity:_this2.state.actionAnimationsOpacity[index]},__source:{fileName:_jsxFileName,lineNumber:150}},item);}));}},{key:"_renderFab",value:function _renderFab(){var _this3=this;var _this$props=this.props,fab=_this$props.fab,style=_this$props.style,fabProps=_this$props.fabProps;var _this$state3=this.state,fabIcon=_this$state3.fabIcon,open=_this$state3.open;if(typeof fab=='string'||fab instanceof String||!fab){return _react.default.createElement(_Fab.default,(0,_extends2.default)({icon:fabIcon,onPress:function onPress(){return _this3.animateActions();},style:style},fabProps,{__source:{fileName:_jsxFileName,lineNumber:172}}));}else{return _react.default.cloneElement(fab,{label:open?'':fab.props.label,icon:fabIcon,color:fab.props.color?fab.props.color:'white',onPress:function onPress(){return _this3.animateActions();}});}}},{key:"render",value:function render(){var _this$props2=this.props,containerStyle=_this$props2.containerStyle,testID=_this$props2.testID;return _react.default.createElement(_reactNative.View,{style:[_FabSpeedDial.default.container,containerStyle],testID:testID,__source:{fileName:_jsxFileName,lineNumber:192}},this.renderActions(),this._renderFab());}}]);return FabSpeedDial;}(_react.Component);(0,_defineProperty2.default)(FabSpeedDial,"propTypes",{containerStyle:_propTypes.default.oneOfType([_propTypes.default.array,_propTypes.default.object]),style:_propTypes.default.oneOfType([_propTypes.default.array,_propTypes.default.object]),onPress:_propTypes.default.func,actions:_propTypes.default.array,fab:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.node]),testID:_propTypes.default.string,fabProps:_propTypes.default.object});(0,_defineProperty2.default)(FabSpeedDial,"defaultProps",{fab:'add'});var _default=(0,_withTheme.default)(FabSpeedDial);exports.default=_default;