diff --git a/.gitignore b/.gitignore index a4e59f5..3a97137 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ __tests__/__snapshots__ coverage # Compiled files -# dist +dist # Dependency directories node_modules diff --git a/dist/SnackBar.js b/dist/SnackBar.js deleted file mode 100644 index c5f66e7..0000000 --- a/dist/SnackBar.js +++ /dev/null @@ -1,265 +0,0 @@ -Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i1&&arguments[1]!==undefined?arguments[1]:function(){};var style=arguments[2];var -buttonColor=_this.props.buttonColor; - -return( -_react2.default.createElement(_reactNative.TouchableOpacity,{style:styles.buttonContainer,onPress:onPress}, -_react2.default.createElement(_reactNative.Text,{style:[styles.button,style,{color:buttonColor}]}, -text))); - - - -};_this. - -renderContent=function(){var _this$props3= - - - - - - - -_this.props,confirmText=_this$props3.confirmText,onConfirm=_this$props3.onConfirm,cancelText=_this$props3.cancelText,onCancel=_this$props3.onCancel,title=_this$props3.title,textColor=_this$props3.textColor; - -var titleElement=_react2.default.createElement(_reactNative.Text,{style:[styles.text,{color:textColor}]},title); - -if(confirmText&&cancelText){ -return( -_react2.default.createElement(_reactNative.View,null, -titleElement, -_react2.default.createElement(_reactNative.View,{style:styles.actionRow}, -_this.renderButton(cancelText,onCancel,styles.flat), -_this.renderButton(confirmText,onConfirm,styles.flat)))); - - - -} - -if(confirmText){ -return( -_react2.default.createElement(_reactNative.View,{style:styles.inlineRow}, -_react2.default.createElement(_reactNative.Text,{style:[styles.inlineText,{color:textColor}]},title), -_this.renderButton(confirmText,onConfirm))); - - -} - -return titleElement; -};_this.state={transformOffsetY:new _reactNative.Animated.Value(0),transformOpacity:new _reactNative.Animated.Value(0)};return _this;}_createClass(SnackBar,[{key:'componentDidMount',value:function componentDidMount(){this.show();}},{key:'componentWillUnmount',value:function componentWillUnmount(){this.hide();}},{key:'componentWillReceiveProps',value:function componentWillReceiveProps(nextProps){var _props=this.props,title=_props.title,confirmText=_props.confirmText,cancelText=_props.cancelText;var isPropsChanged=title!==nextProps.title||confirmText!==nextProps.confirmText||cancelText!==nextProps.cancelText;if(isPropsChanged){this.hide();this.show();}}},{key:'render',value:function render() - -{var _props2= -this.props,style=_props2.style,backgroundColor=_props2.backgroundColor; - -return( -_react2.default.createElement(_reactNative.Animated.View,{ -style:[ -styles.container, -{ -opacity:this.state.transformOpacity, -transform:[{translateY:this.state.transformOffsetY}], -backgroundColor:backgroundColor}, - -style]}, - - -this.renderContent())); - - -}}]);return SnackBar;}(_react.Component);SnackBar.defaultProps={fadeOutDuration:DEFAULT_FADEOUT_DURATION,duration:DEFAULT_DURATION,isStatic:false,onConfirm:Function,onCancel:Function,onAutoDismiss:Function,style:{},backgroundColor:STYLE_BANNER_COLOR,buttonColor:TEXT_COLOR_ACCENT,textColor:'white'};exports.default=SnackBar; -//# sourceMappingURL=SnackBar.js.map \ No newline at end of file diff --git a/dist/SnackBar.js.map b/dist/SnackBar.js.map deleted file mode 100644 index de3f279..0000000 --- a/dist/SnackBar.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/SnackBar.js"],"names":["DEFAULT_DURATION","DEFAULT_FADEOUT_DURATION","INITIAL_POSITION","STYLE_BANNER_COLOR","TEXT_COLOR_ACCENT","TIMEOUT_ID","get","width","styles","create","container","flex","position","bottom","text","padding","fontSize","inlineText","buttonContainer","paddingHorizontal","button","fontWeight","actionRow","flexDirection","justifyContent","marginBottom","inlineRow","flat","marginHorizontal","SnackBar","props","show","state","transformOpacity","transformOffsetY","fadeOutDuration","isStatic","duration","parallel","timing","toValue","easing","inOut","quad","start","runAfterInteractions","setTimeout","hide","onAutoDismiss","renderButton","onPress","style","buttonColor","color","renderContent","confirmText","onConfirm","cancelText","onCancel","title","textColor","titleElement","Value","nextProps","isPropsChanged","backgroundColor","opacity","transform","translateY","defaultProps","Function"],"mappings":";;AAEA,4B;AACA,oD;;;AAGA,yC;;;;;;;;;;;AAWA,GAAMA,kBAA2B,IAAjC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AAI,uBAAS4B,KAAb,CAAmB,CAAnB,CADP,CAEX7B,iBAAkB,GAAI,uBAAS6B,KAAb,CAAmB,CAAnB,CAFP,CAAb,CAHiC,aAOlC,C,kFAEoB,CACnB,KAAK/B,IAAL,GACD,C,mEAEuB,CACtB,KAAKgB,IAAL,GACD,C,4EAE0BgB,S,CAA0B,YAK/C,KAAKjC,KAL0C,CAEjD6B,KAFiD,QAEjDA,KAFiD,CAGjDJ,WAHiD,QAGjDA,WAHiD,CAIjDE,UAJiD,QAIjDA,UAJiD,CAOnD,GAAMO,gBACJL,QAAUI,UAAUJ,KAApB,EACAJ,cAAgBQ,UAAUR,WAD1B,EAEAE,aAAeM,UAAUN,UAH3B,CAMA,GAAIO,cAAJ,CAAoB,CAClB,KAAKjB,IAAL,GACA,KAAKhB,IAAL,GACD,CACF,C;;AAgHS;AAC2B,KAAKD,KADhC,CACAqB,KADA,SACAA,KADA,CACOc,eADP,SACOA,eADP;;AAGR;AACE,oDAAU,IAAV;AACE,MAAO;AACLzD,OAAOE,SADF;AAEL;AACEwD,QAAS,KAAKlC,KAAL,CAAWC,gBADtB;AAEEkC,UAAW,CAAC,CAAEC,WAAY,KAAKpC,KAAL,CAAWE,gBAAzB,CAAD,CAFb;AAGE+B,+BAHF,CAFK;;AAOLd,KAPK,CADT;;;AAWI,KAAKG,aAAL,EAXJ,CADF;;;AAeD,C,wCA9LkBzB,Q,CAQZwC,Y,CAAe,CAEpBlC,gBAAiBlC,wBAFG,CAGpBoC,SAAUrC,gBAHU,CAIpBoC,SAAU,KAJU,CAOpBoB,UAAWc,QAPS,CAQpBZ,SAAUY,QARU,CASpBtB,cAAesB,QATK,CAYpBnB,MAAO,EAZa,CAapBc,gBAAiB9D,kBAbG,CAcpBiD,YAAahD,iBAdO,CAepBwD,UAAW,OAfS,C,iBARH/B,Q","file":"SnackBar.js","sourcesContent":["// @flow\n\nimport React, { Component } from 'react'\nimport Timer from 'react-native-timer'\nimport type { SnackItemType } from './type'\n\nimport {\n View,\n Animated,\n Dimensions,\n Text,\n StyleSheet,\n TouchableOpacity,\n Easing,\n InteractionManager\n} from 'react-native'\n\nconst DEFAULT_DURATION: number = 5000\nconst DEFAULT_FADEOUT_DURATION: number = 250\nconst INITIAL_POSITION: number = -180\n\nconst STYLE_BANNER_COLOR: string = '#000000'\nconst TEXT_COLOR_ACCENT: string = '#0088ff'\n\nconst TIMEOUT_ID: string = 'snackBar'\n\nconst { width } = Dimensions.get('window')\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n position: 'absolute',\n bottom: INITIAL_POSITION,\n width\n },\n\n text: {\n padding: 24,\n fontSize: 16\n },\n\n inlineText: {\n fontSize: 16\n },\n\n buttonContainer: {\n paddingHorizontal: 4\n },\n\n button: {\n fontSize: 16,\n fontWeight: '500'\n },\n\n actionRow: {\n flexDirection: 'row',\n justifyContent: 'flex-end',\n padding: 18,\n marginBottom: 6\n },\n\n inlineRow: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n padding: 18\n },\n\n flat: {\n fontSize: 14,\n marginHorizontal: 16\n }\n})\n\nexport default class SnackBar extends Component {\n state: {\n transformOffsetY: any,\n transformOpacity: any\n }\n\n props: SnackItemType\n\n static defaultProps = {\n // Behaviour\n fadeOutDuration: DEFAULT_FADEOUT_DURATION,\n duration: DEFAULT_DURATION,\n isStatic: false,\n\n // Functions\n onConfirm: Function,\n onCancel: Function,\n onAutoDismiss: Function,\n\n // Styles\n style: {},\n backgroundColor: STYLE_BANNER_COLOR,\n buttonColor: TEXT_COLOR_ACCENT,\n textColor: 'white'\n }\n\n constructor (props: SnackItemType) {\n super(props)\n\n this.state = {\n transformOffsetY: new Animated.Value(0),\n transformOpacity: new Animated.Value(0)\n }\n }\n\n componentDidMount () {\n this.show()\n }\n\n componentWillUnmount () {\n this.hide()\n }\n\n componentWillReceiveProps (nextProps: SnackItemType) {\n const {\n title,\n confirmText,\n cancelText\n } = this.props\n\n const isPropsChanged = (\n title !== nextProps.title ||\n confirmText !== nextProps.confirmText ||\n cancelText !== nextProps.cancelText\n )\n\n if (isPropsChanged) {\n this.hide()\n this.show()\n }\n }\n\n show = () => {\n const {\n transformOpacity,\n transformOffsetY\n } = this.state\n\n const {\n fadeOutDuration,\n isStatic,\n duration\n } = this.props\n\n Animated.parallel([\n Animated.timing(transformOpacity, {\n toValue: 1,\n duration: fadeOutDuration,\n easing: Easing.inOut(Easing.quad)\n }),\n Animated.timing(transformOffsetY, {\n toValue: INITIAL_POSITION,\n duration: fadeOutDuration,\n easing: Easing.inOut(Easing.quad)\n })\n ]).start(() => {\n if (isStatic) {\n return\n }\n\n InteractionManager.runAfterInteractions(() => {\n Timer.setTimeout(TIMEOUT_ID, () => {\n this.hide()\n }, duration)\n })\n })\n }\n\n hide = () => {\n const {\n transformOpacity,\n transformOffsetY\n } = this.state\n\n const {\n fadeOutDuration,\n onAutoDismiss\n } = this.props\n\n Animated.parallel([\n Animated.timing(transformOpacity, {\n toValue: 0,\n duration: fadeOutDuration,\n easing: Easing.inOut(Easing.quad)\n\n }),\n Animated.timing(transformOffsetY, {\n toValue: INITIAL_POSITION * -1,\n easing: Easing.inOut(Easing.quad),\n duration: fadeOutDuration\n })\n ]).start(() => { onAutoDismiss && onAutoDismiss() })\n }\n\n renderButton = (text: string, onPress: Function = () => {}, style?: Object) => {\n const { buttonColor } = this.props\n\n return (\n \n \n {text}\n \n \n )\n }\n\n renderContent = () => {\n const {\n confirmText,\n onConfirm,\n cancelText,\n onCancel,\n title,\n textColor\n } = this.props\n\n const titleElement = {title}\n\n if (confirmText && cancelText) {\n return (\n \n {titleElement}\n \n { this.renderButton(cancelText, onCancel, styles.flat) }\n { this.renderButton(confirmText, onConfirm, styles.flat) }\n \n \n )\n }\n\n if (confirmText) {\n return (\n \n {title}\n { this.renderButton(confirmText, onConfirm) }\n \n )\n }\n\n return titleElement\n }\n\n render () {\n const { style, backgroundColor } = this.props\n\n return (\n \n { this.renderContent() }\n \n )\n }\n}\n"]} \ No newline at end of file diff --git a/dist/SnackBarManager.js b/dist/SnackBarManager.js deleted file mode 100644 index 45c32b7..0000000 --- a/dist/SnackBarManager.js +++ /dev/null @@ -1,82 +0,0 @@ -Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i1&&arguments[1]!==undefined?arguments[1]:function(){}; -_this.current=new _reactNativeRootSiblings2.default(_react2.default.createElement(_SnackBar2.default,_extends({},props,{onAutoDismiss:_this.dismiss})),callback); -};this. - -_removeCurrent=function(){var callback=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){}; -if(!_this.current){ -callback(); -return; -} - -_this.current.destroy(function(){ -_this.current=null; -callback(); -}); -};this. - -get=function(){ -return{ -current:_this.current, -queue:_this.queue}; - -};this. - -add=function( -title, -options) - -{var callback=arguments.length>2&&arguments[2]!==undefined?arguments[2]:function(){}; -var props=_extends({title:title},options); - -if(_this.current){ -_this.queue.push(props); -callback(); -return; -} - -_this._setCurrent(props,callback); -};this. - -show=function( -title, -options) - -{var callback=arguments.length>2&&arguments[2]!==undefined?arguments[2]:function(){}; -var props=_extends({title:title},options); - -if(_this.current){ -_this.queue.unshift(props); -callback(); -return; -} - -_this._setCurrent(props,callback); -};this. - -dismiss=function(){var callback=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){}; -_this._removeCurrent(function(){ -if(!_this.queue.length){ -callback(); -return; -} - -var current=_this.queue.shift(); -_this._setCurrent(current,callback); -}); -};this.current=null;this.queue=[];};exports.default=SnackBarManager; -//# sourceMappingURL=SnackBarManager.js.map \ No newline at end of file diff --git a/dist/SnackBarManager.js.map b/dist/SnackBarManager.js.map deleted file mode 100644 index ae60a06..0000000 --- a/dist/SnackBarManager.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/SnackBarManager.js"],"names":["SnackBarManager","_setCurrent","props","callback","current","dismiss","_removeCurrent","destroy","get","queue","add","title","options","push","show","unshift","length","shift"],"mappings":"yRAAA,4B;AACA,mE;;;AAGA,oC;;AAEqBA,e;;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KG,cAAL,CAAoB,UAAM;AACxB,GAAI,CAAC,MAAKG,KAAL,CAAWO,MAAhB,CAAwB;AACtBb;AACA;AACD;;AAED,GAAMC,SAAU,MAAKK,KAAL,CAAWQ,KAAX,EAAhB;AACA,MAAKhB,WAAL,CAAiBG,OAAjB,CAA0BD,QAA1B;AACD,CARD;AASD,CAtEc,CACb,KAAKC,OAAL,CAAe,IAAf,CACA,KAAKK,KAAL,CAAa,EAAb,CACD,C,iBAPkBT,e","file":"SnackBarManager.js","sourcesContent":["import React from 'react'\nimport RootSiblings from 'react-native-root-siblings'\n\nimport type { SnackItemType } from './type'\nimport SnackBar from './SnackBar'\n\nexport default class SnackBarManager {\n current: SnackItemType\n queue: Array\n\n constructor () {\n this.current = null\n this.queue = []\n }\n\n _setCurrent = (props: SnackItemType, callback?: Function = () => {}): void => {\n this.current = new RootSiblings(, callback)\n }\n\n _removeCurrent = (callback?: Function = () => {}): void => {\n if (!this.current) {\n callback()\n return\n }\n\n this.current.destroy(() => {\n this.current = null\n callback()\n })\n }\n\n get = () => {\n return {\n current: this.current,\n queue: this.queue\n }\n }\n\n add = (\n title: string,\n options?: SnackItemType,\n callback?: Function = () => {}\n ): void => {\n const props = { title, ...options }\n\n if (this.current) {\n this.queue.push(props)\n callback()\n return\n }\n\n this._setCurrent(props, callback)\n }\n\n show = (\n title: string,\n options?: SnackItemType,\n callback?: Function = () => {}\n ): void => {\n const props = { title, ...options }\n\n if (this.current) {\n this.queue.unshift(props)\n callback()\n return\n }\n\n this._setCurrent(props, callback)\n }\n\n dismiss = (callback?: Function = () => {}): void => {\n this._removeCurrent(() => {\n if (!this.queue.length) {\n callback()\n return\n }\n\n const current = this.queue.shift()\n this._setCurrent(current, callback)\n })\n }\n}\n"]} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 0267df0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,4 +0,0 @@ -Object.defineProperty(exports,"__esModule",{value:true});var _SnackBarManager=require('./SnackBarManager');var _SnackBarManager2=_interopRequireDefault(_SnackBarManager);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}exports.default= - -new _SnackBarManager2.default(); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 88ac5fc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["../src/index.js"],"names":[],"mappings":"yDAAA,kD;;AAEe,+B","file":"index.js","sourcesContent":["import SnackBarManager from './SnackBarManager'\n\nexport default new SnackBarManager()\n"]} \ No newline at end of file diff --git a/dist/type.js b/dist/type.js deleted file mode 100644 index 4b791f5..0000000 --- a/dist/type.js +++ /dev/null @@ -1,2 +0,0 @@ -Object.defineProperty(module.exports,"babelPluginFlowReactPropTypes_proptype_SnackItemType",{value:require("react").PropTypes.shape({title:require("react").PropTypes.string.isRequired,confirmText:require("react").PropTypes.string,onConfirm:require("react").PropTypes.func,cancelText:require("react").PropTypes.string,onCancel:require("react").PropTypes.func,style:require("react").PropTypes.object,backgroundColor:require("react").PropTypes.string,buttonColor:require("react").PropTypes.string,textColor:require("react").PropTypes.string,onAutoDismiss:require("react").PropTypes.func,fadeOutDuration:require("react").PropTypes.number,duration:require("react").PropTypes.number,isStatic:require("react").PropTypes.bool})}); -//# sourceMappingURL=type.js.map \ No newline at end of file diff --git a/dist/type.js.map b/dist/type.js.map deleted file mode 100644 index ff51a2e..0000000 --- a/dist/type.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":[],"names":[],"mappings":"","file":"type.js","sourcesContent":[]} \ No newline at end of file diff --git a/package.json b/package.json index 2e62819..f55a70a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-snackbar-dialog", "version": "1.2.0", "description": "A react native snackbar with dialog options", - "main": "dist/index.js", + "main": "src/index.js", "scripts": { "prepublish": "npm run build", "clean": "rimraf dist",