var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _this=this,_jsxFileName="/Users/tima/Tima/react-native-timacare/src/components/keyboardspace/index.tsx";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t in e)"default"!==_t&&{}.hasOwnProperty.call(e,_t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t))&&(i.get||i.set)?o(f,_t,i):f[_t]=e[_t]);return f;})(e,t);}var styles=_reactNative.StyleSheet.create({container:{left:0,right:0}});var defaultAnimation={duration:500,create:{duration:300,type:_reactNative.LayoutAnimation.Types.easeInEaseOut,property:_reactNative.LayoutAnimation.Properties.opacity},update:{type:_reactNative.LayoutAnimation.Types.spring,springDamping:200}};var KeyboardSpacer=function KeyboardSpacer(_ref){var _ref$topSpacing=_ref.topSpacing,topSpacing=_ref$topSpacing===void 0?0:_ref$topSpacing,_ref$onToggle=_ref.onToggle,onToggle=_ref$onToggle===void 0?function(){}:_ref$onToggle,style=_ref.style;var _useState=(0,_react.useState)(0),_useState2=(0,_slicedToArray2.default)(_useState,2),keyboardSpace=_useState2[0],setKeyboardSpace=_useState2[1];(0,_react.useEffect)(function(){var showEvent=_reactNative.Platform.OS==='android'?'keyboardDidShow':'keyboardWillShow';var hideEvent=_reactNative.Platform.OS==='android'?'keyboardDidHide':'keyboardWillHide';var onShow=function onShow(event){if(!(event!=null&&event.endCoordinates))return;var animationConfig=defaultAnimation;if(_reactNative.Platform.OS==='ios'){animationConfig=_reactNative.LayoutAnimation.create(event.duration,_reactNative.LayoutAnimation.Types[event.easing]||'keyboard',_reactNative.LayoutAnimation.Properties.opacity);}_reactNative.LayoutAnimation.configureNext(animationConfig);var screenHeight=_reactNative.Dimensions.get('window').height;var height=screenHeight-event.endCoordinates.screenY+topSpacing;setKeyboardSpace(height);onToggle(true,height);};var onHide=function onHide(event){var animationConfig=defaultAnimation;if(_reactNative.Platform.OS==='ios'){animationConfig=_reactNative.LayoutAnimation.create((event==null?void 0:event.duration)||250,_reactNative.LayoutAnimation.Types[event==null?void 0:event.easing]||'keyboard',_reactNative.LayoutAnimation.Properties.opacity);}_reactNative.LayoutAnimation.configureNext(animationConfig);setKeyboardSpace(0);onToggle(false,0);};var showSub=_reactNative.Keyboard.addListener(showEvent,onShow);var hideSub=_reactNative.Keyboard.addListener(hideEvent,onHide);return function(){showSub.remove();hideSub.remove();};},[topSpacing,onToggle]);return _react.default.createElement(_reactNative.View,{style:[styles.container,{height:keyboardSpace},style],__self:_this,__source:{fileName:_jsxFileName,lineNumber:101,columnNumber:10}});};var _default=exports.default=KeyboardSpacer;
//# sourceMappingURL=index.js.map