docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
sequencelengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
"react-native-easy-grid": "https://github.com/GeekyAnts/react-native-easy-grid#development",
<mask> "native-base-shoutem-theme": "0.2.2", <mask> "print-message": "^2.1.0", <mask> "prop-types": "^15.5.10", <mask> "react-native-drawer": "2.5.0", <mask> "react-native-easy-grid": "0.1.17", <mask> "react-native-keyboard-aware-scroll-view": "0.5.0", <mask> "react-native-vector-icons": "~4.5.0", <mask> "react-tween-state": "^0.1.5", <mask> "tween-functions": "^1.0.1" <mask> }, </s> Upgraded deps and dev-deps, compatible with RN 0.56.0 </s> remove "jest": "19.0.2", "react": "^16.0.0-alpha.12", "react-native": "^0.46.0", "react-native-vector-icons": "~4.5.0", "react-test-renderer": "^16.0.0-alpha.12" </s> add "jest": "23.3.0", "react": "16.4.1", "react-native": "0.56.0", "react-native-vector-icons": "4.6.0", "react-test-renderer": "16.4.1" </s> remove Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color); var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var deviceHeight=_reactNative.Dimensions.get("window").height; var deviceWidth=_reactNative.Dimensions.get("window").width; var platform=_reactNative.Platform.OS; var platformStyle=undefined; var isIphoneX= platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default= { platformStyle:platformStyle, platform:platform, headerStyle:"#edebed", iconStyle:"#000", contentStyle:"#f5f4f5", expandedIconStyle:"#000", accordionBorderColor:"#d3d3d3", androidRipple:true, androidRippleColor:"rgba(256, 256, 256, 0.3)", androidRippleColorDark:"rgba(0, 0, 0, 0.15)", btnUppercaseAndroidText:true, badgeBg:"#ED1727", badgeColor:"#fff", badgePadding:platform==="ios"?3:0, btnFontFamily:platform==="ios"?"System":"Roboto_medium", btnDisabledBg:"#b5b5b5", buttonPadding:6, get btnPrimaryBg(){ return this.brandPrimary; }, get btnPrimaryColor(){ return this.inverseTextColor; }, get btnInfoBg(){ return this.brandInfo; }, get btnInfoColor(){ return this.inverseTextColor; }, get btnSuccessBg(){ return this.brandSuccess; }, get btnSuccessColor(){ return this.inverseTextColor; }, get btnDangerBg(){ return this.brandDanger; }, get btnDangerColor(){ return this.inverseTextColor; }, get btnWarningBg(){ return this.brandWarning; }, get btnWarningColor(){ return this.inverseTextColor; }, get btnTextSize(){ return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1; }, get btnTextSizeLarge(){ return this.fontSizeBase*1.5; }, get btnTextSizeSmall(){ return this.fontSizeBase*0.8; }, get borderRadiusLarge(){ return this.fontSizeBase*3.8; }, get iconSizeLarge(){ return this.iconFontSize*1.5; }, get iconSizeSmall(){ return this.iconFontSize*0.6; }, cardDefaultBg:"#fff", cardBorderColor:"#ccc", cardBorderRadius:2, cardItemPadding:platform==="ios"?10:12, CheckboxRadius:platform==="ios"?13:0, CheckboxBorderWidth:platform==="ios"?1:2, CheckboxPaddingLeft:platform==="ios"?4:2, CheckboxPaddingBottom:platform==="ios"?0:5, CheckboxIconSize:platform==="ios"?21:16, CheckboxIconMarginTop:platform==="ios"?undefined:1, CheckboxFontSize:platform==="ios"?23/0.9:17, checkboxBgColor:"#039BE5", checkboxSize:20, checkboxTickColor:"#fff", brandPrimary:platform==="ios"?"#007aff":"#3F51B5", brandInfo:"#62B1F6", brandSuccess:"#5cb85c", brandDanger:"#d9534f", brandWarning:"#f0ad4e", brandDark:"#000", brandLight:"#f4f4f4", datePickerTextColor:"#000", datePickerBg:"transparent", DefaultFontSize:16, fontFamily:platform==="ios"?"System":"Roboto", fontSizeBase:15, get fontSizeH1(){ return this.fontSizeBase*1.8; }, get fontSizeH2(){ return this.fontSizeBase*1.6; }, get fontSizeH3(){ return this.fontSizeBase*1.4; }, footerHeight:55, footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", footerPaddingBottom:0, tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", tabBarTextSize:platform==="ios"?14:11, activeTab:platform==="ios"?"#007aff":"#fff", sTabBarActiveTextColor:"#007aff", tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5", toolbarBtnColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", toolbarHeight:platform==="ios"?64:56, toolbarSearchIconSize:platform==="ios"?20:23, toolbarInputColor:platform==="ios"?"#CECDD2":"#fff", searchBarHeight:platform==="ios"?30:40, searchBarInputHeight:platform==="ios"?30:50, toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5", iosStatusbar:platform==="ios"?"dark-content":"light-content", get statusBarColor(){ return(0,_color2.default)(this.toolbarDefaultBg). darken(0.2). hex(); }, get darkenHeader(){ return(0,_color2.default)(this.tabBgColor). darken(0.03). hex(); }, iconFamily:"Ionicons", iconFontSize:platform==="ios"?30:28, iconHeaderSize:platform==="ios"?33:24, inputFontSize:17, inputBorderColor:"#D9D5DC", inputSuccessBorderColor:"#2b8339", inputErrorBorderColor:"#ed2f2f", inputHeightBase:50, get inputColor(){ return this.textColor; }, get inputColorPlaceholder(){ return"#575757"; }, btnLineHeight:19, lineHeightH1:32, lineHeightH2:27, lineHeightH3:22, lineHeight:platform==="ios"?20:24, listItemSelected:platform==="ios"?"#007aff":"#3F51B5", listBg:"transparent", listBorderColor:"#c9c9c9", listDividerBg:"#f4f4f4", listBtnUnderlayColor:"#DDD", listItemPadding:platform==="ios"?10:12, listNoteColor:"#808080", listNoteSize:13, defaultProgressColor:"#E4202D", inverseProgressColor:"#1A191B", radioBtnSize:platform==="ios"?25:23, radioSelectedColorAndroid:"#3F51B5", radioBtnLineHeight:platform==="ios"?29:24, get radioColor(){ return this.brandPrimary; }, segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5", segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff", segmentTextColor:platform==="ios"?"#007aff":"#fff", segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5", segmentBorderColor:platform==="ios"?"#007aff":"#fff", segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5", defaultSpinnerColor:"#45D56E", inverseSpinnerColor:"#1A191B", tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff", topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff", tabBgColor:"#F8F8F8", tabFontSize:15, textColor:"#000", inverseTextColor:"#fff", noteFontSize:14, get defaultTextColor(){ return this.textColor; }, titleFontfamily:platform==="ios"?"System":"Roboto_medium", titleFontSize:platform==="ios"?17:19, subTitleFontSize:platform==="ios"?11:14, subtitleColor:platform==="ios"?"#8e8e93":"#FFF", titleFontColor:platform==="ios"?"#000":"#FFF", borderRadiusBase:platform==="ios"?5:2, borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1), contentPadding:10, dropdownLinkColor:"#414142", inputLineHeight:24, deviceWidth:deviceWidth, deviceHeight:deviceHeight, isIphoneX:isIphoneX, inputGroupRoundedBorderRadius:30, Inset:{ portrait:{ topInset:24, leftInset:0, rightInset:0, bottomInset:34}, landscape:{ topInset:0, leftInset:44, rightInset:44, bottomInset:21}}}; </s> add Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color);var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var deviceHeight=_reactNative.Dimensions.get("window").height;var deviceWidth=_reactNative.Dimensions.get("window").width;var platform=_reactNative.Platform.OS;var platformStyle=undefined;var isIphoneX=platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default={platformStyle:platformStyle,platform:platform,headerStyle:"#edebed",iconStyle:"#000",contentStyle:"#f5f4f5",expandedIconStyle:"#000",accordionBorderColor:"#d3d3d3",androidRipple:true,androidRippleColor:"rgba(256, 256, 256, 0.3)",androidRippleColorDark:"rgba(0, 0, 0, 0.15)",btnUppercaseAndroidText:true,badgeBg:"#ED1727",badgeColor:"#fff",badgePadding:platform==="ios"?3:0,btnFontFamily:platform==="ios"?"System":"Roboto_medium",btnDisabledBg:"#b5b5b5",buttonPadding:6,get btnPrimaryBg(){return this.brandPrimary;},get btnPrimaryColor(){return this.inverseTextColor;},get btnInfoBg(){return this.brandInfo;},get btnInfoColor(){return this.inverseTextColor;},get btnSuccessBg(){return this.brandSuccess;},get btnSuccessColor(){return this.inverseTextColor;},get btnDangerBg(){return this.brandDanger;},get btnDangerColor(){return this.inverseTextColor;},get btnWarningBg(){return this.brandWarning;},get btnWarningColor(){return this.inverseTextColor;},get btnTextSize(){return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1;},get btnTextSizeLarge(){return this.fontSizeBase*1.5;},get btnTextSizeSmall(){return this.fontSizeBase*0.8;},get borderRadiusLarge(){return this.fontSizeBase*3.8;},get iconSizeLarge(){return this.iconFontSize*1.5;},get iconSizeSmall(){return this.iconFontSize*0.6;},cardDefaultBg:"#fff",cardBorderColor:"#ccc",cardBorderRadius:2,cardItemPadding:platform==="ios"?10:12,CheckboxRadius:platform==="ios"?13:0,CheckboxBorderWidth:platform==="ios"?1:2,CheckboxPaddingLeft:platform==="ios"?4:2,CheckboxPaddingBottom:platform==="ios"?0:5,CheckboxIconSize:platform==="ios"?21:16,CheckboxIconMarginTop:platform==="ios"?undefined:1,CheckboxFontSize:platform==="ios"?23/0.9:17,checkboxBgColor:"#039BE5",checkboxSize:20,checkboxTickColor:"#fff",brandPrimary:platform==="ios"?"#007aff":"#3F51B5",brandInfo:"#62B1F6",brandSuccess:"#5cb85c",brandDanger:"#d9534f",brandWarning:"#f0ad4e",brandDark:"#000",brandLight:"#f4f4f4",datePickerTextColor:"#000",datePickerBg:"transparent",DefaultFontSize:16,fontFamily:platform==="ios"?"System":"Roboto",fontSizeBase:15,get fontSizeH1(){return this.fontSizeBase*1.8;},get fontSizeH2(){return this.fontSizeBase*1.6;},get fontSizeH3(){return this.fontSizeBase*1.4;},footerHeight:55,footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",footerPaddingBottom:0,tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",tabBarTextSize:platform==="ios"?14:11,activeTab:platform==="ios"?"#007aff":"#fff",sTabBarActiveTextColor:"#007aff",tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5",toolbarBtnColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",toolbarHeight:platform==="ios"?64:56,toolbarSearchIconSize:platform==="ios"?20:23,toolbarInputColor:platform==="ios"?"#CECDD2":"#fff",searchBarHeight:platform==="ios"?30:40,searchBarInputHeight:platform==="ios"?30:50,toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5",iosStatusbar:platform==="ios"?"dark-content":"light-content",get statusBarColor(){return(0,_color2.default)(this.toolbarDefaultBg).darken(0.2).hex();},get darkenHeader(){return(0,_color2.default)(this.tabBgColor).darken(0.03).hex();},iconFamily:"Ionicons",iconFontSize:platform==="ios"?30:28,iconHeaderSize:platform==="ios"?33:24,inputFontSize:17,inputBorderColor:"#D9D5DC",inputSuccessBorderColor:"#2b8339",inputErrorBorderColor:"#ed2f2f",inputHeightBase:50,get inputColor(){return this.textColor;},get inputColorPlaceholder(){return"#575757";},btnLineHeight:19,lineHeightH1:32,lineHeightH2:27,lineHeightH3:22,lineHeight:platform==="ios"?20:24,listItemSelected:platform==="ios"?"#007aff":"#3F51B5",listBg:"transparent",listBorderColor:"#c9c9c9",listDividerBg:"#f4f4f4",listBtnUnderlayColor:"#DDD",listItemPadding:platform==="ios"?10:12,listNoteColor:"#808080",listNoteSize:13,defaultProgressColor:"#E4202D",inverseProgressColor:"#1A191B",radioBtnSize:platform==="ios"?25:23,radioSelectedColorAndroid:"#3F51B5",radioBtnLineHeight:platform==="ios"?29:24,get radioColor(){return this.brandPrimary;},segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5",segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff",segmentTextColor:platform==="ios"?"#007aff":"#fff",segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5",segmentBorderColor:platform==="ios"?"#007aff":"#fff",segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5",defaultSpinnerColor:"#45D56E",inverseSpinnerColor:"#1A191B",tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff",topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff",tabBgColor:"#F8F8F8",tabFontSize:15,textColor:"#000",inverseTextColor:"#fff",noteFontSize:14,get defaultTextColor(){return this.textColor;},titleFontfamily:platform==="ios"?"System":"Roboto_medium",titleFontSize:platform==="ios"?17:19,subTitleFontSize:platform==="ios"?11:14,subtitleColor:platform==="ios"?"#8e8e93":"#FFF",titleFontColor:platform==="ios"?"#000":"#FFF",borderRadiusBase:platform==="ios"?5:2,borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1),contentPadding:10,dropdownLinkColor:"#414142",inputLineHeight:24,deviceWidth:deviceWidth,deviceHeight:deviceHeight,isIphoneX:isIphoneX,inputGroupRoundedBorderRadius:30,Inset:{portrait:{topInset:24,leftInset:0,rightInset:0,bottomInset:34},landscape:{topInset:0,leftInset:44,rightInset:44,bottomInset:21}}}; </s> remove 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 _jsxFileName="src/basic/Tabs/index.js";var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;} var React=require("react");var Component=React.Component; var ReactNative=require("react-native");var Dimensions= ReactNative.Dimensions,View=ReactNative.View,Animated=ReactNative.Animated,ScrollView=ReactNative.ScrollView,StyleSheet=ReactNative.StyleSheet,Platform=ReactNative.Platform; var TimerMixin=require("react-timer-mixin"); var SceneComponent=require("./SceneComponent");var _require= require("./DefaultTabBar"),DefaultTabBar=_require.DefaultTabBar;var _require2= require("./ScrollableTabBar"),ScrollableTabBar=_require2.ScrollableTabBar; var ScrollableTabView=(0,_createReactClass2.default)({displayName:"ScrollableTabView", mixins:[TimerMixin], statics:{ DefaultTabBar:DefaultTabBar, ScrollableTabBar:ScrollableTabBar}, propTypes:{ tabBarPosition:_propTypes2.default.oneOf([ "top", "bottom", "overlayTop", "overlayBottom"]), initialPage:_propTypes2.default.number, page:_propTypes2.default.number, onChangeTab:_propTypes2.default.func, onScroll:_propTypes2.default.func, renderTabBar:_propTypes2.default.any, style:_utils.ViewPropTypes.style, contentProps:_propTypes2.default.object, scrollWithoutAnimation:_propTypes2.default.bool, locked:_propTypes2.default.bool, prerenderingSiblingsNumber:_propTypes2.default.number}, getDefaultProps:function getDefaultProps(){ return{ tabBarPosition:"top", initialPage:0, page:-1, onChangeTab:function onChangeTab(){}, onScroll:function onScroll(){}, contentProps:{}, scrollWithoutAnimation:false, locked:false, prerenderingSiblingsNumber:0}; }, getInitialState:function getInitialState(){ return{ currentPage:this.props.initialPage, scrollValue:new Animated.Value(this.props.initialPage), containerWidth:Dimensions.get("window").width, sceneKeys:this.newSceneKeys({currentPage:this.props.initialPage})}; }, componentDidMount:function componentDidMount(){var _this=this; var scrollFn=function scrollFn(){ if(_this.scrollView){ _this.state.scrollValue.setValue(_this.props.initialPage); } }; _utils.InteractionManager.runAfterInteractions(scrollFn); }, componentWillReceiveProps:function componentWillReceiveProps(props){ if(props.children!==this.props.children){ this.updateSceneKeys({ page:this.state.currentPage, children:props.children}); } if(props.page>=0&&props.page!==this.state.currentPage){ this.goToPage(props.page); } }, goToPage:function goToPage(pageNumber){ var offset=pageNumber*this.state.containerWidth; if(this.scrollView){ this.scrollView.scrollTo({ x:offset, y:0, animated:!this.props.scrollWithoutAnimation}); } var currentPage=this.state.currentPage; this.updateSceneKeys({ page:pageNumber, callback:this._onChangeTab.bind(this,currentPage,pageNumber)}); }, renderTabBar:function renderTabBar(props){ if(this.props.renderTabBar===false){ return null; }else if(this.props.renderTabBar){ return React.cloneElement(this.props.renderTabBar(props),props); }else{ return React.createElement(DefaultTabBar,_extends({},props,{__source:{fileName:_jsxFileName,lineNumber:116}})); } }, updateSceneKeys:function updateSceneKeys(_ref) {var page=_ref.page,_ref$children=_ref.children,children=_ref$children===undefined?this.props.children:_ref$children,_ref$callback=_ref.callback,callback=_ref$callback===undefined?function(){}:_ref$callback; var newKeys=this.newSceneKeys({ previousKeys:this.state.sceneKeys, currentPage:page, children:children}); this.setState({currentPage:page,sceneKeys:newKeys},callback); }, newSceneKeys:function newSceneKeys(_ref2) {var _this2=this;var _ref2$previousKeys=_ref2.previousKeys,previousKeys=_ref2$previousKeys===undefined?[]:_ref2$previousKeys,_ref2$currentPage=_ref2.currentPage,currentPage=_ref2$currentPage===undefined?0:_ref2$currentPage,_ref2$children=_ref2.children,children=_ref2$children===undefined?this.props.children:_ref2$children; var newKeys=[]; this._children(children).forEach(function(child,idx){ var key=_this2._makeSceneKey(child,idx); if( _this2._keyExists(previousKeys,key)|| _this2._shouldRenderSceneKey(idx,currentPage)) { newKeys.push(key); } }); return newKeys; }, _shouldRenderSceneKey:function _shouldRenderSceneKey(idx,currentPageKey){ var numOfSibling=this.props.prerenderingSiblingsNumber; return( idx<currentPageKey+numOfSibling+1&& idx>currentPageKey-numOfSibling-1); }, _keyExists:function _keyExists(sceneKeys,key){ return sceneKeys.find(function(sceneKey){return key===sceneKey;}); }, _makeSceneKey:function _makeSceneKey(child,idx){ return child.props.heading+"_"+idx; }, renderScrollableContent:function renderScrollableContent(){var _this3=this; var scenes=this._composeScenes(); return( React.createElement(ScrollView,_extends({ horizontal:true, pagingEnabled:true, automaticallyAdjustContentInsets:false, keyboardShouldPersistTaps:"handled", contentOffset:{ x:this.props.initialPage*this.state.containerWidth}, ref:function ref(scrollView){ _this3.scrollView=scrollView; }, onScroll:function onScroll(e){ var offsetX=e.nativeEvent.contentOffset.x; _this3._updateScrollValue(offsetX/_this3.state.containerWidth); }, onMomentumScrollBegin:this._onMomentumScrollBeginAndEnd, onMomentumScrollEnd:this._onMomentumScrollBeginAndEnd, scrollEventThrottle:16, scrollsToTop:false, showsHorizontalScrollIndicator:false, scrollEnabled:!this.props.locked, directionalLockEnabled:true, alwaysBounceVertical:false, keyboardDismissMode:"on-drag"}, this.props.contentProps,{__source:{fileName:_jsxFileName,lineNumber:170}}), scenes)); }, _composeScenes:function _composeScenes(){var _this4=this; return this._children().map(function(child,idx){ var key=_this4._makeSceneKey(child,idx); return( React.createElement(SceneComponent,{ key:child.key, shouldUpdated:_this4._shouldRenderSceneKey( idx, _this4.state.currentPage), style:{width:_this4.state.containerWidth},__source:{fileName:_jsxFileName,lineNumber:205}}, _this4._keyExists(_this4.state.sceneKeys,key)? child: React.createElement(View,{heading:child.props.heading,__source:{fileName:_jsxFileName,lineNumber:216}}))); }); }, _onMomentumScrollBeginAndEnd:function _onMomentumScrollBeginAndEnd(e){ var offsetX=e.nativeEvent.contentOffset.x; var page=Math.round(offsetX/this.state.containerWidth); if(this.state.currentPage!==page){ this._updateSelectedPage(page); } }, _updateSelectedPage:function _updateSelectedPage(nextPage){ var localNextPage=nextPage; if(typeof localNextPage==="object"){ localNextPage=nextPage.nativeEvent.position; } var currentPage=this.state.currentPage; this.updateSceneKeys({ page:localNextPage, callback:this._onChangeTab.bind(this,currentPage,localNextPage)}); }, _onChangeTab:function _onChangeTab(prevPage,currentPage){ this.props.onChangeTab({ i:currentPage, ref:this._children()[currentPage], from:prevPage}); }, _updateScrollValue:function _updateScrollValue(value){ this.state.scrollValue.setValue(value); this.props.onScroll(value); }, _handleLayout:function _handleLayout(e){var _this5=this;var width=e.nativeEvent.layout.width; if(Math.round(width)!==Math.round(this.state.containerWidth)){ this.setState({containerWidth:width}); this.requestAnimationFrame(function(){ _this5.goToPage(_this5.state.currentPage); }); } }, _children:function _children(){var children=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.props.children; return React.Children.map(children,function(child){return child;}); }, render:function render(){ var overlayTabs= this.props.tabBarPosition==="overlayTop"|| this.props.tabBarPosition==="overlayBottom"; var tabBarProps={ goToPage:this.goToPage, tabs:this._children().map(function(child){return child.props.heading;}), tabStyle:this._children().map(function(child){return child.props.tabStyle;}), activeTabStyle:this._children().map(function(child){return child.props.activeTabStyle;}), textStyle:this._children().map(function(child){return child.props.textStyle;}), activeTextStyle:this._children().map( function(child){return child.props.activeTextStyle;}), tabHeaderStyle:this._children().map(function(child){return( _lodash2.default.get(child.props.heading.props,"style",undefined));}), activeTab:this.state.currentPage, scrollValue:this.state.scrollValue, containerWidth:this.state.containerWidth}; if(this.props.tabBarBackgroundColor){ tabBarProps.backgroundColor=this.props.tabBarBackgroundColor; } if(this.props.tabBarActiveTextColor){ tabBarProps.activeTextColor=this.props.tabBarActiveTextColor; } if(this.props.tabBarInactiveTextColor){ tabBarProps.inactiveTextColor=this.props.tabBarInactiveTextColor; } if(this.props.tabBarTextStyle){ tabBarProps.textStyle=this.props.tabBarTextStyle; } if(this.props.tabBarUnderlineStyle){ tabBarProps.underlineStyle=this.props.tabBarUnderlineStyle; } if(this.props.tabContainerStyle){ tabBarProps.tabContainerStyle=this.props.tabContainerStyle; } if(overlayTabs){var _tabBarProps$style; tabBarProps.style=(_tabBarProps$style={ position:"absolute", left:0, right:0},_defineProperty(_tabBarProps$style, this.props.tabBarPosition==="overlayTop"?"top":"bottom",0),_defineProperty(_tabBarProps$style,"backgroundColor", "rgba(255, 255, 255, 0.7)"),_tabBarProps$style); } return( React.createElement(View,{ style:[styles.container,this.props.style], onLayout:this._handleLayout,__source:{fileName:_jsxFileName,lineNumber:322}}, (this.props.tabBarPosition==="top"|| this.props.tabBarPosition==="overlayTop")&& this.renderTabBar(tabBarProps), this.renderScrollableContent(), (this.props.tabBarPosition==="bottom"|| this.props.tabBarPosition==="overlayBottom")&& this.renderTabBar(tabBarProps))); }});exports.default= ScrollableTabView; var styles=StyleSheet.create({ container:{ flex:1}, scrollableContentAndroid:{ flex:1}}); </s> add 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 _jsxFileName="src/basic/Tabs/index.js";var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var React=require("react");var Component=React.Component;var ReactNative=require("react-native");var Dimensions=ReactNative.Dimensions,View=ReactNative.View,Animated=ReactNative.Animated,ScrollView=ReactNative.ScrollView,StyleSheet=ReactNative.StyleSheet,Platform=ReactNative.Platform;var TimerMixin=require("react-timer-mixin");var SceneComponent=require("./SceneComponent");var _require=require("./DefaultTabBar"),DefaultTabBar=_require.DefaultTabBar;var _require2=require("./ScrollableTabBar"),ScrollableTabBar=_require2.ScrollableTabBar;var ScrollableTabView=(0,_createReactClass2.default)({displayName:"ScrollableTabView",mixins:[TimerMixin],statics:{DefaultTabBar:DefaultTabBar,ScrollableTabBar:ScrollableTabBar},propTypes:{tabBarPosition:_propTypes2.default.oneOf(["top","bottom","overlayTop","overlayBottom"]),initialPage:_propTypes2.default.number,page:_propTypes2.default.number,onChangeTab:_propTypes2.default.func,onScroll:_propTypes2.default.func,renderTabBar:_propTypes2.default.any,style:_utils.ViewPropTypes.style,contentProps:_propTypes2.default.object,scrollWithoutAnimation:_propTypes2.default.bool,locked:_propTypes2.default.bool,prerenderingSiblingsNumber:_propTypes2.default.number},getDefaultProps:function getDefaultProps(){return{tabBarPosition:"top",initialPage:0,page:-1,onChangeTab:function onChangeTab(){},onScroll:function onScroll(){},contentProps:{},scrollWithoutAnimation:false,locked:false,prerenderingSiblingsNumber:0};},getInitialState:function getInitialState(){return{currentPage:this.props.initialPage,scrollValue:new Animated.Value(this.props.initialPage),containerWidth:Dimensions.get("window").width,sceneKeys:this.newSceneKeys({currentPage:this.props.initialPage})};},componentDidMount:function componentDidMount(){var _this=this;var scrollFn=function scrollFn(){if(_this.scrollView){_this.state.scrollValue.setValue(_this.props.initialPage);}};_utils.InteractionManager.runAfterInteractions(scrollFn);},componentWillReceiveProps:function componentWillReceiveProps(props){if(props.children!==this.props.children){this.updateSceneKeys({page:this.state.currentPage,children:props.children});}if(props.page>=0&&props.page!==this.state.currentPage){this.goToPage(props.page);}},goToPage:function goToPage(pageNumber){var offset=pageNumber*this.state.containerWidth;if(this.scrollView){this.scrollView.scrollTo({x:offset,y:0,animated:!this.props.scrollWithoutAnimation});}var currentPage=this.state.currentPage;this.updateSceneKeys({page:pageNumber,callback:this._onChangeTab.bind(this,currentPage,pageNumber)});},renderTabBar:function renderTabBar(props){if(this.props.renderTabBar===false){return null;}else if(this.props.renderTabBar){return React.cloneElement(this.props.renderTabBar(props),props);}else{return React.createElement(DefaultTabBar,_extends({},props,{__source:{fileName:_jsxFileName,lineNumber:116}}));}},updateSceneKeys:function updateSceneKeys(_ref){var page=_ref.page,_ref$children=_ref.children,children=_ref$children===undefined?this.props.children:_ref$children,_ref$callback=_ref.callback,callback=_ref$callback===undefined?function(){}:_ref$callback;var newKeys=this.newSceneKeys({previousKeys:this.state.sceneKeys,currentPage:page,children:children});this.setState({currentPage:page,sceneKeys:newKeys},callback);},newSceneKeys:function newSceneKeys(_ref2){var _this2=this;var _ref2$previousKeys=_ref2.previousKeys,previousKeys=_ref2$previousKeys===undefined?[]:_ref2$previousKeys,_ref2$currentPage=_ref2.currentPage,currentPage=_ref2$currentPage===undefined?0:_ref2$currentPage,_ref2$children=_ref2.children,children=_ref2$children===undefined?this.props.children:_ref2$children;var newKeys=[];this._children(children).forEach(function(child,idx){var key=_this2._makeSceneKey(child,idx);if(_this2._keyExists(previousKeys,key)||_this2._shouldRenderSceneKey(idx,currentPage)){newKeys.push(key);}});return newKeys;},_shouldRenderSceneKey:function _shouldRenderSceneKey(idx,currentPageKey){var numOfSibling=this.props.prerenderingSiblingsNumber;return idx<currentPageKey+numOfSibling+1&&idx>currentPageKey-numOfSibling-1;},_keyExists:function _keyExists(sceneKeys,key){return sceneKeys.find(function(sceneKey){return key===sceneKey;});},_makeSceneKey:function _makeSceneKey(child,idx){return child.props.heading+"_"+idx;},renderScrollableContent:function renderScrollableContent(){var _this3=this;var scenes=this._composeScenes();return React.createElement(ScrollView,_extends({horizontal:true,pagingEnabled:true,automaticallyAdjustContentInsets:false,keyboardShouldPersistTaps:"handled",contentOffset:{x:this.props.initialPage*this.state.containerWidth},ref:function ref(scrollView){_this3.scrollView=scrollView;},onScroll:function onScroll(e){var offsetX=e.nativeEvent.contentOffset.x;_this3._updateScrollValue(offsetX/_this3.state.containerWidth);},onMomentumScrollBegin:this._onMomentumScrollBeginAndEnd,onMomentumScrollEnd:this._onMomentumScrollBeginAndEnd,scrollEventThrottle:16,scrollsToTop:false,showsHorizontalScrollIndicator:false,scrollEnabled:!this.props.locked,directionalLockEnabled:true,alwaysBounceVertical:false,keyboardDismissMode:"on-drag"},this.props.contentProps,{__source:{fileName:_jsxFileName,lineNumber:170}}),scenes);},_composeScenes:function _composeScenes(){var _this4=this;return this._children().map(function(child,idx){var key=_this4._makeSceneKey(child,idx);return React.createElement(SceneComponent,{key:child.key,shouldUpdated:_this4._shouldRenderSceneKey(idx,_this4.state.currentPage),style:{width:_this4.state.containerWidth},__source:{fileName:_jsxFileName,lineNumber:205}},_this4._keyExists(_this4.state.sceneKeys,key)?child:React.createElement(View,{heading:child.props.heading,__source:{fileName:_jsxFileName,lineNumber:216}}));});},_onMomentumScrollBeginAndEnd:function _onMomentumScrollBeginAndEnd(e){var offsetX=e.nativeEvent.contentOffset.x;var page=Math.round(offsetX/this.state.containerWidth);if(this.state.currentPage!==page){this._updateSelectedPage(page);}},_updateSelectedPage:function _updateSelectedPage(nextPage){var localNextPage=nextPage;if(typeof localNextPage==="object"){localNextPage=nextPage.nativeEvent.position;}var currentPage=this.state.currentPage;this.updateSceneKeys({page:localNextPage,callback:this._onChangeTab.bind(this,currentPage,localNextPage)});},_onChangeTab:function _onChangeTab(prevPage,currentPage){this.props.onChangeTab({i:currentPage,ref:this._children()[currentPage],from:prevPage});},_updateScrollValue:function _updateScrollValue(value){this.state.scrollValue.setValue(value);this.props.onScroll(value);},_handleLayout:function _handleLayout(e){var _this5=this;var width=e.nativeEvent.layout.width;if(Math.round(width)!==Math.round(this.state.containerWidth)){this.setState({containerWidth:width});this.requestAnimationFrame(function(){_this5.goToPage(_this5.state.currentPage);});}},_children:function _children(){var children=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.props.children;return React.Children.map(children,function(child){return child;});},render:function render(){var overlayTabs=this.props.tabBarPosition==="overlayTop"||this.props.tabBarPosition==="overlayBottom";var tabBarProps={goToPage:this.goToPage,tabs:this._children().map(function(child){return child.props.heading;}),tabStyle:this._children().map(function(child){return child.props.tabStyle;}),activeTabStyle:this._children().map(function(child){return child.props.activeTabStyle;}),textStyle:this._children().map(function(child){return child.props.textStyle;}),activeTextStyle:this._children().map(function(child){return child.props.activeTextStyle;}),tabHeaderStyle:this._children().map(function(child){return _lodash2.default.get(child.props.heading.props,"style",undefined);}),activeTab:this.state.currentPage,scrollValue:this.state.scrollValue,containerWidth:this.state.containerWidth};if(this.props.tabBarBackgroundColor){tabBarProps.backgroundColor=this.props.tabBarBackgroundColor;}if(this.props.tabBarActiveTextColor){tabBarProps.activeTextColor=this.props.tabBarActiveTextColor;}if(this.props.tabBarInactiveTextColor){tabBarProps.inactiveTextColor=this.props.tabBarInactiveTextColor;}if(this.props.tabBarTextStyle){tabBarProps.textStyle=this.props.tabBarTextStyle;}if(this.props.tabBarUnderlineStyle){tabBarProps.underlineStyle=this.props.tabBarUnderlineStyle;}if(this.props.tabContainerStyle){tabBarProps.tabContainerStyle=this.props.tabContainerStyle;}if(overlayTabs){var _tabBarProps$style;tabBarProps.style=(_tabBarProps$style={position:"absolute",left:0,right:0},_defineProperty(_tabBarProps$style,this.props.tabBarPosition==="overlayTop"?"top":"bottom",0),_defineProperty(_tabBarProps$style,"backgroundColor","rgba(255, 255, 255, 0.7)"),_tabBarProps$style);}return React.createElement(View,{style:[styles.container,this.props.style],onLayout:this._handleLayout,__source:{fileName:_jsxFileName,lineNumber:322}},(this.props.tabBarPosition==="top"||this.props.tabBarPosition==="overlayTop")&&this.renderTabBar(tabBarProps),this.renderScrollableContent(),(this.props.tabBarPosition==="bottom"||this.props.tabBarPosition==="overlayBottom")&&this.renderTabBar(tabBarProps));}});exports.default=ScrollableTabView;var styles=StyleSheet.create({container:{flex:1},scrollableContentAndroid:{flex:1}}); </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollableTab=undefined;var _jsxFileName="src/basic/Tabs/ScrollableTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react); var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _index=require("./../../index"); var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var Button=require("./Button"); var ReactNative=require("react-native");var View= ReactNative.View,Animated=ReactNative.Animated,StyleSheet=ReactNative.StyleSheet,ScrollView=ReactNative.ScrollView,Platform=ReactNative.Platform,Dimensions=ReactNative.Dimensions; var WINDOW_WIDTH=Dimensions.get("window").width; var ScrollableTabBar=(0,_createReactClass2.default)({displayName:"ScrollableTabBar", propTypes:{ goToPage:_propTypes2.default.func, activeTab:_propTypes2.default.number, tabs:_propTypes2.default.array, backgroundColor:_propTypes2.default.string, activeTextColor:_propTypes2.default.string, inactiveTextColor:_propTypes2.default.string, scrollOffset:_propTypes2.default.number, style:_utils.ViewPropTypes.style, tabStyle:_utils.ViewPropTypes.style, tabsContainerStyle:_utils.ViewPropTypes.style, renderTab:_propTypes2.default.func, underlineStyle:_utils.ViewPropTypes.style, onScroll:_propTypes2.default.func}, contextTypes:{ theme:_propTypes2.default.object}, getDefaultProps:function getDefaultProps(){ return{ scrollOffset:52, activeTextColor:"navy", inactiveTextColor:"black", backgroundColor:_platform2.default.tabDefaultBg, style:{}, tabStyle:{}, tabsContainerStyle:{}, underlineStyle:{}, tabFontSize:_platform2.default.tabFontSize}; }, getInitialState:function getInitialState(){ this._tabsMeasurements=[]; return{ _leftTabUnderline:new Animated.Value(0), _widthTabUnderline:new Animated.Value(0), _containerWidth:null}; }, componentDidMount:function componentDidMount(){ this.props.scrollValue.addListener(this.updateView); }, updateView:function updateView(offset){ var position=Math.floor(offset.value); var pageOffset=offset.value%1; var tabCount=this.props.tabs.length; var lastTabPosition=tabCount-1; if(tabCount===0||offset.value<0||offset.value>lastTabPosition){ return; } if( this.necessarilyMeasurementsCompleted( position, position===lastTabPosition)) { this.updateTabPanel(position,pageOffset); this.updateTabUnderline(position,pageOffset,tabCount); } }, necessarilyMeasurementsCompleted:function necessarilyMeasurementsCompleted(position,isLastTab){ return( this._tabsMeasurements[position]&&( isLastTab||this._tabsMeasurements[position+1])&& this._tabContainerMeasurements&& this._containerMeasurements); }, updateTabPanel:function updateTabPanel(position,pageOffset){ var containerWidth=this._containerMeasurements.width; var tabWidth=this._tabsMeasurements[position].width; var nextTabMeasurements=this._tabsMeasurements[position+1]; var nextTabWidth= nextTabMeasurements&&nextTabMeasurements.width||0; var tabOffset=this._tabsMeasurements[position].left; var absolutePageOffset=pageOffset*tabWidth; var newScrollX=tabOffset+absolutePageOffset; newScrollX-= (containerWidth- (1-pageOffset)*tabWidth- pageOffset*nextTabWidth)/ 2; newScrollX=newScrollX>=0?newScrollX:0; if(Platform.OS==="android"){ this._scrollView.scrollTo({x:newScrollX,y:0,animated:false}); }else{ var rightBoundScroll= this._tabContainerMeasurements.width- this._containerMeasurements.width; newScrollX= newScrollX>rightBoundScroll?rightBoundScroll:newScrollX; this._scrollView.scrollTo({x:newScrollX,y:0,animated:false}); } }, updateTabUnderline:function updateTabUnderline(position,pageOffset,tabCount){ var lineLeft=this._tabsMeasurements[position].left; var lineRight=this._tabsMeasurements[position].right; if(position<tabCount-1){ var nextTabLeft=this._tabsMeasurements[position+1].left; var nextTabRight=this._tabsMeasurements[position+1].right; var newLineLeft= pageOffset*nextTabLeft+(1-pageOffset)*lineLeft; var newLineRight= pageOffset*nextTabRight+(1-pageOffset)*lineRight; this.state._leftTabUnderline.setValue(newLineLeft); this.state._widthTabUnderline.setValue(newLineRight-newLineLeft); }else{ this.state._leftTabUnderline.setValue(lineLeft); this.state._widthTabUnderline.setValue(lineRight-lineLeft); } }, renderTab:function renderTab( name, page, isTabActive, onPressHandler, onLayoutHandler, tabStyle, activeTabStyle, textStyle, activeTextStyle, tabHeaderStyle) { var headerContent= typeof name!=="string"?name.props.children:undefined;var _props= this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize; var textColor=isTabActive?activeTextColor:inactiveTextColor; var fontWeight=isTabActive?"bold":"normal"; var fontSize=tabFontSize; if(typeof name==="string"){ return( _react2.default.createElement(Button,{ key:name+"_"+page, onPress:function onPress(){return onPressHandler(page);}, onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:172}}, _react2.default.createElement(_index.TabHeading,{ scrollable:true, style:isTabActive?activeTabStyle:tabStyle, active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:177}}, _react2.default.createElement(_index.Text,{ style:[ isTabActive?activeTextStyle:textStyle, {fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:182}}, name)))); }else{ return( _react2.default.createElement(Button,{ key:_lodash2.default.random(1.2,5.2), onPress:function onPress(){return onPressHandler(page);}, onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:195}}, _react2.default.createElement(_index.TabHeading,{scrollable:true,style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:200}}, headerContent))); } }, measureTab:function measureTab(page,event){var _event$nativeEvent$la= event.nativeEvent.layout,x=_event$nativeEvent$la.x,width=_event$nativeEvent$la.width,height=_event$nativeEvent$la.height; this._tabsMeasurements[page]={left:x,right:x+width,width:width,height:height}; this.updateView({value:this.props.scrollValue._value}); }, render:function render(){var _this=this; var variables=this.context.theme? this.context.theme["@@shoutem.theme/themeStyle"].variables: _platform2.default; var tabUnderlineStyle={ position:"absolute", height:4, backgroundColor:variables.topTabBarActiveBorderColor, bottom:0}; var dynamicTabUnderline={ left:this.state._leftTabUnderline, width:this.state._widthTabUnderline}; return( _react2.default.createElement(View,{ style:[ styles.container, {backgroundColor:this.props.backgroundColor}, this.props.style], onLayout:this.onContainerLayout,__source:{fileName:_jsxFileName,lineNumber:231}}, _react2.default.createElement(ScrollView,{ automaticallyAdjustContentInsets:false, ref:function ref(scrollView){ _this._scrollView=scrollView; }, horizontal:true, showsHorizontalScrollIndicator:false, showsVerticalScrollIndicator:false, directionalLockEnabled:true, onScroll:this.props.onScroll, bounces:false, scrollsToTop:false,__source:{fileName:_jsxFileName,lineNumber:239}}, _react2.default.createElement(View,{ style:[ styles.tabs, {width:this.state._containerWidth}, this.props.tabsContainerStyle], ref:"tabContainer", onLayout:this.onTabContainerLayout,__source:{fileName:_jsxFileName,lineNumber:252}}, this.props.tabs.map(function(name,page){ var isTabActive=_this.props.activeTab===page; var renderTab=_this.props.renderTab||_this.renderTab; return renderTab( name, page, isTabActive, _this.props.goToPage, _this.measureTab.bind(_this,page), _this.props.tabStyle[page], _this.props.activeTabStyle[page], _this.props.textStyle[page], _this.props.activeTextStyle[page], _this.props.tabHeaderStyle[page]); }), _react2.default.createElement(Animated.View,{ style:[ tabUnderlineStyle, dynamicTabUnderline, this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:277}}))))); }, componentWillReceiveProps:function componentWillReceiveProps(nextProps){ if( !_lodash2.default.isEqual(this.props.tabs,nextProps.tabs)&& this.state._containerWidth) { this.setState({_containerWidth:null}); } }, onTabContainerLayout:function onTabContainerLayout(e){ this._tabContainerMeasurements=e.nativeEvent.layout; var width=this._tabContainerMeasurements.width; if(width<WINDOW_WIDTH){ width=WINDOW_WIDTH; } this.setState({_containerWidth:width}); this.updateView({value:this.props.scrollValue._value}); }, onContainerLayout:function onContainerLayout(e){ this._containerMeasurements=e.nativeEvent.layout; this.updateView({value:this.props.scrollValue._value}); }}); var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)( "NativeBase.ScrollableTab", {}, _mapPropsToStyleNames2.default)( ScrollableTabBar);exports. ScrollableTab=StyledTab; var styles=StyleSheet.create({ tab:{ height:49, alignItems:"center", justifyContent:"center", paddingLeft:20, paddingRight:20}, container:{ height:50, borderWidth:1, borderTopWidth:0, borderLeftWidth:0, borderRightWidth:0, borderColor:"#ccc"}, tabs:{ flexDirection:"row", justifyContent:"space-around"}}); </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollableTab=undefined;var _jsxFileName="src/basic/Tabs/ScrollableTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _index=require("./../../index");var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var Button=require("./Button");var ReactNative=require("react-native");var View=ReactNative.View,Animated=ReactNative.Animated,StyleSheet=ReactNative.StyleSheet,ScrollView=ReactNative.ScrollView,Platform=ReactNative.Platform,Dimensions=ReactNative.Dimensions;var WINDOW_WIDTH=Dimensions.get("window").width;var ScrollableTabBar=(0,_createReactClass2.default)({displayName:"ScrollableTabBar",propTypes:{goToPage:_propTypes2.default.func,activeTab:_propTypes2.default.number,tabs:_propTypes2.default.array,backgroundColor:_propTypes2.default.string,activeTextColor:_propTypes2.default.string,inactiveTextColor:_propTypes2.default.string,scrollOffset:_propTypes2.default.number,style:_utils.ViewPropTypes.style,tabStyle:_utils.ViewPropTypes.style,tabsContainerStyle:_utils.ViewPropTypes.style,renderTab:_propTypes2.default.func,underlineStyle:_utils.ViewPropTypes.style,onScroll:_propTypes2.default.func},contextTypes:{theme:_propTypes2.default.object},getDefaultProps:function getDefaultProps(){return{scrollOffset:52,activeTextColor:"navy",inactiveTextColor:"black",backgroundColor:_platform2.default.tabDefaultBg,style:{},tabStyle:{},tabsContainerStyle:{},underlineStyle:{},tabFontSize:_platform2.default.tabFontSize};},getInitialState:function getInitialState(){this._tabsMeasurements=[];return{_leftTabUnderline:new Animated.Value(0),_widthTabUnderline:new Animated.Value(0),_containerWidth:null};},componentDidMount:function componentDidMount(){this.props.scrollValue.addListener(this.updateView);},updateView:function updateView(offset){var position=Math.floor(offset.value);var pageOffset=offset.value%1;var tabCount=this.props.tabs.length;var lastTabPosition=tabCount-1;if(tabCount===0||offset.value<0||offset.value>lastTabPosition){return;}if(this.necessarilyMeasurementsCompleted(position,position===lastTabPosition)){this.updateTabPanel(position,pageOffset);this.updateTabUnderline(position,pageOffset,tabCount);}},necessarilyMeasurementsCompleted:function necessarilyMeasurementsCompleted(position,isLastTab){return this._tabsMeasurements[position]&&(isLastTab||this._tabsMeasurements[position+1])&&this._tabContainerMeasurements&&this._containerMeasurements;},updateTabPanel:function updateTabPanel(position,pageOffset){var containerWidth=this._containerMeasurements.width;var tabWidth=this._tabsMeasurements[position].width;var nextTabMeasurements=this._tabsMeasurements[position+1];var nextTabWidth=nextTabMeasurements&&nextTabMeasurements.width||0;var tabOffset=this._tabsMeasurements[position].left;var absolutePageOffset=pageOffset*tabWidth;var newScrollX=tabOffset+absolutePageOffset;newScrollX-=(containerWidth-(1-pageOffset)*tabWidth-pageOffset*nextTabWidth)/2;newScrollX=newScrollX>=0?newScrollX:0;if(Platform.OS==="android"){this._scrollView.scrollTo({x:newScrollX,y:0,animated:false});}else{var rightBoundScroll=this._tabContainerMeasurements.width-this._containerMeasurements.width;newScrollX=newScrollX>rightBoundScroll?rightBoundScroll:newScrollX;this._scrollView.scrollTo({x:newScrollX,y:0,animated:false});}},updateTabUnderline:function updateTabUnderline(position,pageOffset,tabCount){var lineLeft=this._tabsMeasurements[position].left;var lineRight=this._tabsMeasurements[position].right;if(position<tabCount-1){var nextTabLeft=this._tabsMeasurements[position+1].left;var nextTabRight=this._tabsMeasurements[position+1].right;var newLineLeft=pageOffset*nextTabLeft+(1-pageOffset)*lineLeft;var newLineRight=pageOffset*nextTabRight+(1-pageOffset)*lineRight;this.state._leftTabUnderline.setValue(newLineLeft);this.state._widthTabUnderline.setValue(newLineRight-newLineLeft);}else{this.state._leftTabUnderline.setValue(lineLeft);this.state._widthTabUnderline.setValue(lineRight-lineLeft);}},renderTab:function renderTab(name,page,isTabActive,onPressHandler,onLayoutHandler,tabStyle,activeTabStyle,textStyle,activeTextStyle,tabHeaderStyle){var headerContent=typeof name!=="string"?name.props.children:undefined;var _props=this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize;var textColor=isTabActive?activeTextColor:inactiveTextColor;var fontWeight=isTabActive?"bold":"normal";var fontSize=tabFontSize;if(typeof name==="string"){return _react2.default.createElement(Button,{key:name+"_"+page,onPress:function onPress(){return onPressHandler(page);},onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:172}},_react2.default.createElement(_index.TabHeading,{scrollable:true,style:isTabActive?activeTabStyle:tabStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:177}},_react2.default.createElement(_index.Text,{style:[isTabActive?activeTextStyle:textStyle,{fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:182}},name)));}else{return _react2.default.createElement(Button,{key:_lodash2.default.random(1.2,5.2),onPress:function onPress(){return onPressHandler(page);},onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:195}},_react2.default.createElement(_index.TabHeading,{scrollable:true,style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:200}},headerContent));}},measureTab:function measureTab(page,event){var _event$nativeEvent$la=event.nativeEvent.layout,x=_event$nativeEvent$la.x,width=_event$nativeEvent$la.width,height=_event$nativeEvent$la.height;this._tabsMeasurements[page]={left:x,right:x+width,width:width,height:height};this.updateView({value:this.props.scrollValue._value});},render:function render(){var _this=this;var variables=this.context.theme?this.context.theme["@@shoutem.theme/themeStyle"].variables:_platform2.default;var tabUnderlineStyle={position:"absolute",height:4,backgroundColor:variables.topTabBarActiveBorderColor,bottom:0};var dynamicTabUnderline={left:this.state._leftTabUnderline,width:this.state._widthTabUnderline};return _react2.default.createElement(View,{style:[styles.container,{backgroundColor:this.props.backgroundColor},this.props.style],onLayout:this.onContainerLayout,__source:{fileName:_jsxFileName,lineNumber:231}},_react2.default.createElement(ScrollView,{automaticallyAdjustContentInsets:false,ref:function ref(scrollView){_this._scrollView=scrollView;},horizontal:true,showsHorizontalScrollIndicator:false,showsVerticalScrollIndicator:false,directionalLockEnabled:true,onScroll:this.props.onScroll,bounces:false,scrollsToTop:false,__source:{fileName:_jsxFileName,lineNumber:239}},_react2.default.createElement(View,{style:[styles.tabs,{width:this.state._containerWidth},this.props.tabsContainerStyle],ref:"tabContainer",onLayout:this.onTabContainerLayout,__source:{fileName:_jsxFileName,lineNumber:252}},this.props.tabs.map(function(name,page){var isTabActive=_this.props.activeTab===page;var renderTab=_this.props.renderTab||_this.renderTab;return renderTab(name,page,isTabActive,_this.props.goToPage,_this.measureTab.bind(_this,page),_this.props.tabStyle[page],_this.props.activeTabStyle[page],_this.props.textStyle[page],_this.props.activeTextStyle[page],_this.props.tabHeaderStyle[page]);}),_react2.default.createElement(Animated.View,{style:[tabUnderlineStyle,dynamicTabUnderline,this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:277}}))));},componentWillReceiveProps:function componentWillReceiveProps(nextProps){if(!_lodash2.default.isEqual(this.props.tabs,nextProps.tabs)&&this.state._containerWidth){this.setState({_containerWidth:null});}},onTabContainerLayout:function onTabContainerLayout(e){this._tabContainerMeasurements=e.nativeEvent.layout;var width=this._tabContainerMeasurements.width;if(width<WINDOW_WIDTH){width=WINDOW_WIDTH;}this.setState({_containerWidth:width});this.updateView({value:this.props.scrollValue._value});},onContainerLayout:function onContainerLayout(e){this._containerMeasurements=e.nativeEvent.layout;this.updateView({value:this.props.scrollValue._value});}});var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.ScrollableTab",{},_mapPropsToStyleNames2.default)(ScrollableTabBar);exports.ScrollableTab=StyledTab;var styles=StyleSheet.create({tab:{height:49,alignItems:"center",justifyContent:"center",paddingLeft:20,paddingRight:20},container:{height:50,borderWidth:1,borderTopWidth:0,borderLeftWidth:0,borderRightWidth:0,borderColor:"#ccc"},tabs:{flexDirection:"row",justifyContent:"space-around"}}); </s> remove "react": ">=16.0.0-alpha.12", "react-native": ">=0.46.0" </s> add "react": ">=16.4.1", "react-native": ">=0.56.0"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f6b810f5f0d9b1a4cfabaccbcf733cafc7edff42
package.json
"babel-jest": "23.2.0", "babel-preset-react-native": "4.0.0",
<mask> }, <mask> "devDependencies": { <mask> "babel-cli": "^6.18.0", <mask> "babel-eslint": "^7.2.3", <mask> "babel-jest": "^16.0.0", <mask> "babel-preset-react-native": "^1.9.2", <mask> "eslint": "^3.5.0", <mask> "eslint-config-airbnb": "^11.1.0", <mask> "eslint-plugin-import": "^1.14.0", <mask> "eslint-plugin-jsx-a11y": "^2.2.1", <mask> "eslint-plugin-react": "^6.2.0", </s> Upgraded deps and dev-deps, compatible with RN 0.56.0 </s> remove "jest": "19.0.2", "react": "^16.0.0-alpha.12", "react-native": "^0.46.0", "react-native-vector-icons": "~4.5.0", "react-test-renderer": "^16.0.0-alpha.12" </s> add "jest": "23.3.0", "react": "16.4.1", "react-native": "0.56.0", "react-native-vector-icons": "4.6.0", "react-test-renderer": "16.4.1" </s> remove Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color); var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var deviceHeight=_reactNative.Dimensions.get("window").height; var deviceWidth=_reactNative.Dimensions.get("window").width; var platform=_reactNative.Platform.OS; var platformStyle=undefined; var isIphoneX= platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default= { platformStyle:platformStyle, platform:platform, headerStyle:"#edebed", iconStyle:"#000", contentStyle:"#f5f4f5", expandedIconStyle:"#000", accordionBorderColor:"#d3d3d3", androidRipple:true, androidRippleColor:"rgba(256, 256, 256, 0.3)", androidRippleColorDark:"rgba(0, 0, 0, 0.15)", btnUppercaseAndroidText:true, badgeBg:"#ED1727", badgeColor:"#fff", badgePadding:platform==="ios"?3:0, btnFontFamily:platform==="ios"?"System":"Roboto_medium", btnDisabledBg:"#b5b5b5", buttonPadding:6, get btnPrimaryBg(){ return this.brandPrimary; }, get btnPrimaryColor(){ return this.inverseTextColor; }, get btnInfoBg(){ return this.brandInfo; }, get btnInfoColor(){ return this.inverseTextColor; }, get btnSuccessBg(){ return this.brandSuccess; }, get btnSuccessColor(){ return this.inverseTextColor; }, get btnDangerBg(){ return this.brandDanger; }, get btnDangerColor(){ return this.inverseTextColor; }, get btnWarningBg(){ return this.brandWarning; }, get btnWarningColor(){ return this.inverseTextColor; }, get btnTextSize(){ return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1; }, get btnTextSizeLarge(){ return this.fontSizeBase*1.5; }, get btnTextSizeSmall(){ return this.fontSizeBase*0.8; }, get borderRadiusLarge(){ return this.fontSizeBase*3.8; }, get iconSizeLarge(){ return this.iconFontSize*1.5; }, get iconSizeSmall(){ return this.iconFontSize*0.6; }, cardDefaultBg:"#fff", cardBorderColor:"#ccc", cardBorderRadius:2, cardItemPadding:platform==="ios"?10:12, CheckboxRadius:platform==="ios"?13:0, CheckboxBorderWidth:platform==="ios"?1:2, CheckboxPaddingLeft:platform==="ios"?4:2, CheckboxPaddingBottom:platform==="ios"?0:5, CheckboxIconSize:platform==="ios"?21:16, CheckboxIconMarginTop:platform==="ios"?undefined:1, CheckboxFontSize:platform==="ios"?23/0.9:17, checkboxBgColor:"#039BE5", checkboxSize:20, checkboxTickColor:"#fff", brandPrimary:platform==="ios"?"#007aff":"#3F51B5", brandInfo:"#62B1F6", brandSuccess:"#5cb85c", brandDanger:"#d9534f", brandWarning:"#f0ad4e", brandDark:"#000", brandLight:"#f4f4f4", datePickerTextColor:"#000", datePickerBg:"transparent", DefaultFontSize:16, fontFamily:platform==="ios"?"System":"Roboto", fontSizeBase:15, get fontSizeH1(){ return this.fontSizeBase*1.8; }, get fontSizeH2(){ return this.fontSizeBase*1.6; }, get fontSizeH3(){ return this.fontSizeBase*1.4; }, footerHeight:55, footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", footerPaddingBottom:0, tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", tabBarTextSize:platform==="ios"?14:11, activeTab:platform==="ios"?"#007aff":"#fff", sTabBarActiveTextColor:"#007aff", tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5", toolbarBtnColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", toolbarHeight:platform==="ios"?64:56, toolbarSearchIconSize:platform==="ios"?20:23, toolbarInputColor:platform==="ios"?"#CECDD2":"#fff", searchBarHeight:platform==="ios"?30:40, searchBarInputHeight:platform==="ios"?30:50, toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5", iosStatusbar:platform==="ios"?"dark-content":"light-content", get statusBarColor(){ return(0,_color2.default)(this.toolbarDefaultBg). darken(0.2). hex(); }, get darkenHeader(){ return(0,_color2.default)(this.tabBgColor). darken(0.03). hex(); }, iconFamily:"Ionicons", iconFontSize:platform==="ios"?30:28, iconHeaderSize:platform==="ios"?33:24, inputFontSize:17, inputBorderColor:"#D9D5DC", inputSuccessBorderColor:"#2b8339", inputErrorBorderColor:"#ed2f2f", inputHeightBase:50, get inputColor(){ return this.textColor; }, get inputColorPlaceholder(){ return"#575757"; }, btnLineHeight:19, lineHeightH1:32, lineHeightH2:27, lineHeightH3:22, lineHeight:platform==="ios"?20:24, listItemSelected:platform==="ios"?"#007aff":"#3F51B5", listBg:"transparent", listBorderColor:"#c9c9c9", listDividerBg:"#f4f4f4", listBtnUnderlayColor:"#DDD", listItemPadding:platform==="ios"?10:12, listNoteColor:"#808080", listNoteSize:13, defaultProgressColor:"#E4202D", inverseProgressColor:"#1A191B", radioBtnSize:platform==="ios"?25:23, radioSelectedColorAndroid:"#3F51B5", radioBtnLineHeight:platform==="ios"?29:24, get radioColor(){ return this.brandPrimary; }, segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5", segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff", segmentTextColor:platform==="ios"?"#007aff":"#fff", segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5", segmentBorderColor:platform==="ios"?"#007aff":"#fff", segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5", defaultSpinnerColor:"#45D56E", inverseSpinnerColor:"#1A191B", tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff", topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff", tabBgColor:"#F8F8F8", tabFontSize:15, textColor:"#000", inverseTextColor:"#fff", noteFontSize:14, get defaultTextColor(){ return this.textColor; }, titleFontfamily:platform==="ios"?"System":"Roboto_medium", titleFontSize:platform==="ios"?17:19, subTitleFontSize:platform==="ios"?11:14, subtitleColor:platform==="ios"?"#8e8e93":"#FFF", titleFontColor:platform==="ios"?"#000":"#FFF", borderRadiusBase:platform==="ios"?5:2, borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1), contentPadding:10, dropdownLinkColor:"#414142", inputLineHeight:24, deviceWidth:deviceWidth, deviceHeight:deviceHeight, isIphoneX:isIphoneX, inputGroupRoundedBorderRadius:30, Inset:{ portrait:{ topInset:24, leftInset:0, rightInset:0, bottomInset:34}, landscape:{ topInset:0, leftInset:44, rightInset:44, bottomInset:21}}}; </s> add Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color);var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var deviceHeight=_reactNative.Dimensions.get("window").height;var deviceWidth=_reactNative.Dimensions.get("window").width;var platform=_reactNative.Platform.OS;var platformStyle=undefined;var isIphoneX=platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default={platformStyle:platformStyle,platform:platform,headerStyle:"#edebed",iconStyle:"#000",contentStyle:"#f5f4f5",expandedIconStyle:"#000",accordionBorderColor:"#d3d3d3",androidRipple:true,androidRippleColor:"rgba(256, 256, 256, 0.3)",androidRippleColorDark:"rgba(0, 0, 0, 0.15)",btnUppercaseAndroidText:true,badgeBg:"#ED1727",badgeColor:"#fff",badgePadding:platform==="ios"?3:0,btnFontFamily:platform==="ios"?"System":"Roboto_medium",btnDisabledBg:"#b5b5b5",buttonPadding:6,get btnPrimaryBg(){return this.brandPrimary;},get btnPrimaryColor(){return this.inverseTextColor;},get btnInfoBg(){return this.brandInfo;},get btnInfoColor(){return this.inverseTextColor;},get btnSuccessBg(){return this.brandSuccess;},get btnSuccessColor(){return this.inverseTextColor;},get btnDangerBg(){return this.brandDanger;},get btnDangerColor(){return this.inverseTextColor;},get btnWarningBg(){return this.brandWarning;},get btnWarningColor(){return this.inverseTextColor;},get btnTextSize(){return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1;},get btnTextSizeLarge(){return this.fontSizeBase*1.5;},get btnTextSizeSmall(){return this.fontSizeBase*0.8;},get borderRadiusLarge(){return this.fontSizeBase*3.8;},get iconSizeLarge(){return this.iconFontSize*1.5;},get iconSizeSmall(){return this.iconFontSize*0.6;},cardDefaultBg:"#fff",cardBorderColor:"#ccc",cardBorderRadius:2,cardItemPadding:platform==="ios"?10:12,CheckboxRadius:platform==="ios"?13:0,CheckboxBorderWidth:platform==="ios"?1:2,CheckboxPaddingLeft:platform==="ios"?4:2,CheckboxPaddingBottom:platform==="ios"?0:5,CheckboxIconSize:platform==="ios"?21:16,CheckboxIconMarginTop:platform==="ios"?undefined:1,CheckboxFontSize:platform==="ios"?23/0.9:17,checkboxBgColor:"#039BE5",checkboxSize:20,checkboxTickColor:"#fff",brandPrimary:platform==="ios"?"#007aff":"#3F51B5",brandInfo:"#62B1F6",brandSuccess:"#5cb85c",brandDanger:"#d9534f",brandWarning:"#f0ad4e",brandDark:"#000",brandLight:"#f4f4f4",datePickerTextColor:"#000",datePickerBg:"transparent",DefaultFontSize:16,fontFamily:platform==="ios"?"System":"Roboto",fontSizeBase:15,get fontSizeH1(){return this.fontSizeBase*1.8;},get fontSizeH2(){return this.fontSizeBase*1.6;},get fontSizeH3(){return this.fontSizeBase*1.4;},footerHeight:55,footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",footerPaddingBottom:0,tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",tabBarTextSize:platform==="ios"?14:11,activeTab:platform==="ios"?"#007aff":"#fff",sTabBarActiveTextColor:"#007aff",tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5",toolbarBtnColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",toolbarHeight:platform==="ios"?64:56,toolbarSearchIconSize:platform==="ios"?20:23,toolbarInputColor:platform==="ios"?"#CECDD2":"#fff",searchBarHeight:platform==="ios"?30:40,searchBarInputHeight:platform==="ios"?30:50,toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5",iosStatusbar:platform==="ios"?"dark-content":"light-content",get statusBarColor(){return(0,_color2.default)(this.toolbarDefaultBg).darken(0.2).hex();},get darkenHeader(){return(0,_color2.default)(this.tabBgColor).darken(0.03).hex();},iconFamily:"Ionicons",iconFontSize:platform==="ios"?30:28,iconHeaderSize:platform==="ios"?33:24,inputFontSize:17,inputBorderColor:"#D9D5DC",inputSuccessBorderColor:"#2b8339",inputErrorBorderColor:"#ed2f2f",inputHeightBase:50,get inputColor(){return this.textColor;},get inputColorPlaceholder(){return"#575757";},btnLineHeight:19,lineHeightH1:32,lineHeightH2:27,lineHeightH3:22,lineHeight:platform==="ios"?20:24,listItemSelected:platform==="ios"?"#007aff":"#3F51B5",listBg:"transparent",listBorderColor:"#c9c9c9",listDividerBg:"#f4f4f4",listBtnUnderlayColor:"#DDD",listItemPadding:platform==="ios"?10:12,listNoteColor:"#808080",listNoteSize:13,defaultProgressColor:"#E4202D",inverseProgressColor:"#1A191B",radioBtnSize:platform==="ios"?25:23,radioSelectedColorAndroid:"#3F51B5",radioBtnLineHeight:platform==="ios"?29:24,get radioColor(){return this.brandPrimary;},segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5",segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff",segmentTextColor:platform==="ios"?"#007aff":"#fff",segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5",segmentBorderColor:platform==="ios"?"#007aff":"#fff",segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5",defaultSpinnerColor:"#45D56E",inverseSpinnerColor:"#1A191B",tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff",topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff",tabBgColor:"#F8F8F8",tabFontSize:15,textColor:"#000",inverseTextColor:"#fff",noteFontSize:14,get defaultTextColor(){return this.textColor;},titleFontfamily:platform==="ios"?"System":"Roboto_medium",titleFontSize:platform==="ios"?17:19,subTitleFontSize:platform==="ios"?11:14,subtitleColor:platform==="ios"?"#8e8e93":"#FFF",titleFontColor:platform==="ios"?"#000":"#FFF",borderRadiusBase:platform==="ios"?5:2,borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1),contentPadding:10,dropdownLinkColor:"#414142",inputLineHeight:24,deviceWidth:deviceWidth,deviceHeight:deviceHeight,isIphoneX:isIphoneX,inputGroupRoundedBorderRadius:30,Inset:{portrait:{topInset:24,leftInset:0,rightInset:0,bottomInset:34},landscape:{topInset:0,leftInset:44,rightInset:44,bottomInset:21}}}; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollableTab=undefined;var _jsxFileName="src/basic/Tabs/ScrollableTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react); var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _index=require("./../../index"); var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var Button=require("./Button"); var ReactNative=require("react-native");var View= ReactNative.View,Animated=ReactNative.Animated,StyleSheet=ReactNative.StyleSheet,ScrollView=ReactNative.ScrollView,Platform=ReactNative.Platform,Dimensions=ReactNative.Dimensions; var WINDOW_WIDTH=Dimensions.get("window").width; var ScrollableTabBar=(0,_createReactClass2.default)({displayName:"ScrollableTabBar", propTypes:{ goToPage:_propTypes2.default.func, activeTab:_propTypes2.default.number, tabs:_propTypes2.default.array, backgroundColor:_propTypes2.default.string, activeTextColor:_propTypes2.default.string, inactiveTextColor:_propTypes2.default.string, scrollOffset:_propTypes2.default.number, style:_utils.ViewPropTypes.style, tabStyle:_utils.ViewPropTypes.style, tabsContainerStyle:_utils.ViewPropTypes.style, renderTab:_propTypes2.default.func, underlineStyle:_utils.ViewPropTypes.style, onScroll:_propTypes2.default.func}, contextTypes:{ theme:_propTypes2.default.object}, getDefaultProps:function getDefaultProps(){ return{ scrollOffset:52, activeTextColor:"navy", inactiveTextColor:"black", backgroundColor:_platform2.default.tabDefaultBg, style:{}, tabStyle:{}, tabsContainerStyle:{}, underlineStyle:{}, tabFontSize:_platform2.default.tabFontSize}; }, getInitialState:function getInitialState(){ this._tabsMeasurements=[]; return{ _leftTabUnderline:new Animated.Value(0), _widthTabUnderline:new Animated.Value(0), _containerWidth:null}; }, componentDidMount:function componentDidMount(){ this.props.scrollValue.addListener(this.updateView); }, updateView:function updateView(offset){ var position=Math.floor(offset.value); var pageOffset=offset.value%1; var tabCount=this.props.tabs.length; var lastTabPosition=tabCount-1; if(tabCount===0||offset.value<0||offset.value>lastTabPosition){ return; } if( this.necessarilyMeasurementsCompleted( position, position===lastTabPosition)) { this.updateTabPanel(position,pageOffset); this.updateTabUnderline(position,pageOffset,tabCount); } }, necessarilyMeasurementsCompleted:function necessarilyMeasurementsCompleted(position,isLastTab){ return( this._tabsMeasurements[position]&&( isLastTab||this._tabsMeasurements[position+1])&& this._tabContainerMeasurements&& this._containerMeasurements); }, updateTabPanel:function updateTabPanel(position,pageOffset){ var containerWidth=this._containerMeasurements.width; var tabWidth=this._tabsMeasurements[position].width; var nextTabMeasurements=this._tabsMeasurements[position+1]; var nextTabWidth= nextTabMeasurements&&nextTabMeasurements.width||0; var tabOffset=this._tabsMeasurements[position].left; var absolutePageOffset=pageOffset*tabWidth; var newScrollX=tabOffset+absolutePageOffset; newScrollX-= (containerWidth- (1-pageOffset)*tabWidth- pageOffset*nextTabWidth)/ 2; newScrollX=newScrollX>=0?newScrollX:0; if(Platform.OS==="android"){ this._scrollView.scrollTo({x:newScrollX,y:0,animated:false}); }else{ var rightBoundScroll= this._tabContainerMeasurements.width- this._containerMeasurements.width; newScrollX= newScrollX>rightBoundScroll?rightBoundScroll:newScrollX; this._scrollView.scrollTo({x:newScrollX,y:0,animated:false}); } }, updateTabUnderline:function updateTabUnderline(position,pageOffset,tabCount){ var lineLeft=this._tabsMeasurements[position].left; var lineRight=this._tabsMeasurements[position].right; if(position<tabCount-1){ var nextTabLeft=this._tabsMeasurements[position+1].left; var nextTabRight=this._tabsMeasurements[position+1].right; var newLineLeft= pageOffset*nextTabLeft+(1-pageOffset)*lineLeft; var newLineRight= pageOffset*nextTabRight+(1-pageOffset)*lineRight; this.state._leftTabUnderline.setValue(newLineLeft); this.state._widthTabUnderline.setValue(newLineRight-newLineLeft); }else{ this.state._leftTabUnderline.setValue(lineLeft); this.state._widthTabUnderline.setValue(lineRight-lineLeft); } }, renderTab:function renderTab( name, page, isTabActive, onPressHandler, onLayoutHandler, tabStyle, activeTabStyle, textStyle, activeTextStyle, tabHeaderStyle) { var headerContent= typeof name!=="string"?name.props.children:undefined;var _props= this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize; var textColor=isTabActive?activeTextColor:inactiveTextColor; var fontWeight=isTabActive?"bold":"normal"; var fontSize=tabFontSize; if(typeof name==="string"){ return( _react2.default.createElement(Button,{ key:name+"_"+page, onPress:function onPress(){return onPressHandler(page);}, onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:172}}, _react2.default.createElement(_index.TabHeading,{ scrollable:true, style:isTabActive?activeTabStyle:tabStyle, active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:177}}, _react2.default.createElement(_index.Text,{ style:[ isTabActive?activeTextStyle:textStyle, {fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:182}}, name)))); }else{ return( _react2.default.createElement(Button,{ key:_lodash2.default.random(1.2,5.2), onPress:function onPress(){return onPressHandler(page);}, onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:195}}, _react2.default.createElement(_index.TabHeading,{scrollable:true,style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:200}}, headerContent))); } }, measureTab:function measureTab(page,event){var _event$nativeEvent$la= event.nativeEvent.layout,x=_event$nativeEvent$la.x,width=_event$nativeEvent$la.width,height=_event$nativeEvent$la.height; this._tabsMeasurements[page]={left:x,right:x+width,width:width,height:height}; this.updateView({value:this.props.scrollValue._value}); }, render:function render(){var _this=this; var variables=this.context.theme? this.context.theme["@@shoutem.theme/themeStyle"].variables: _platform2.default; var tabUnderlineStyle={ position:"absolute", height:4, backgroundColor:variables.topTabBarActiveBorderColor, bottom:0}; var dynamicTabUnderline={ left:this.state._leftTabUnderline, width:this.state._widthTabUnderline}; return( _react2.default.createElement(View,{ style:[ styles.container, {backgroundColor:this.props.backgroundColor}, this.props.style], onLayout:this.onContainerLayout,__source:{fileName:_jsxFileName,lineNumber:231}}, _react2.default.createElement(ScrollView,{ automaticallyAdjustContentInsets:false, ref:function ref(scrollView){ _this._scrollView=scrollView; }, horizontal:true, showsHorizontalScrollIndicator:false, showsVerticalScrollIndicator:false, directionalLockEnabled:true, onScroll:this.props.onScroll, bounces:false, scrollsToTop:false,__source:{fileName:_jsxFileName,lineNumber:239}}, _react2.default.createElement(View,{ style:[ styles.tabs, {width:this.state._containerWidth}, this.props.tabsContainerStyle], ref:"tabContainer", onLayout:this.onTabContainerLayout,__source:{fileName:_jsxFileName,lineNumber:252}}, this.props.tabs.map(function(name,page){ var isTabActive=_this.props.activeTab===page; var renderTab=_this.props.renderTab||_this.renderTab; return renderTab( name, page, isTabActive, _this.props.goToPage, _this.measureTab.bind(_this,page), _this.props.tabStyle[page], _this.props.activeTabStyle[page], _this.props.textStyle[page], _this.props.activeTextStyle[page], _this.props.tabHeaderStyle[page]); }), _react2.default.createElement(Animated.View,{ style:[ tabUnderlineStyle, dynamicTabUnderline, this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:277}}))))); }, componentWillReceiveProps:function componentWillReceiveProps(nextProps){ if( !_lodash2.default.isEqual(this.props.tabs,nextProps.tabs)&& this.state._containerWidth) { this.setState({_containerWidth:null}); } }, onTabContainerLayout:function onTabContainerLayout(e){ this._tabContainerMeasurements=e.nativeEvent.layout; var width=this._tabContainerMeasurements.width; if(width<WINDOW_WIDTH){ width=WINDOW_WIDTH; } this.setState({_containerWidth:width}); this.updateView({value:this.props.scrollValue._value}); }, onContainerLayout:function onContainerLayout(e){ this._containerMeasurements=e.nativeEvent.layout; this.updateView({value:this.props.scrollValue._value}); }}); var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)( "NativeBase.ScrollableTab", {}, _mapPropsToStyleNames2.default)( ScrollableTabBar);exports. ScrollableTab=StyledTab; var styles=StyleSheet.create({ tab:{ height:49, alignItems:"center", justifyContent:"center", paddingLeft:20, paddingRight:20}, container:{ height:50, borderWidth:1, borderTopWidth:0, borderLeftWidth:0, borderRightWidth:0, borderColor:"#ccc"}, tabs:{ flexDirection:"row", justifyContent:"space-around"}}); </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollableTab=undefined;var _jsxFileName="src/basic/Tabs/ScrollableTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _index=require("./../../index");var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var Button=require("./Button");var ReactNative=require("react-native");var View=ReactNative.View,Animated=ReactNative.Animated,StyleSheet=ReactNative.StyleSheet,ScrollView=ReactNative.ScrollView,Platform=ReactNative.Platform,Dimensions=ReactNative.Dimensions;var WINDOW_WIDTH=Dimensions.get("window").width;var ScrollableTabBar=(0,_createReactClass2.default)({displayName:"ScrollableTabBar",propTypes:{goToPage:_propTypes2.default.func,activeTab:_propTypes2.default.number,tabs:_propTypes2.default.array,backgroundColor:_propTypes2.default.string,activeTextColor:_propTypes2.default.string,inactiveTextColor:_propTypes2.default.string,scrollOffset:_propTypes2.default.number,style:_utils.ViewPropTypes.style,tabStyle:_utils.ViewPropTypes.style,tabsContainerStyle:_utils.ViewPropTypes.style,renderTab:_propTypes2.default.func,underlineStyle:_utils.ViewPropTypes.style,onScroll:_propTypes2.default.func},contextTypes:{theme:_propTypes2.default.object},getDefaultProps:function getDefaultProps(){return{scrollOffset:52,activeTextColor:"navy",inactiveTextColor:"black",backgroundColor:_platform2.default.tabDefaultBg,style:{},tabStyle:{},tabsContainerStyle:{},underlineStyle:{},tabFontSize:_platform2.default.tabFontSize};},getInitialState:function getInitialState(){this._tabsMeasurements=[];return{_leftTabUnderline:new Animated.Value(0),_widthTabUnderline:new Animated.Value(0),_containerWidth:null};},componentDidMount:function componentDidMount(){this.props.scrollValue.addListener(this.updateView);},updateView:function updateView(offset){var position=Math.floor(offset.value);var pageOffset=offset.value%1;var tabCount=this.props.tabs.length;var lastTabPosition=tabCount-1;if(tabCount===0||offset.value<0||offset.value>lastTabPosition){return;}if(this.necessarilyMeasurementsCompleted(position,position===lastTabPosition)){this.updateTabPanel(position,pageOffset);this.updateTabUnderline(position,pageOffset,tabCount);}},necessarilyMeasurementsCompleted:function necessarilyMeasurementsCompleted(position,isLastTab){return this._tabsMeasurements[position]&&(isLastTab||this._tabsMeasurements[position+1])&&this._tabContainerMeasurements&&this._containerMeasurements;},updateTabPanel:function updateTabPanel(position,pageOffset){var containerWidth=this._containerMeasurements.width;var tabWidth=this._tabsMeasurements[position].width;var nextTabMeasurements=this._tabsMeasurements[position+1];var nextTabWidth=nextTabMeasurements&&nextTabMeasurements.width||0;var tabOffset=this._tabsMeasurements[position].left;var absolutePageOffset=pageOffset*tabWidth;var newScrollX=tabOffset+absolutePageOffset;newScrollX-=(containerWidth-(1-pageOffset)*tabWidth-pageOffset*nextTabWidth)/2;newScrollX=newScrollX>=0?newScrollX:0;if(Platform.OS==="android"){this._scrollView.scrollTo({x:newScrollX,y:0,animated:false});}else{var rightBoundScroll=this._tabContainerMeasurements.width-this._containerMeasurements.width;newScrollX=newScrollX>rightBoundScroll?rightBoundScroll:newScrollX;this._scrollView.scrollTo({x:newScrollX,y:0,animated:false});}},updateTabUnderline:function updateTabUnderline(position,pageOffset,tabCount){var lineLeft=this._tabsMeasurements[position].left;var lineRight=this._tabsMeasurements[position].right;if(position<tabCount-1){var nextTabLeft=this._tabsMeasurements[position+1].left;var nextTabRight=this._tabsMeasurements[position+1].right;var newLineLeft=pageOffset*nextTabLeft+(1-pageOffset)*lineLeft;var newLineRight=pageOffset*nextTabRight+(1-pageOffset)*lineRight;this.state._leftTabUnderline.setValue(newLineLeft);this.state._widthTabUnderline.setValue(newLineRight-newLineLeft);}else{this.state._leftTabUnderline.setValue(lineLeft);this.state._widthTabUnderline.setValue(lineRight-lineLeft);}},renderTab:function renderTab(name,page,isTabActive,onPressHandler,onLayoutHandler,tabStyle,activeTabStyle,textStyle,activeTextStyle,tabHeaderStyle){var headerContent=typeof name!=="string"?name.props.children:undefined;var _props=this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize;var textColor=isTabActive?activeTextColor:inactiveTextColor;var fontWeight=isTabActive?"bold":"normal";var fontSize=tabFontSize;if(typeof name==="string"){return _react2.default.createElement(Button,{key:name+"_"+page,onPress:function onPress(){return onPressHandler(page);},onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:172}},_react2.default.createElement(_index.TabHeading,{scrollable:true,style:isTabActive?activeTabStyle:tabStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:177}},_react2.default.createElement(_index.Text,{style:[isTabActive?activeTextStyle:textStyle,{fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:182}},name)));}else{return _react2.default.createElement(Button,{key:_lodash2.default.random(1.2,5.2),onPress:function onPress(){return onPressHandler(page);},onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:195}},_react2.default.createElement(_index.TabHeading,{scrollable:true,style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:200}},headerContent));}},measureTab:function measureTab(page,event){var _event$nativeEvent$la=event.nativeEvent.layout,x=_event$nativeEvent$la.x,width=_event$nativeEvent$la.width,height=_event$nativeEvent$la.height;this._tabsMeasurements[page]={left:x,right:x+width,width:width,height:height};this.updateView({value:this.props.scrollValue._value});},render:function render(){var _this=this;var variables=this.context.theme?this.context.theme["@@shoutem.theme/themeStyle"].variables:_platform2.default;var tabUnderlineStyle={position:"absolute",height:4,backgroundColor:variables.topTabBarActiveBorderColor,bottom:0};var dynamicTabUnderline={left:this.state._leftTabUnderline,width:this.state._widthTabUnderline};return _react2.default.createElement(View,{style:[styles.container,{backgroundColor:this.props.backgroundColor},this.props.style],onLayout:this.onContainerLayout,__source:{fileName:_jsxFileName,lineNumber:231}},_react2.default.createElement(ScrollView,{automaticallyAdjustContentInsets:false,ref:function ref(scrollView){_this._scrollView=scrollView;},horizontal:true,showsHorizontalScrollIndicator:false,showsVerticalScrollIndicator:false,directionalLockEnabled:true,onScroll:this.props.onScroll,bounces:false,scrollsToTop:false,__source:{fileName:_jsxFileName,lineNumber:239}},_react2.default.createElement(View,{style:[styles.tabs,{width:this.state._containerWidth},this.props.tabsContainerStyle],ref:"tabContainer",onLayout:this.onTabContainerLayout,__source:{fileName:_jsxFileName,lineNumber:252}},this.props.tabs.map(function(name,page){var isTabActive=_this.props.activeTab===page;var renderTab=_this.props.renderTab||_this.renderTab;return renderTab(name,page,isTabActive,_this.props.goToPage,_this.measureTab.bind(_this,page),_this.props.tabStyle[page],_this.props.activeTabStyle[page],_this.props.textStyle[page],_this.props.activeTextStyle[page],_this.props.tabHeaderStyle[page]);}),_react2.default.createElement(Animated.View,{style:[tabUnderlineStyle,dynamicTabUnderline,this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:277}}))));},componentWillReceiveProps:function componentWillReceiveProps(nextProps){if(!_lodash2.default.isEqual(this.props.tabs,nextProps.tabs)&&this.state._containerWidth){this.setState({_containerWidth:null});}},onTabContainerLayout:function onTabContainerLayout(e){this._tabContainerMeasurements=e.nativeEvent.layout;var width=this._tabContainerMeasurements.width;if(width<WINDOW_WIDTH){width=WINDOW_WIDTH;}this.setState({_containerWidth:width});this.updateView({value:this.props.scrollValue._value});},onContainerLayout:function onContainerLayout(e){this._containerMeasurements=e.nativeEvent.layout;this.updateView({value:this.props.scrollValue._value});}});var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.ScrollableTab",{},_mapPropsToStyleNames2.default)(ScrollableTabBar);exports.ScrollableTab=StyledTab;var styles=StyleSheet.create({tab:{height:49,alignItems:"center",justifyContent:"center",paddingLeft:20,paddingRight:20},container:{height:50,borderWidth:1,borderTopWidth:0,borderLeftWidth:0,borderRightWidth:0,borderColor:"#ccc"},tabs:{flexDirection:"row",justifyContent:"space-around"}}); </s> remove "react": ">=16.0.0-alpha.12", "react-native": ">=0.46.0" </s> add "react": ">=16.4.1", "react-native": ">=0.56.0" </s> remove 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 _jsxFileName="src/basic/Tabs/index.js";var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;} var React=require("react");var Component=React.Component; var ReactNative=require("react-native");var Dimensions= ReactNative.Dimensions,View=ReactNative.View,Animated=ReactNative.Animated,ScrollView=ReactNative.ScrollView,StyleSheet=ReactNative.StyleSheet,Platform=ReactNative.Platform; var TimerMixin=require("react-timer-mixin"); var SceneComponent=require("./SceneComponent");var _require= require("./DefaultTabBar"),DefaultTabBar=_require.DefaultTabBar;var _require2= require("./ScrollableTabBar"),ScrollableTabBar=_require2.ScrollableTabBar; var ScrollableTabView=(0,_createReactClass2.default)({displayName:"ScrollableTabView", mixins:[TimerMixin], statics:{ DefaultTabBar:DefaultTabBar, ScrollableTabBar:ScrollableTabBar}, propTypes:{ tabBarPosition:_propTypes2.default.oneOf([ "top", "bottom", "overlayTop", "overlayBottom"]), initialPage:_propTypes2.default.number, page:_propTypes2.default.number, onChangeTab:_propTypes2.default.func, onScroll:_propTypes2.default.func, renderTabBar:_propTypes2.default.any, style:_utils.ViewPropTypes.style, contentProps:_propTypes2.default.object, scrollWithoutAnimation:_propTypes2.default.bool, locked:_propTypes2.default.bool, prerenderingSiblingsNumber:_propTypes2.default.number}, getDefaultProps:function getDefaultProps(){ return{ tabBarPosition:"top", initialPage:0, page:-1, onChangeTab:function onChangeTab(){}, onScroll:function onScroll(){}, contentProps:{}, scrollWithoutAnimation:false, locked:false, prerenderingSiblingsNumber:0}; }, getInitialState:function getInitialState(){ return{ currentPage:this.props.initialPage, scrollValue:new Animated.Value(this.props.initialPage), containerWidth:Dimensions.get("window").width, sceneKeys:this.newSceneKeys({currentPage:this.props.initialPage})}; }, componentDidMount:function componentDidMount(){var _this=this; var scrollFn=function scrollFn(){ if(_this.scrollView){ _this.state.scrollValue.setValue(_this.props.initialPage); } }; _utils.InteractionManager.runAfterInteractions(scrollFn); }, componentWillReceiveProps:function componentWillReceiveProps(props){ if(props.children!==this.props.children){ this.updateSceneKeys({ page:this.state.currentPage, children:props.children}); } if(props.page>=0&&props.page!==this.state.currentPage){ this.goToPage(props.page); } }, goToPage:function goToPage(pageNumber){ var offset=pageNumber*this.state.containerWidth; if(this.scrollView){ this.scrollView.scrollTo({ x:offset, y:0, animated:!this.props.scrollWithoutAnimation}); } var currentPage=this.state.currentPage; this.updateSceneKeys({ page:pageNumber, callback:this._onChangeTab.bind(this,currentPage,pageNumber)}); }, renderTabBar:function renderTabBar(props){ if(this.props.renderTabBar===false){ return null; }else if(this.props.renderTabBar){ return React.cloneElement(this.props.renderTabBar(props),props); }else{ return React.createElement(DefaultTabBar,_extends({},props,{__source:{fileName:_jsxFileName,lineNumber:116}})); } }, updateSceneKeys:function updateSceneKeys(_ref) {var page=_ref.page,_ref$children=_ref.children,children=_ref$children===undefined?this.props.children:_ref$children,_ref$callback=_ref.callback,callback=_ref$callback===undefined?function(){}:_ref$callback; var newKeys=this.newSceneKeys({ previousKeys:this.state.sceneKeys, currentPage:page, children:children}); this.setState({currentPage:page,sceneKeys:newKeys},callback); }, newSceneKeys:function newSceneKeys(_ref2) {var _this2=this;var _ref2$previousKeys=_ref2.previousKeys,previousKeys=_ref2$previousKeys===undefined?[]:_ref2$previousKeys,_ref2$currentPage=_ref2.currentPage,currentPage=_ref2$currentPage===undefined?0:_ref2$currentPage,_ref2$children=_ref2.children,children=_ref2$children===undefined?this.props.children:_ref2$children; var newKeys=[]; this._children(children).forEach(function(child,idx){ var key=_this2._makeSceneKey(child,idx); if( _this2._keyExists(previousKeys,key)|| _this2._shouldRenderSceneKey(idx,currentPage)) { newKeys.push(key); } }); return newKeys; }, _shouldRenderSceneKey:function _shouldRenderSceneKey(idx,currentPageKey){ var numOfSibling=this.props.prerenderingSiblingsNumber; return( idx<currentPageKey+numOfSibling+1&& idx>currentPageKey-numOfSibling-1); }, _keyExists:function _keyExists(sceneKeys,key){ return sceneKeys.find(function(sceneKey){return key===sceneKey;}); }, _makeSceneKey:function _makeSceneKey(child,idx){ return child.props.heading+"_"+idx; }, renderScrollableContent:function renderScrollableContent(){var _this3=this; var scenes=this._composeScenes(); return( React.createElement(ScrollView,_extends({ horizontal:true, pagingEnabled:true, automaticallyAdjustContentInsets:false, keyboardShouldPersistTaps:"handled", contentOffset:{ x:this.props.initialPage*this.state.containerWidth}, ref:function ref(scrollView){ _this3.scrollView=scrollView; }, onScroll:function onScroll(e){ var offsetX=e.nativeEvent.contentOffset.x; _this3._updateScrollValue(offsetX/_this3.state.containerWidth); }, onMomentumScrollBegin:this._onMomentumScrollBeginAndEnd, onMomentumScrollEnd:this._onMomentumScrollBeginAndEnd, scrollEventThrottle:16, scrollsToTop:false, showsHorizontalScrollIndicator:false, scrollEnabled:!this.props.locked, directionalLockEnabled:true, alwaysBounceVertical:false, keyboardDismissMode:"on-drag"}, this.props.contentProps,{__source:{fileName:_jsxFileName,lineNumber:170}}), scenes)); }, _composeScenes:function _composeScenes(){var _this4=this; return this._children().map(function(child,idx){ var key=_this4._makeSceneKey(child,idx); return( React.createElement(SceneComponent,{ key:child.key, shouldUpdated:_this4._shouldRenderSceneKey( idx, _this4.state.currentPage), style:{width:_this4.state.containerWidth},__source:{fileName:_jsxFileName,lineNumber:205}}, _this4._keyExists(_this4.state.sceneKeys,key)? child: React.createElement(View,{heading:child.props.heading,__source:{fileName:_jsxFileName,lineNumber:216}}))); }); }, _onMomentumScrollBeginAndEnd:function _onMomentumScrollBeginAndEnd(e){ var offsetX=e.nativeEvent.contentOffset.x; var page=Math.round(offsetX/this.state.containerWidth); if(this.state.currentPage!==page){ this._updateSelectedPage(page); } }, _updateSelectedPage:function _updateSelectedPage(nextPage){ var localNextPage=nextPage; if(typeof localNextPage==="object"){ localNextPage=nextPage.nativeEvent.position; } var currentPage=this.state.currentPage; this.updateSceneKeys({ page:localNextPage, callback:this._onChangeTab.bind(this,currentPage,localNextPage)}); }, _onChangeTab:function _onChangeTab(prevPage,currentPage){ this.props.onChangeTab({ i:currentPage, ref:this._children()[currentPage], from:prevPage}); }, _updateScrollValue:function _updateScrollValue(value){ this.state.scrollValue.setValue(value); this.props.onScroll(value); }, _handleLayout:function _handleLayout(e){var _this5=this;var width=e.nativeEvent.layout.width; if(Math.round(width)!==Math.round(this.state.containerWidth)){ this.setState({containerWidth:width}); this.requestAnimationFrame(function(){ _this5.goToPage(_this5.state.currentPage); }); } }, _children:function _children(){var children=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.props.children; return React.Children.map(children,function(child){return child;}); }, render:function render(){ var overlayTabs= this.props.tabBarPosition==="overlayTop"|| this.props.tabBarPosition==="overlayBottom"; var tabBarProps={ goToPage:this.goToPage, tabs:this._children().map(function(child){return child.props.heading;}), tabStyle:this._children().map(function(child){return child.props.tabStyle;}), activeTabStyle:this._children().map(function(child){return child.props.activeTabStyle;}), textStyle:this._children().map(function(child){return child.props.textStyle;}), activeTextStyle:this._children().map( function(child){return child.props.activeTextStyle;}), tabHeaderStyle:this._children().map(function(child){return( _lodash2.default.get(child.props.heading.props,"style",undefined));}), activeTab:this.state.currentPage, scrollValue:this.state.scrollValue, containerWidth:this.state.containerWidth}; if(this.props.tabBarBackgroundColor){ tabBarProps.backgroundColor=this.props.tabBarBackgroundColor; } if(this.props.tabBarActiveTextColor){ tabBarProps.activeTextColor=this.props.tabBarActiveTextColor; } if(this.props.tabBarInactiveTextColor){ tabBarProps.inactiveTextColor=this.props.tabBarInactiveTextColor; } if(this.props.tabBarTextStyle){ tabBarProps.textStyle=this.props.tabBarTextStyle; } if(this.props.tabBarUnderlineStyle){ tabBarProps.underlineStyle=this.props.tabBarUnderlineStyle; } if(this.props.tabContainerStyle){ tabBarProps.tabContainerStyle=this.props.tabContainerStyle; } if(overlayTabs){var _tabBarProps$style; tabBarProps.style=(_tabBarProps$style={ position:"absolute", left:0, right:0},_defineProperty(_tabBarProps$style, this.props.tabBarPosition==="overlayTop"?"top":"bottom",0),_defineProperty(_tabBarProps$style,"backgroundColor", "rgba(255, 255, 255, 0.7)"),_tabBarProps$style); } return( React.createElement(View,{ style:[styles.container,this.props.style], onLayout:this._handleLayout,__source:{fileName:_jsxFileName,lineNumber:322}}, (this.props.tabBarPosition==="top"|| this.props.tabBarPosition==="overlayTop")&& this.renderTabBar(tabBarProps), this.renderScrollableContent(), (this.props.tabBarPosition==="bottom"|| this.props.tabBarPosition==="overlayBottom")&& this.renderTabBar(tabBarProps))); }});exports.default= ScrollableTabView; var styles=StyleSheet.create({ container:{ flex:1}, scrollableContentAndroid:{ flex:1}}); </s> add 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 _jsxFileName="src/basic/Tabs/index.js";var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var React=require("react");var Component=React.Component;var ReactNative=require("react-native");var Dimensions=ReactNative.Dimensions,View=ReactNative.View,Animated=ReactNative.Animated,ScrollView=ReactNative.ScrollView,StyleSheet=ReactNative.StyleSheet,Platform=ReactNative.Platform;var TimerMixin=require("react-timer-mixin");var SceneComponent=require("./SceneComponent");var _require=require("./DefaultTabBar"),DefaultTabBar=_require.DefaultTabBar;var _require2=require("./ScrollableTabBar"),ScrollableTabBar=_require2.ScrollableTabBar;var ScrollableTabView=(0,_createReactClass2.default)({displayName:"ScrollableTabView",mixins:[TimerMixin],statics:{DefaultTabBar:DefaultTabBar,ScrollableTabBar:ScrollableTabBar},propTypes:{tabBarPosition:_propTypes2.default.oneOf(["top","bottom","overlayTop","overlayBottom"]),initialPage:_propTypes2.default.number,page:_propTypes2.default.number,onChangeTab:_propTypes2.default.func,onScroll:_propTypes2.default.func,renderTabBar:_propTypes2.default.any,style:_utils.ViewPropTypes.style,contentProps:_propTypes2.default.object,scrollWithoutAnimation:_propTypes2.default.bool,locked:_propTypes2.default.bool,prerenderingSiblingsNumber:_propTypes2.default.number},getDefaultProps:function getDefaultProps(){return{tabBarPosition:"top",initialPage:0,page:-1,onChangeTab:function onChangeTab(){},onScroll:function onScroll(){},contentProps:{},scrollWithoutAnimation:false,locked:false,prerenderingSiblingsNumber:0};},getInitialState:function getInitialState(){return{currentPage:this.props.initialPage,scrollValue:new Animated.Value(this.props.initialPage),containerWidth:Dimensions.get("window").width,sceneKeys:this.newSceneKeys({currentPage:this.props.initialPage})};},componentDidMount:function componentDidMount(){var _this=this;var scrollFn=function scrollFn(){if(_this.scrollView){_this.state.scrollValue.setValue(_this.props.initialPage);}};_utils.InteractionManager.runAfterInteractions(scrollFn);},componentWillReceiveProps:function componentWillReceiveProps(props){if(props.children!==this.props.children){this.updateSceneKeys({page:this.state.currentPage,children:props.children});}if(props.page>=0&&props.page!==this.state.currentPage){this.goToPage(props.page);}},goToPage:function goToPage(pageNumber){var offset=pageNumber*this.state.containerWidth;if(this.scrollView){this.scrollView.scrollTo({x:offset,y:0,animated:!this.props.scrollWithoutAnimation});}var currentPage=this.state.currentPage;this.updateSceneKeys({page:pageNumber,callback:this._onChangeTab.bind(this,currentPage,pageNumber)});},renderTabBar:function renderTabBar(props){if(this.props.renderTabBar===false){return null;}else if(this.props.renderTabBar){return React.cloneElement(this.props.renderTabBar(props),props);}else{return React.createElement(DefaultTabBar,_extends({},props,{__source:{fileName:_jsxFileName,lineNumber:116}}));}},updateSceneKeys:function updateSceneKeys(_ref){var page=_ref.page,_ref$children=_ref.children,children=_ref$children===undefined?this.props.children:_ref$children,_ref$callback=_ref.callback,callback=_ref$callback===undefined?function(){}:_ref$callback;var newKeys=this.newSceneKeys({previousKeys:this.state.sceneKeys,currentPage:page,children:children});this.setState({currentPage:page,sceneKeys:newKeys},callback);},newSceneKeys:function newSceneKeys(_ref2){var _this2=this;var _ref2$previousKeys=_ref2.previousKeys,previousKeys=_ref2$previousKeys===undefined?[]:_ref2$previousKeys,_ref2$currentPage=_ref2.currentPage,currentPage=_ref2$currentPage===undefined?0:_ref2$currentPage,_ref2$children=_ref2.children,children=_ref2$children===undefined?this.props.children:_ref2$children;var newKeys=[];this._children(children).forEach(function(child,idx){var key=_this2._makeSceneKey(child,idx);if(_this2._keyExists(previousKeys,key)||_this2._shouldRenderSceneKey(idx,currentPage)){newKeys.push(key);}});return newKeys;},_shouldRenderSceneKey:function _shouldRenderSceneKey(idx,currentPageKey){var numOfSibling=this.props.prerenderingSiblingsNumber;return idx<currentPageKey+numOfSibling+1&&idx>currentPageKey-numOfSibling-1;},_keyExists:function _keyExists(sceneKeys,key){return sceneKeys.find(function(sceneKey){return key===sceneKey;});},_makeSceneKey:function _makeSceneKey(child,idx){return child.props.heading+"_"+idx;},renderScrollableContent:function renderScrollableContent(){var _this3=this;var scenes=this._composeScenes();return React.createElement(ScrollView,_extends({horizontal:true,pagingEnabled:true,automaticallyAdjustContentInsets:false,keyboardShouldPersistTaps:"handled",contentOffset:{x:this.props.initialPage*this.state.containerWidth},ref:function ref(scrollView){_this3.scrollView=scrollView;},onScroll:function onScroll(e){var offsetX=e.nativeEvent.contentOffset.x;_this3._updateScrollValue(offsetX/_this3.state.containerWidth);},onMomentumScrollBegin:this._onMomentumScrollBeginAndEnd,onMomentumScrollEnd:this._onMomentumScrollBeginAndEnd,scrollEventThrottle:16,scrollsToTop:false,showsHorizontalScrollIndicator:false,scrollEnabled:!this.props.locked,directionalLockEnabled:true,alwaysBounceVertical:false,keyboardDismissMode:"on-drag"},this.props.contentProps,{__source:{fileName:_jsxFileName,lineNumber:170}}),scenes);},_composeScenes:function _composeScenes(){var _this4=this;return this._children().map(function(child,idx){var key=_this4._makeSceneKey(child,idx);return React.createElement(SceneComponent,{key:child.key,shouldUpdated:_this4._shouldRenderSceneKey(idx,_this4.state.currentPage),style:{width:_this4.state.containerWidth},__source:{fileName:_jsxFileName,lineNumber:205}},_this4._keyExists(_this4.state.sceneKeys,key)?child:React.createElement(View,{heading:child.props.heading,__source:{fileName:_jsxFileName,lineNumber:216}}));});},_onMomentumScrollBeginAndEnd:function _onMomentumScrollBeginAndEnd(e){var offsetX=e.nativeEvent.contentOffset.x;var page=Math.round(offsetX/this.state.containerWidth);if(this.state.currentPage!==page){this._updateSelectedPage(page);}},_updateSelectedPage:function _updateSelectedPage(nextPage){var localNextPage=nextPage;if(typeof localNextPage==="object"){localNextPage=nextPage.nativeEvent.position;}var currentPage=this.state.currentPage;this.updateSceneKeys({page:localNextPage,callback:this._onChangeTab.bind(this,currentPage,localNextPage)});},_onChangeTab:function _onChangeTab(prevPage,currentPage){this.props.onChangeTab({i:currentPage,ref:this._children()[currentPage],from:prevPage});},_updateScrollValue:function _updateScrollValue(value){this.state.scrollValue.setValue(value);this.props.onScroll(value);},_handleLayout:function _handleLayout(e){var _this5=this;var width=e.nativeEvent.layout.width;if(Math.round(width)!==Math.round(this.state.containerWidth)){this.setState({containerWidth:width});this.requestAnimationFrame(function(){_this5.goToPage(_this5.state.currentPage);});}},_children:function _children(){var children=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.props.children;return React.Children.map(children,function(child){return child;});},render:function render(){var overlayTabs=this.props.tabBarPosition==="overlayTop"||this.props.tabBarPosition==="overlayBottom";var tabBarProps={goToPage:this.goToPage,tabs:this._children().map(function(child){return child.props.heading;}),tabStyle:this._children().map(function(child){return child.props.tabStyle;}),activeTabStyle:this._children().map(function(child){return child.props.activeTabStyle;}),textStyle:this._children().map(function(child){return child.props.textStyle;}),activeTextStyle:this._children().map(function(child){return child.props.activeTextStyle;}),tabHeaderStyle:this._children().map(function(child){return _lodash2.default.get(child.props.heading.props,"style",undefined);}),activeTab:this.state.currentPage,scrollValue:this.state.scrollValue,containerWidth:this.state.containerWidth};if(this.props.tabBarBackgroundColor){tabBarProps.backgroundColor=this.props.tabBarBackgroundColor;}if(this.props.tabBarActiveTextColor){tabBarProps.activeTextColor=this.props.tabBarActiveTextColor;}if(this.props.tabBarInactiveTextColor){tabBarProps.inactiveTextColor=this.props.tabBarInactiveTextColor;}if(this.props.tabBarTextStyle){tabBarProps.textStyle=this.props.tabBarTextStyle;}if(this.props.tabBarUnderlineStyle){tabBarProps.underlineStyle=this.props.tabBarUnderlineStyle;}if(this.props.tabContainerStyle){tabBarProps.tabContainerStyle=this.props.tabContainerStyle;}if(overlayTabs){var _tabBarProps$style;tabBarProps.style=(_tabBarProps$style={position:"absolute",left:0,right:0},_defineProperty(_tabBarProps$style,this.props.tabBarPosition==="overlayTop"?"top":"bottom",0),_defineProperty(_tabBarProps$style,"backgroundColor","rgba(255, 255, 255, 0.7)"),_tabBarProps$style);}return React.createElement(View,{style:[styles.container,this.props.style],onLayout:this._handleLayout,__source:{fileName:_jsxFileName,lineNumber:322}},(this.props.tabBarPosition==="top"||this.props.tabBarPosition==="overlayTop")&&this.renderTabBar(tabBarProps),this.renderScrollableContent(),(this.props.tabBarPosition==="bottom"||this.props.tabBarPosition==="overlayBottom")&&this.renderTabBar(tabBarProps));}});exports.default=ScrollableTabView;var styles=StyleSheet.create({container:{flex:1},scrollableContentAndroid:{flex:1}});
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f6b810f5f0d9b1a4cfabaccbcf733cafc7edff42
package.json
"jest": "23.3.0", "react": "16.4.1", "react-native": "0.56.0", "react-native-vector-icons": "4.6.0", "react-test-renderer": "16.4.1"
<mask> "eslint-plugin-jsx-a11y": "^2.2.1", <mask> "eslint-plugin-react": "^6.2.0", <mask> "eslint-plugin-react-native": "^2.0.0", <mask> "flow-bin": "0.47.0", <mask> "jest": "19.0.2", <mask> "react": "^16.0.0-alpha.12", <mask> "react-native": "^0.46.0", <mask> "react-native-vector-icons": "~4.5.0", <mask> "react-test-renderer": "^16.0.0-alpha.12" <mask> }, <mask> "gitHead": "5bbeacc403ba97622703699132c55d8359344004", <mask> "homepage": "https://github.com/GeekyAnts/NativeBase#readme", <mask> "main": "dist/src/index.js", <mask> "typings": "./index.d.ts", </s> Upgraded deps and dev-deps, compatible with RN 0.56.0 </s> remove "react": ">=16.0.0-alpha.12", "react-native": ">=0.46.0" </s> add "react": ">=16.4.1", "react-native": ">=0.56.0" </s> remove "babel-jest": "^16.0.0", "babel-preset-react-native": "^1.9.2", </s> add "babel-jest": "23.2.0", "babel-preset-react-native": "4.0.0", </s> remove "react-native-easy-grid": "0.1.17", </s> add "react-native-easy-grid": "https://github.com/GeekyAnts/react-native-easy-grid#development", </s> remove Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color); var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var deviceHeight=_reactNative.Dimensions.get("window").height; var deviceWidth=_reactNative.Dimensions.get("window").width; var platform=_reactNative.Platform.OS; var platformStyle=undefined; var isIphoneX= platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default= { platformStyle:platformStyle, platform:platform, headerStyle:"#edebed", iconStyle:"#000", contentStyle:"#f5f4f5", expandedIconStyle:"#000", accordionBorderColor:"#d3d3d3", androidRipple:true, androidRippleColor:"rgba(256, 256, 256, 0.3)", androidRippleColorDark:"rgba(0, 0, 0, 0.15)", btnUppercaseAndroidText:true, badgeBg:"#ED1727", badgeColor:"#fff", badgePadding:platform==="ios"?3:0, btnFontFamily:platform==="ios"?"System":"Roboto_medium", btnDisabledBg:"#b5b5b5", buttonPadding:6, get btnPrimaryBg(){ return this.brandPrimary; }, get btnPrimaryColor(){ return this.inverseTextColor; }, get btnInfoBg(){ return this.brandInfo; }, get btnInfoColor(){ return this.inverseTextColor; }, get btnSuccessBg(){ return this.brandSuccess; }, get btnSuccessColor(){ return this.inverseTextColor; }, get btnDangerBg(){ return this.brandDanger; }, get btnDangerColor(){ return this.inverseTextColor; }, get btnWarningBg(){ return this.brandWarning; }, get btnWarningColor(){ return this.inverseTextColor; }, get btnTextSize(){ return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1; }, get btnTextSizeLarge(){ return this.fontSizeBase*1.5; }, get btnTextSizeSmall(){ return this.fontSizeBase*0.8; }, get borderRadiusLarge(){ return this.fontSizeBase*3.8; }, get iconSizeLarge(){ return this.iconFontSize*1.5; }, get iconSizeSmall(){ return this.iconFontSize*0.6; }, cardDefaultBg:"#fff", cardBorderColor:"#ccc", cardBorderRadius:2, cardItemPadding:platform==="ios"?10:12, CheckboxRadius:platform==="ios"?13:0, CheckboxBorderWidth:platform==="ios"?1:2, CheckboxPaddingLeft:platform==="ios"?4:2, CheckboxPaddingBottom:platform==="ios"?0:5, CheckboxIconSize:platform==="ios"?21:16, CheckboxIconMarginTop:platform==="ios"?undefined:1, CheckboxFontSize:platform==="ios"?23/0.9:17, checkboxBgColor:"#039BE5", checkboxSize:20, checkboxTickColor:"#fff", brandPrimary:platform==="ios"?"#007aff":"#3F51B5", brandInfo:"#62B1F6", brandSuccess:"#5cb85c", brandDanger:"#d9534f", brandWarning:"#f0ad4e", brandDark:"#000", brandLight:"#f4f4f4", datePickerTextColor:"#000", datePickerBg:"transparent", DefaultFontSize:16, fontFamily:platform==="ios"?"System":"Roboto", fontSizeBase:15, get fontSizeH1(){ return this.fontSizeBase*1.8; }, get fontSizeH2(){ return this.fontSizeBase*1.6; }, get fontSizeH3(){ return this.fontSizeBase*1.4; }, footerHeight:55, footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", footerPaddingBottom:0, tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", tabBarTextSize:platform==="ios"?14:11, activeTab:platform==="ios"?"#007aff":"#fff", sTabBarActiveTextColor:"#007aff", tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5", toolbarBtnColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", toolbarHeight:platform==="ios"?64:56, toolbarSearchIconSize:platform==="ios"?20:23, toolbarInputColor:platform==="ios"?"#CECDD2":"#fff", searchBarHeight:platform==="ios"?30:40, searchBarInputHeight:platform==="ios"?30:50, toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5", iosStatusbar:platform==="ios"?"dark-content":"light-content", get statusBarColor(){ return(0,_color2.default)(this.toolbarDefaultBg). darken(0.2). hex(); }, get darkenHeader(){ return(0,_color2.default)(this.tabBgColor). darken(0.03). hex(); }, iconFamily:"Ionicons", iconFontSize:platform==="ios"?30:28, iconHeaderSize:platform==="ios"?33:24, inputFontSize:17, inputBorderColor:"#D9D5DC", inputSuccessBorderColor:"#2b8339", inputErrorBorderColor:"#ed2f2f", inputHeightBase:50, get inputColor(){ return this.textColor; }, get inputColorPlaceholder(){ return"#575757"; }, btnLineHeight:19, lineHeightH1:32, lineHeightH2:27, lineHeightH3:22, lineHeight:platform==="ios"?20:24, listItemSelected:platform==="ios"?"#007aff":"#3F51B5", listBg:"transparent", listBorderColor:"#c9c9c9", listDividerBg:"#f4f4f4", listBtnUnderlayColor:"#DDD", listItemPadding:platform==="ios"?10:12, listNoteColor:"#808080", listNoteSize:13, defaultProgressColor:"#E4202D", inverseProgressColor:"#1A191B", radioBtnSize:platform==="ios"?25:23, radioSelectedColorAndroid:"#3F51B5", radioBtnLineHeight:platform==="ios"?29:24, get radioColor(){ return this.brandPrimary; }, segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5", segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff", segmentTextColor:platform==="ios"?"#007aff":"#fff", segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5", segmentBorderColor:platform==="ios"?"#007aff":"#fff", segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5", defaultSpinnerColor:"#45D56E", inverseSpinnerColor:"#1A191B", tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff", topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff", tabBgColor:"#F8F8F8", tabFontSize:15, textColor:"#000", inverseTextColor:"#fff", noteFontSize:14, get defaultTextColor(){ return this.textColor; }, titleFontfamily:platform==="ios"?"System":"Roboto_medium", titleFontSize:platform==="ios"?17:19, subTitleFontSize:platform==="ios"?11:14, subtitleColor:platform==="ios"?"#8e8e93":"#FFF", titleFontColor:platform==="ios"?"#000":"#FFF", borderRadiusBase:platform==="ios"?5:2, borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1), contentPadding:10, dropdownLinkColor:"#414142", inputLineHeight:24, deviceWidth:deviceWidth, deviceHeight:deviceHeight, isIphoneX:isIphoneX, inputGroupRoundedBorderRadius:30, Inset:{ portrait:{ topInset:24, leftInset:0, rightInset:0, bottomInset:34}, landscape:{ topInset:0, leftInset:44, rightInset:44, bottomInset:21}}}; </s> add Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color);var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var deviceHeight=_reactNative.Dimensions.get("window").height;var deviceWidth=_reactNative.Dimensions.get("window").width;var platform=_reactNative.Platform.OS;var platformStyle=undefined;var isIphoneX=platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default={platformStyle:platformStyle,platform:platform,headerStyle:"#edebed",iconStyle:"#000",contentStyle:"#f5f4f5",expandedIconStyle:"#000",accordionBorderColor:"#d3d3d3",androidRipple:true,androidRippleColor:"rgba(256, 256, 256, 0.3)",androidRippleColorDark:"rgba(0, 0, 0, 0.15)",btnUppercaseAndroidText:true,badgeBg:"#ED1727",badgeColor:"#fff",badgePadding:platform==="ios"?3:0,btnFontFamily:platform==="ios"?"System":"Roboto_medium",btnDisabledBg:"#b5b5b5",buttonPadding:6,get btnPrimaryBg(){return this.brandPrimary;},get btnPrimaryColor(){return this.inverseTextColor;},get btnInfoBg(){return this.brandInfo;},get btnInfoColor(){return this.inverseTextColor;},get btnSuccessBg(){return this.brandSuccess;},get btnSuccessColor(){return this.inverseTextColor;},get btnDangerBg(){return this.brandDanger;},get btnDangerColor(){return this.inverseTextColor;},get btnWarningBg(){return this.brandWarning;},get btnWarningColor(){return this.inverseTextColor;},get btnTextSize(){return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1;},get btnTextSizeLarge(){return this.fontSizeBase*1.5;},get btnTextSizeSmall(){return this.fontSizeBase*0.8;},get borderRadiusLarge(){return this.fontSizeBase*3.8;},get iconSizeLarge(){return this.iconFontSize*1.5;},get iconSizeSmall(){return this.iconFontSize*0.6;},cardDefaultBg:"#fff",cardBorderColor:"#ccc",cardBorderRadius:2,cardItemPadding:platform==="ios"?10:12,CheckboxRadius:platform==="ios"?13:0,CheckboxBorderWidth:platform==="ios"?1:2,CheckboxPaddingLeft:platform==="ios"?4:2,CheckboxPaddingBottom:platform==="ios"?0:5,CheckboxIconSize:platform==="ios"?21:16,CheckboxIconMarginTop:platform==="ios"?undefined:1,CheckboxFontSize:platform==="ios"?23/0.9:17,checkboxBgColor:"#039BE5",checkboxSize:20,checkboxTickColor:"#fff",brandPrimary:platform==="ios"?"#007aff":"#3F51B5",brandInfo:"#62B1F6",brandSuccess:"#5cb85c",brandDanger:"#d9534f",brandWarning:"#f0ad4e",brandDark:"#000",brandLight:"#f4f4f4",datePickerTextColor:"#000",datePickerBg:"transparent",DefaultFontSize:16,fontFamily:platform==="ios"?"System":"Roboto",fontSizeBase:15,get fontSizeH1(){return this.fontSizeBase*1.8;},get fontSizeH2(){return this.fontSizeBase*1.6;},get fontSizeH3(){return this.fontSizeBase*1.4;},footerHeight:55,footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",footerPaddingBottom:0,tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",tabBarTextSize:platform==="ios"?14:11,activeTab:platform==="ios"?"#007aff":"#fff",sTabBarActiveTextColor:"#007aff",tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5",toolbarBtnColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",toolbarHeight:platform==="ios"?64:56,toolbarSearchIconSize:platform==="ios"?20:23,toolbarInputColor:platform==="ios"?"#CECDD2":"#fff",searchBarHeight:platform==="ios"?30:40,searchBarInputHeight:platform==="ios"?30:50,toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5",iosStatusbar:platform==="ios"?"dark-content":"light-content",get statusBarColor(){return(0,_color2.default)(this.toolbarDefaultBg).darken(0.2).hex();},get darkenHeader(){return(0,_color2.default)(this.tabBgColor).darken(0.03).hex();},iconFamily:"Ionicons",iconFontSize:platform==="ios"?30:28,iconHeaderSize:platform==="ios"?33:24,inputFontSize:17,inputBorderColor:"#D9D5DC",inputSuccessBorderColor:"#2b8339",inputErrorBorderColor:"#ed2f2f",inputHeightBase:50,get inputColor(){return this.textColor;},get inputColorPlaceholder(){return"#575757";},btnLineHeight:19,lineHeightH1:32,lineHeightH2:27,lineHeightH3:22,lineHeight:platform==="ios"?20:24,listItemSelected:platform==="ios"?"#007aff":"#3F51B5",listBg:"transparent",listBorderColor:"#c9c9c9",listDividerBg:"#f4f4f4",listBtnUnderlayColor:"#DDD",listItemPadding:platform==="ios"?10:12,listNoteColor:"#808080",listNoteSize:13,defaultProgressColor:"#E4202D",inverseProgressColor:"#1A191B",radioBtnSize:platform==="ios"?25:23,radioSelectedColorAndroid:"#3F51B5",radioBtnLineHeight:platform==="ios"?29:24,get radioColor(){return this.brandPrimary;},segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5",segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff",segmentTextColor:platform==="ios"?"#007aff":"#fff",segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5",segmentBorderColor:platform==="ios"?"#007aff":"#fff",segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5",defaultSpinnerColor:"#45D56E",inverseSpinnerColor:"#1A191B",tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff",topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff",tabBgColor:"#F8F8F8",tabFontSize:15,textColor:"#000",inverseTextColor:"#fff",noteFontSize:14,get defaultTextColor(){return this.textColor;},titleFontfamily:platform==="ios"?"System":"Roboto_medium",titleFontSize:platform==="ios"?17:19,subTitleFontSize:platform==="ios"?11:14,subtitleColor:platform==="ios"?"#8e8e93":"#FFF",titleFontColor:platform==="ios"?"#000":"#FFF",borderRadiusBase:platform==="ios"?5:2,borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1),contentPadding:10,dropdownLinkColor:"#414142",inputLineHeight:24,deviceWidth:deviceWidth,deviceHeight:deviceHeight,isIphoneX:isIphoneX,inputGroupRoundedBorderRadius:30,Inset:{portrait:{topInset:24,leftInset:0,rightInset:0,bottomInset:34},landscape:{topInset:0,leftInset:44,rightInset:44,bottomInset:21}}}; </s> remove 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 _jsxFileName="src/basic/Tabs/index.js";var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;} var React=require("react");var Component=React.Component; var ReactNative=require("react-native");var Dimensions= ReactNative.Dimensions,View=ReactNative.View,Animated=ReactNative.Animated,ScrollView=ReactNative.ScrollView,StyleSheet=ReactNative.StyleSheet,Platform=ReactNative.Platform; var TimerMixin=require("react-timer-mixin"); var SceneComponent=require("./SceneComponent");var _require= require("./DefaultTabBar"),DefaultTabBar=_require.DefaultTabBar;var _require2= require("./ScrollableTabBar"),ScrollableTabBar=_require2.ScrollableTabBar; var ScrollableTabView=(0,_createReactClass2.default)({displayName:"ScrollableTabView", mixins:[TimerMixin], statics:{ DefaultTabBar:DefaultTabBar, ScrollableTabBar:ScrollableTabBar}, propTypes:{ tabBarPosition:_propTypes2.default.oneOf([ "top", "bottom", "overlayTop", "overlayBottom"]), initialPage:_propTypes2.default.number, page:_propTypes2.default.number, onChangeTab:_propTypes2.default.func, onScroll:_propTypes2.default.func, renderTabBar:_propTypes2.default.any, style:_utils.ViewPropTypes.style, contentProps:_propTypes2.default.object, scrollWithoutAnimation:_propTypes2.default.bool, locked:_propTypes2.default.bool, prerenderingSiblingsNumber:_propTypes2.default.number}, getDefaultProps:function getDefaultProps(){ return{ tabBarPosition:"top", initialPage:0, page:-1, onChangeTab:function onChangeTab(){}, onScroll:function onScroll(){}, contentProps:{}, scrollWithoutAnimation:false, locked:false, prerenderingSiblingsNumber:0}; }, getInitialState:function getInitialState(){ return{ currentPage:this.props.initialPage, scrollValue:new Animated.Value(this.props.initialPage), containerWidth:Dimensions.get("window").width, sceneKeys:this.newSceneKeys({currentPage:this.props.initialPage})}; }, componentDidMount:function componentDidMount(){var _this=this; var scrollFn=function scrollFn(){ if(_this.scrollView){ _this.state.scrollValue.setValue(_this.props.initialPage); } }; _utils.InteractionManager.runAfterInteractions(scrollFn); }, componentWillReceiveProps:function componentWillReceiveProps(props){ if(props.children!==this.props.children){ this.updateSceneKeys({ page:this.state.currentPage, children:props.children}); } if(props.page>=0&&props.page!==this.state.currentPage){ this.goToPage(props.page); } }, goToPage:function goToPage(pageNumber){ var offset=pageNumber*this.state.containerWidth; if(this.scrollView){ this.scrollView.scrollTo({ x:offset, y:0, animated:!this.props.scrollWithoutAnimation}); } var currentPage=this.state.currentPage; this.updateSceneKeys({ page:pageNumber, callback:this._onChangeTab.bind(this,currentPage,pageNumber)}); }, renderTabBar:function renderTabBar(props){ if(this.props.renderTabBar===false){ return null; }else if(this.props.renderTabBar){ return React.cloneElement(this.props.renderTabBar(props),props); }else{ return React.createElement(DefaultTabBar,_extends({},props,{__source:{fileName:_jsxFileName,lineNumber:116}})); } }, updateSceneKeys:function updateSceneKeys(_ref) {var page=_ref.page,_ref$children=_ref.children,children=_ref$children===undefined?this.props.children:_ref$children,_ref$callback=_ref.callback,callback=_ref$callback===undefined?function(){}:_ref$callback; var newKeys=this.newSceneKeys({ previousKeys:this.state.sceneKeys, currentPage:page, children:children}); this.setState({currentPage:page,sceneKeys:newKeys},callback); }, newSceneKeys:function newSceneKeys(_ref2) {var _this2=this;var _ref2$previousKeys=_ref2.previousKeys,previousKeys=_ref2$previousKeys===undefined?[]:_ref2$previousKeys,_ref2$currentPage=_ref2.currentPage,currentPage=_ref2$currentPage===undefined?0:_ref2$currentPage,_ref2$children=_ref2.children,children=_ref2$children===undefined?this.props.children:_ref2$children; var newKeys=[]; this._children(children).forEach(function(child,idx){ var key=_this2._makeSceneKey(child,idx); if( _this2._keyExists(previousKeys,key)|| _this2._shouldRenderSceneKey(idx,currentPage)) { newKeys.push(key); } }); return newKeys; }, _shouldRenderSceneKey:function _shouldRenderSceneKey(idx,currentPageKey){ var numOfSibling=this.props.prerenderingSiblingsNumber; return( idx<currentPageKey+numOfSibling+1&& idx>currentPageKey-numOfSibling-1); }, _keyExists:function _keyExists(sceneKeys,key){ return sceneKeys.find(function(sceneKey){return key===sceneKey;}); }, _makeSceneKey:function _makeSceneKey(child,idx){ return child.props.heading+"_"+idx; }, renderScrollableContent:function renderScrollableContent(){var _this3=this; var scenes=this._composeScenes(); return( React.createElement(ScrollView,_extends({ horizontal:true, pagingEnabled:true, automaticallyAdjustContentInsets:false, keyboardShouldPersistTaps:"handled", contentOffset:{ x:this.props.initialPage*this.state.containerWidth}, ref:function ref(scrollView){ _this3.scrollView=scrollView; }, onScroll:function onScroll(e){ var offsetX=e.nativeEvent.contentOffset.x; _this3._updateScrollValue(offsetX/_this3.state.containerWidth); }, onMomentumScrollBegin:this._onMomentumScrollBeginAndEnd, onMomentumScrollEnd:this._onMomentumScrollBeginAndEnd, scrollEventThrottle:16, scrollsToTop:false, showsHorizontalScrollIndicator:false, scrollEnabled:!this.props.locked, directionalLockEnabled:true, alwaysBounceVertical:false, keyboardDismissMode:"on-drag"}, this.props.contentProps,{__source:{fileName:_jsxFileName,lineNumber:170}}), scenes)); }, _composeScenes:function _composeScenes(){var _this4=this; return this._children().map(function(child,idx){ var key=_this4._makeSceneKey(child,idx); return( React.createElement(SceneComponent,{ key:child.key, shouldUpdated:_this4._shouldRenderSceneKey( idx, _this4.state.currentPage), style:{width:_this4.state.containerWidth},__source:{fileName:_jsxFileName,lineNumber:205}}, _this4._keyExists(_this4.state.sceneKeys,key)? child: React.createElement(View,{heading:child.props.heading,__source:{fileName:_jsxFileName,lineNumber:216}}))); }); }, _onMomentumScrollBeginAndEnd:function _onMomentumScrollBeginAndEnd(e){ var offsetX=e.nativeEvent.contentOffset.x; var page=Math.round(offsetX/this.state.containerWidth); if(this.state.currentPage!==page){ this._updateSelectedPage(page); } }, _updateSelectedPage:function _updateSelectedPage(nextPage){ var localNextPage=nextPage; if(typeof localNextPage==="object"){ localNextPage=nextPage.nativeEvent.position; } var currentPage=this.state.currentPage; this.updateSceneKeys({ page:localNextPage, callback:this._onChangeTab.bind(this,currentPage,localNextPage)}); }, _onChangeTab:function _onChangeTab(prevPage,currentPage){ this.props.onChangeTab({ i:currentPage, ref:this._children()[currentPage], from:prevPage}); }, _updateScrollValue:function _updateScrollValue(value){ this.state.scrollValue.setValue(value); this.props.onScroll(value); }, _handleLayout:function _handleLayout(e){var _this5=this;var width=e.nativeEvent.layout.width; if(Math.round(width)!==Math.round(this.state.containerWidth)){ this.setState({containerWidth:width}); this.requestAnimationFrame(function(){ _this5.goToPage(_this5.state.currentPage); }); } }, _children:function _children(){var children=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.props.children; return React.Children.map(children,function(child){return child;}); }, render:function render(){ var overlayTabs= this.props.tabBarPosition==="overlayTop"|| this.props.tabBarPosition==="overlayBottom"; var tabBarProps={ goToPage:this.goToPage, tabs:this._children().map(function(child){return child.props.heading;}), tabStyle:this._children().map(function(child){return child.props.tabStyle;}), activeTabStyle:this._children().map(function(child){return child.props.activeTabStyle;}), textStyle:this._children().map(function(child){return child.props.textStyle;}), activeTextStyle:this._children().map( function(child){return child.props.activeTextStyle;}), tabHeaderStyle:this._children().map(function(child){return( _lodash2.default.get(child.props.heading.props,"style",undefined));}), activeTab:this.state.currentPage, scrollValue:this.state.scrollValue, containerWidth:this.state.containerWidth}; if(this.props.tabBarBackgroundColor){ tabBarProps.backgroundColor=this.props.tabBarBackgroundColor; } if(this.props.tabBarActiveTextColor){ tabBarProps.activeTextColor=this.props.tabBarActiveTextColor; } if(this.props.tabBarInactiveTextColor){ tabBarProps.inactiveTextColor=this.props.tabBarInactiveTextColor; } if(this.props.tabBarTextStyle){ tabBarProps.textStyle=this.props.tabBarTextStyle; } if(this.props.tabBarUnderlineStyle){ tabBarProps.underlineStyle=this.props.tabBarUnderlineStyle; } if(this.props.tabContainerStyle){ tabBarProps.tabContainerStyle=this.props.tabContainerStyle; } if(overlayTabs){var _tabBarProps$style; tabBarProps.style=(_tabBarProps$style={ position:"absolute", left:0, right:0},_defineProperty(_tabBarProps$style, this.props.tabBarPosition==="overlayTop"?"top":"bottom",0),_defineProperty(_tabBarProps$style,"backgroundColor", "rgba(255, 255, 255, 0.7)"),_tabBarProps$style); } return( React.createElement(View,{ style:[styles.container,this.props.style], onLayout:this._handleLayout,__source:{fileName:_jsxFileName,lineNumber:322}}, (this.props.tabBarPosition==="top"|| this.props.tabBarPosition==="overlayTop")&& this.renderTabBar(tabBarProps), this.renderScrollableContent(), (this.props.tabBarPosition==="bottom"|| this.props.tabBarPosition==="overlayBottom")&& this.renderTabBar(tabBarProps))); }});exports.default= ScrollableTabView; var styles=StyleSheet.create({ container:{ flex:1}, scrollableContentAndroid:{ flex:1}}); </s> add 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 _jsxFileName="src/basic/Tabs/index.js";var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var React=require("react");var Component=React.Component;var ReactNative=require("react-native");var Dimensions=ReactNative.Dimensions,View=ReactNative.View,Animated=ReactNative.Animated,ScrollView=ReactNative.ScrollView,StyleSheet=ReactNative.StyleSheet,Platform=ReactNative.Platform;var TimerMixin=require("react-timer-mixin");var SceneComponent=require("./SceneComponent");var _require=require("./DefaultTabBar"),DefaultTabBar=_require.DefaultTabBar;var _require2=require("./ScrollableTabBar"),ScrollableTabBar=_require2.ScrollableTabBar;var ScrollableTabView=(0,_createReactClass2.default)({displayName:"ScrollableTabView",mixins:[TimerMixin],statics:{DefaultTabBar:DefaultTabBar,ScrollableTabBar:ScrollableTabBar},propTypes:{tabBarPosition:_propTypes2.default.oneOf(["top","bottom","overlayTop","overlayBottom"]),initialPage:_propTypes2.default.number,page:_propTypes2.default.number,onChangeTab:_propTypes2.default.func,onScroll:_propTypes2.default.func,renderTabBar:_propTypes2.default.any,style:_utils.ViewPropTypes.style,contentProps:_propTypes2.default.object,scrollWithoutAnimation:_propTypes2.default.bool,locked:_propTypes2.default.bool,prerenderingSiblingsNumber:_propTypes2.default.number},getDefaultProps:function getDefaultProps(){return{tabBarPosition:"top",initialPage:0,page:-1,onChangeTab:function onChangeTab(){},onScroll:function onScroll(){},contentProps:{},scrollWithoutAnimation:false,locked:false,prerenderingSiblingsNumber:0};},getInitialState:function getInitialState(){return{currentPage:this.props.initialPage,scrollValue:new Animated.Value(this.props.initialPage),containerWidth:Dimensions.get("window").width,sceneKeys:this.newSceneKeys({currentPage:this.props.initialPage})};},componentDidMount:function componentDidMount(){var _this=this;var scrollFn=function scrollFn(){if(_this.scrollView){_this.state.scrollValue.setValue(_this.props.initialPage);}};_utils.InteractionManager.runAfterInteractions(scrollFn);},componentWillReceiveProps:function componentWillReceiveProps(props){if(props.children!==this.props.children){this.updateSceneKeys({page:this.state.currentPage,children:props.children});}if(props.page>=0&&props.page!==this.state.currentPage){this.goToPage(props.page);}},goToPage:function goToPage(pageNumber){var offset=pageNumber*this.state.containerWidth;if(this.scrollView){this.scrollView.scrollTo({x:offset,y:0,animated:!this.props.scrollWithoutAnimation});}var currentPage=this.state.currentPage;this.updateSceneKeys({page:pageNumber,callback:this._onChangeTab.bind(this,currentPage,pageNumber)});},renderTabBar:function renderTabBar(props){if(this.props.renderTabBar===false){return null;}else if(this.props.renderTabBar){return React.cloneElement(this.props.renderTabBar(props),props);}else{return React.createElement(DefaultTabBar,_extends({},props,{__source:{fileName:_jsxFileName,lineNumber:116}}));}},updateSceneKeys:function updateSceneKeys(_ref){var page=_ref.page,_ref$children=_ref.children,children=_ref$children===undefined?this.props.children:_ref$children,_ref$callback=_ref.callback,callback=_ref$callback===undefined?function(){}:_ref$callback;var newKeys=this.newSceneKeys({previousKeys:this.state.sceneKeys,currentPage:page,children:children});this.setState({currentPage:page,sceneKeys:newKeys},callback);},newSceneKeys:function newSceneKeys(_ref2){var _this2=this;var _ref2$previousKeys=_ref2.previousKeys,previousKeys=_ref2$previousKeys===undefined?[]:_ref2$previousKeys,_ref2$currentPage=_ref2.currentPage,currentPage=_ref2$currentPage===undefined?0:_ref2$currentPage,_ref2$children=_ref2.children,children=_ref2$children===undefined?this.props.children:_ref2$children;var newKeys=[];this._children(children).forEach(function(child,idx){var key=_this2._makeSceneKey(child,idx);if(_this2._keyExists(previousKeys,key)||_this2._shouldRenderSceneKey(idx,currentPage)){newKeys.push(key);}});return newKeys;},_shouldRenderSceneKey:function _shouldRenderSceneKey(idx,currentPageKey){var numOfSibling=this.props.prerenderingSiblingsNumber;return idx<currentPageKey+numOfSibling+1&&idx>currentPageKey-numOfSibling-1;},_keyExists:function _keyExists(sceneKeys,key){return sceneKeys.find(function(sceneKey){return key===sceneKey;});},_makeSceneKey:function _makeSceneKey(child,idx){return child.props.heading+"_"+idx;},renderScrollableContent:function renderScrollableContent(){var _this3=this;var scenes=this._composeScenes();return React.createElement(ScrollView,_extends({horizontal:true,pagingEnabled:true,automaticallyAdjustContentInsets:false,keyboardShouldPersistTaps:"handled",contentOffset:{x:this.props.initialPage*this.state.containerWidth},ref:function ref(scrollView){_this3.scrollView=scrollView;},onScroll:function onScroll(e){var offsetX=e.nativeEvent.contentOffset.x;_this3._updateScrollValue(offsetX/_this3.state.containerWidth);},onMomentumScrollBegin:this._onMomentumScrollBeginAndEnd,onMomentumScrollEnd:this._onMomentumScrollBeginAndEnd,scrollEventThrottle:16,scrollsToTop:false,showsHorizontalScrollIndicator:false,scrollEnabled:!this.props.locked,directionalLockEnabled:true,alwaysBounceVertical:false,keyboardDismissMode:"on-drag"},this.props.contentProps,{__source:{fileName:_jsxFileName,lineNumber:170}}),scenes);},_composeScenes:function _composeScenes(){var _this4=this;return this._children().map(function(child,idx){var key=_this4._makeSceneKey(child,idx);return React.createElement(SceneComponent,{key:child.key,shouldUpdated:_this4._shouldRenderSceneKey(idx,_this4.state.currentPage),style:{width:_this4.state.containerWidth},__source:{fileName:_jsxFileName,lineNumber:205}},_this4._keyExists(_this4.state.sceneKeys,key)?child:React.createElement(View,{heading:child.props.heading,__source:{fileName:_jsxFileName,lineNumber:216}}));});},_onMomentumScrollBeginAndEnd:function _onMomentumScrollBeginAndEnd(e){var offsetX=e.nativeEvent.contentOffset.x;var page=Math.round(offsetX/this.state.containerWidth);if(this.state.currentPage!==page){this._updateSelectedPage(page);}},_updateSelectedPage:function _updateSelectedPage(nextPage){var localNextPage=nextPage;if(typeof localNextPage==="object"){localNextPage=nextPage.nativeEvent.position;}var currentPage=this.state.currentPage;this.updateSceneKeys({page:localNextPage,callback:this._onChangeTab.bind(this,currentPage,localNextPage)});},_onChangeTab:function _onChangeTab(prevPage,currentPage){this.props.onChangeTab({i:currentPage,ref:this._children()[currentPage],from:prevPage});},_updateScrollValue:function _updateScrollValue(value){this.state.scrollValue.setValue(value);this.props.onScroll(value);},_handleLayout:function _handleLayout(e){var _this5=this;var width=e.nativeEvent.layout.width;if(Math.round(width)!==Math.round(this.state.containerWidth)){this.setState({containerWidth:width});this.requestAnimationFrame(function(){_this5.goToPage(_this5.state.currentPage);});}},_children:function _children(){var children=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.props.children;return React.Children.map(children,function(child){return child;});},render:function render(){var overlayTabs=this.props.tabBarPosition==="overlayTop"||this.props.tabBarPosition==="overlayBottom";var tabBarProps={goToPage:this.goToPage,tabs:this._children().map(function(child){return child.props.heading;}),tabStyle:this._children().map(function(child){return child.props.tabStyle;}),activeTabStyle:this._children().map(function(child){return child.props.activeTabStyle;}),textStyle:this._children().map(function(child){return child.props.textStyle;}),activeTextStyle:this._children().map(function(child){return child.props.activeTextStyle;}),tabHeaderStyle:this._children().map(function(child){return _lodash2.default.get(child.props.heading.props,"style",undefined);}),activeTab:this.state.currentPage,scrollValue:this.state.scrollValue,containerWidth:this.state.containerWidth};if(this.props.tabBarBackgroundColor){tabBarProps.backgroundColor=this.props.tabBarBackgroundColor;}if(this.props.tabBarActiveTextColor){tabBarProps.activeTextColor=this.props.tabBarActiveTextColor;}if(this.props.tabBarInactiveTextColor){tabBarProps.inactiveTextColor=this.props.tabBarInactiveTextColor;}if(this.props.tabBarTextStyle){tabBarProps.textStyle=this.props.tabBarTextStyle;}if(this.props.tabBarUnderlineStyle){tabBarProps.underlineStyle=this.props.tabBarUnderlineStyle;}if(this.props.tabContainerStyle){tabBarProps.tabContainerStyle=this.props.tabContainerStyle;}if(overlayTabs){var _tabBarProps$style;tabBarProps.style=(_tabBarProps$style={position:"absolute",left:0,right:0},_defineProperty(_tabBarProps$style,this.props.tabBarPosition==="overlayTop"?"top":"bottom",0),_defineProperty(_tabBarProps$style,"backgroundColor","rgba(255, 255, 255, 0.7)"),_tabBarProps$style);}return React.createElement(View,{style:[styles.container,this.props.style],onLayout:this._handleLayout,__source:{fileName:_jsxFileName,lineNumber:322}},(this.props.tabBarPosition==="top"||this.props.tabBarPosition==="overlayTop")&&this.renderTabBar(tabBarProps),this.renderScrollableContent(),(this.props.tabBarPosition==="bottom"||this.props.tabBarPosition==="overlayBottom")&&this.renderTabBar(tabBarProps));}});exports.default=ScrollableTabView;var styles=StyleSheet.create({container:{flex:1},scrollableContentAndroid:{flex:1}});
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f6b810f5f0d9b1a4cfabaccbcf733cafc7edff42
package.json
"react": ">=16.4.1", "react-native": ">=0.56.0"
<mask> "main": "dist/src/index.js", <mask> "typings": "./index.d.ts", <mask> "optionalDependencies": {}, <mask> "peerDependencies": { <mask> "react": ">=16.0.0-alpha.12", <mask> "react-native": ">=0.46.0" <mask> }, <mask> "readmeFilename": "README.md", <mask> "repository": { <mask> "type": "git", <mask> "url": "git+https://github.com/GeekyAnts/NativeBase.git" </s> Upgraded deps and dev-deps, compatible with RN 0.56.0 </s> remove "jest": "19.0.2", "react": "^16.0.0-alpha.12", "react-native": "^0.46.0", "react-native-vector-icons": "~4.5.0", "react-test-renderer": "^16.0.0-alpha.12" </s> add "jest": "23.3.0", "react": "16.4.1", "react-native": "0.56.0", "react-native-vector-icons": "4.6.0", "react-test-renderer": "16.4.1" </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollableTab=undefined;var _jsxFileName="src/basic/Tabs/ScrollableTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react); var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _index=require("./../../index"); var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var Button=require("./Button"); var ReactNative=require("react-native");var View= ReactNative.View,Animated=ReactNative.Animated,StyleSheet=ReactNative.StyleSheet,ScrollView=ReactNative.ScrollView,Platform=ReactNative.Platform,Dimensions=ReactNative.Dimensions; var WINDOW_WIDTH=Dimensions.get("window").width; var ScrollableTabBar=(0,_createReactClass2.default)({displayName:"ScrollableTabBar", propTypes:{ goToPage:_propTypes2.default.func, activeTab:_propTypes2.default.number, tabs:_propTypes2.default.array, backgroundColor:_propTypes2.default.string, activeTextColor:_propTypes2.default.string, inactiveTextColor:_propTypes2.default.string, scrollOffset:_propTypes2.default.number, style:_utils.ViewPropTypes.style, tabStyle:_utils.ViewPropTypes.style, tabsContainerStyle:_utils.ViewPropTypes.style, renderTab:_propTypes2.default.func, underlineStyle:_utils.ViewPropTypes.style, onScroll:_propTypes2.default.func}, contextTypes:{ theme:_propTypes2.default.object}, getDefaultProps:function getDefaultProps(){ return{ scrollOffset:52, activeTextColor:"navy", inactiveTextColor:"black", backgroundColor:_platform2.default.tabDefaultBg, style:{}, tabStyle:{}, tabsContainerStyle:{}, underlineStyle:{}, tabFontSize:_platform2.default.tabFontSize}; }, getInitialState:function getInitialState(){ this._tabsMeasurements=[]; return{ _leftTabUnderline:new Animated.Value(0), _widthTabUnderline:new Animated.Value(0), _containerWidth:null}; }, componentDidMount:function componentDidMount(){ this.props.scrollValue.addListener(this.updateView); }, updateView:function updateView(offset){ var position=Math.floor(offset.value); var pageOffset=offset.value%1; var tabCount=this.props.tabs.length; var lastTabPosition=tabCount-1; if(tabCount===0||offset.value<0||offset.value>lastTabPosition){ return; } if( this.necessarilyMeasurementsCompleted( position, position===lastTabPosition)) { this.updateTabPanel(position,pageOffset); this.updateTabUnderline(position,pageOffset,tabCount); } }, necessarilyMeasurementsCompleted:function necessarilyMeasurementsCompleted(position,isLastTab){ return( this._tabsMeasurements[position]&&( isLastTab||this._tabsMeasurements[position+1])&& this._tabContainerMeasurements&& this._containerMeasurements); }, updateTabPanel:function updateTabPanel(position,pageOffset){ var containerWidth=this._containerMeasurements.width; var tabWidth=this._tabsMeasurements[position].width; var nextTabMeasurements=this._tabsMeasurements[position+1]; var nextTabWidth= nextTabMeasurements&&nextTabMeasurements.width||0; var tabOffset=this._tabsMeasurements[position].left; var absolutePageOffset=pageOffset*tabWidth; var newScrollX=tabOffset+absolutePageOffset; newScrollX-= (containerWidth- (1-pageOffset)*tabWidth- pageOffset*nextTabWidth)/ 2; newScrollX=newScrollX>=0?newScrollX:0; if(Platform.OS==="android"){ this._scrollView.scrollTo({x:newScrollX,y:0,animated:false}); }else{ var rightBoundScroll= this._tabContainerMeasurements.width- this._containerMeasurements.width; newScrollX= newScrollX>rightBoundScroll?rightBoundScroll:newScrollX; this._scrollView.scrollTo({x:newScrollX,y:0,animated:false}); } }, updateTabUnderline:function updateTabUnderline(position,pageOffset,tabCount){ var lineLeft=this._tabsMeasurements[position].left; var lineRight=this._tabsMeasurements[position].right; if(position<tabCount-1){ var nextTabLeft=this._tabsMeasurements[position+1].left; var nextTabRight=this._tabsMeasurements[position+1].right; var newLineLeft= pageOffset*nextTabLeft+(1-pageOffset)*lineLeft; var newLineRight= pageOffset*nextTabRight+(1-pageOffset)*lineRight; this.state._leftTabUnderline.setValue(newLineLeft); this.state._widthTabUnderline.setValue(newLineRight-newLineLeft); }else{ this.state._leftTabUnderline.setValue(lineLeft); this.state._widthTabUnderline.setValue(lineRight-lineLeft); } }, renderTab:function renderTab( name, page, isTabActive, onPressHandler, onLayoutHandler, tabStyle, activeTabStyle, textStyle, activeTextStyle, tabHeaderStyle) { var headerContent= typeof name!=="string"?name.props.children:undefined;var _props= this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize; var textColor=isTabActive?activeTextColor:inactiveTextColor; var fontWeight=isTabActive?"bold":"normal"; var fontSize=tabFontSize; if(typeof name==="string"){ return( _react2.default.createElement(Button,{ key:name+"_"+page, onPress:function onPress(){return onPressHandler(page);}, onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:172}}, _react2.default.createElement(_index.TabHeading,{ scrollable:true, style:isTabActive?activeTabStyle:tabStyle, active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:177}}, _react2.default.createElement(_index.Text,{ style:[ isTabActive?activeTextStyle:textStyle, {fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:182}}, name)))); }else{ return( _react2.default.createElement(Button,{ key:_lodash2.default.random(1.2,5.2), onPress:function onPress(){return onPressHandler(page);}, onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:195}}, _react2.default.createElement(_index.TabHeading,{scrollable:true,style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:200}}, headerContent))); } }, measureTab:function measureTab(page,event){var _event$nativeEvent$la= event.nativeEvent.layout,x=_event$nativeEvent$la.x,width=_event$nativeEvent$la.width,height=_event$nativeEvent$la.height; this._tabsMeasurements[page]={left:x,right:x+width,width:width,height:height}; this.updateView({value:this.props.scrollValue._value}); }, render:function render(){var _this=this; var variables=this.context.theme? this.context.theme["@@shoutem.theme/themeStyle"].variables: _platform2.default; var tabUnderlineStyle={ position:"absolute", height:4, backgroundColor:variables.topTabBarActiveBorderColor, bottom:0}; var dynamicTabUnderline={ left:this.state._leftTabUnderline, width:this.state._widthTabUnderline}; return( _react2.default.createElement(View,{ style:[ styles.container, {backgroundColor:this.props.backgroundColor}, this.props.style], onLayout:this.onContainerLayout,__source:{fileName:_jsxFileName,lineNumber:231}}, _react2.default.createElement(ScrollView,{ automaticallyAdjustContentInsets:false, ref:function ref(scrollView){ _this._scrollView=scrollView; }, horizontal:true, showsHorizontalScrollIndicator:false, showsVerticalScrollIndicator:false, directionalLockEnabled:true, onScroll:this.props.onScroll, bounces:false, scrollsToTop:false,__source:{fileName:_jsxFileName,lineNumber:239}}, _react2.default.createElement(View,{ style:[ styles.tabs, {width:this.state._containerWidth}, this.props.tabsContainerStyle], ref:"tabContainer", onLayout:this.onTabContainerLayout,__source:{fileName:_jsxFileName,lineNumber:252}}, this.props.tabs.map(function(name,page){ var isTabActive=_this.props.activeTab===page; var renderTab=_this.props.renderTab||_this.renderTab; return renderTab( name, page, isTabActive, _this.props.goToPage, _this.measureTab.bind(_this,page), _this.props.tabStyle[page], _this.props.activeTabStyle[page], _this.props.textStyle[page], _this.props.activeTextStyle[page], _this.props.tabHeaderStyle[page]); }), _react2.default.createElement(Animated.View,{ style:[ tabUnderlineStyle, dynamicTabUnderline, this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:277}}))))); }, componentWillReceiveProps:function componentWillReceiveProps(nextProps){ if( !_lodash2.default.isEqual(this.props.tabs,nextProps.tabs)&& this.state._containerWidth) { this.setState({_containerWidth:null}); } }, onTabContainerLayout:function onTabContainerLayout(e){ this._tabContainerMeasurements=e.nativeEvent.layout; var width=this._tabContainerMeasurements.width; if(width<WINDOW_WIDTH){ width=WINDOW_WIDTH; } this.setState({_containerWidth:width}); this.updateView({value:this.props.scrollValue._value}); }, onContainerLayout:function onContainerLayout(e){ this._containerMeasurements=e.nativeEvent.layout; this.updateView({value:this.props.scrollValue._value}); }}); var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)( "NativeBase.ScrollableTab", {}, _mapPropsToStyleNames2.default)( ScrollableTabBar);exports. ScrollableTab=StyledTab; var styles=StyleSheet.create({ tab:{ height:49, alignItems:"center", justifyContent:"center", paddingLeft:20, paddingRight:20}, container:{ height:50, borderWidth:1, borderTopWidth:0, borderLeftWidth:0, borderRightWidth:0, borderColor:"#ccc"}, tabs:{ flexDirection:"row", justifyContent:"space-around"}}); </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.ScrollableTab=undefined;var _jsxFileName="src/basic/Tabs/ScrollableTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _index=require("./../../index");var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var Button=require("./Button");var ReactNative=require("react-native");var View=ReactNative.View,Animated=ReactNative.Animated,StyleSheet=ReactNative.StyleSheet,ScrollView=ReactNative.ScrollView,Platform=ReactNative.Platform,Dimensions=ReactNative.Dimensions;var WINDOW_WIDTH=Dimensions.get("window").width;var ScrollableTabBar=(0,_createReactClass2.default)({displayName:"ScrollableTabBar",propTypes:{goToPage:_propTypes2.default.func,activeTab:_propTypes2.default.number,tabs:_propTypes2.default.array,backgroundColor:_propTypes2.default.string,activeTextColor:_propTypes2.default.string,inactiveTextColor:_propTypes2.default.string,scrollOffset:_propTypes2.default.number,style:_utils.ViewPropTypes.style,tabStyle:_utils.ViewPropTypes.style,tabsContainerStyle:_utils.ViewPropTypes.style,renderTab:_propTypes2.default.func,underlineStyle:_utils.ViewPropTypes.style,onScroll:_propTypes2.default.func},contextTypes:{theme:_propTypes2.default.object},getDefaultProps:function getDefaultProps(){return{scrollOffset:52,activeTextColor:"navy",inactiveTextColor:"black",backgroundColor:_platform2.default.tabDefaultBg,style:{},tabStyle:{},tabsContainerStyle:{},underlineStyle:{},tabFontSize:_platform2.default.tabFontSize};},getInitialState:function getInitialState(){this._tabsMeasurements=[];return{_leftTabUnderline:new Animated.Value(0),_widthTabUnderline:new Animated.Value(0),_containerWidth:null};},componentDidMount:function componentDidMount(){this.props.scrollValue.addListener(this.updateView);},updateView:function updateView(offset){var position=Math.floor(offset.value);var pageOffset=offset.value%1;var tabCount=this.props.tabs.length;var lastTabPosition=tabCount-1;if(tabCount===0||offset.value<0||offset.value>lastTabPosition){return;}if(this.necessarilyMeasurementsCompleted(position,position===lastTabPosition)){this.updateTabPanel(position,pageOffset);this.updateTabUnderline(position,pageOffset,tabCount);}},necessarilyMeasurementsCompleted:function necessarilyMeasurementsCompleted(position,isLastTab){return this._tabsMeasurements[position]&&(isLastTab||this._tabsMeasurements[position+1])&&this._tabContainerMeasurements&&this._containerMeasurements;},updateTabPanel:function updateTabPanel(position,pageOffset){var containerWidth=this._containerMeasurements.width;var tabWidth=this._tabsMeasurements[position].width;var nextTabMeasurements=this._tabsMeasurements[position+1];var nextTabWidth=nextTabMeasurements&&nextTabMeasurements.width||0;var tabOffset=this._tabsMeasurements[position].left;var absolutePageOffset=pageOffset*tabWidth;var newScrollX=tabOffset+absolutePageOffset;newScrollX-=(containerWidth-(1-pageOffset)*tabWidth-pageOffset*nextTabWidth)/2;newScrollX=newScrollX>=0?newScrollX:0;if(Platform.OS==="android"){this._scrollView.scrollTo({x:newScrollX,y:0,animated:false});}else{var rightBoundScroll=this._tabContainerMeasurements.width-this._containerMeasurements.width;newScrollX=newScrollX>rightBoundScroll?rightBoundScroll:newScrollX;this._scrollView.scrollTo({x:newScrollX,y:0,animated:false});}},updateTabUnderline:function updateTabUnderline(position,pageOffset,tabCount){var lineLeft=this._tabsMeasurements[position].left;var lineRight=this._tabsMeasurements[position].right;if(position<tabCount-1){var nextTabLeft=this._tabsMeasurements[position+1].left;var nextTabRight=this._tabsMeasurements[position+1].right;var newLineLeft=pageOffset*nextTabLeft+(1-pageOffset)*lineLeft;var newLineRight=pageOffset*nextTabRight+(1-pageOffset)*lineRight;this.state._leftTabUnderline.setValue(newLineLeft);this.state._widthTabUnderline.setValue(newLineRight-newLineLeft);}else{this.state._leftTabUnderline.setValue(lineLeft);this.state._widthTabUnderline.setValue(lineRight-lineLeft);}},renderTab:function renderTab(name,page,isTabActive,onPressHandler,onLayoutHandler,tabStyle,activeTabStyle,textStyle,activeTextStyle,tabHeaderStyle){var headerContent=typeof name!=="string"?name.props.children:undefined;var _props=this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize;var textColor=isTabActive?activeTextColor:inactiveTextColor;var fontWeight=isTabActive?"bold":"normal";var fontSize=tabFontSize;if(typeof name==="string"){return _react2.default.createElement(Button,{key:name+"_"+page,onPress:function onPress(){return onPressHandler(page);},onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:172}},_react2.default.createElement(_index.TabHeading,{scrollable:true,style:isTabActive?activeTabStyle:tabStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:177}},_react2.default.createElement(_index.Text,{style:[isTabActive?activeTextStyle:textStyle,{fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:182}},name)));}else{return _react2.default.createElement(Button,{key:_lodash2.default.random(1.2,5.2),onPress:function onPress(){return onPressHandler(page);},onLayout:onLayoutHandler,__source:{fileName:_jsxFileName,lineNumber:195}},_react2.default.createElement(_index.TabHeading,{scrollable:true,style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:200}},headerContent));}},measureTab:function measureTab(page,event){var _event$nativeEvent$la=event.nativeEvent.layout,x=_event$nativeEvent$la.x,width=_event$nativeEvent$la.width,height=_event$nativeEvent$la.height;this._tabsMeasurements[page]={left:x,right:x+width,width:width,height:height};this.updateView({value:this.props.scrollValue._value});},render:function render(){var _this=this;var variables=this.context.theme?this.context.theme["@@shoutem.theme/themeStyle"].variables:_platform2.default;var tabUnderlineStyle={position:"absolute",height:4,backgroundColor:variables.topTabBarActiveBorderColor,bottom:0};var dynamicTabUnderline={left:this.state._leftTabUnderline,width:this.state._widthTabUnderline};return _react2.default.createElement(View,{style:[styles.container,{backgroundColor:this.props.backgroundColor},this.props.style],onLayout:this.onContainerLayout,__source:{fileName:_jsxFileName,lineNumber:231}},_react2.default.createElement(ScrollView,{automaticallyAdjustContentInsets:false,ref:function ref(scrollView){_this._scrollView=scrollView;},horizontal:true,showsHorizontalScrollIndicator:false,showsVerticalScrollIndicator:false,directionalLockEnabled:true,onScroll:this.props.onScroll,bounces:false,scrollsToTop:false,__source:{fileName:_jsxFileName,lineNumber:239}},_react2.default.createElement(View,{style:[styles.tabs,{width:this.state._containerWidth},this.props.tabsContainerStyle],ref:"tabContainer",onLayout:this.onTabContainerLayout,__source:{fileName:_jsxFileName,lineNumber:252}},this.props.tabs.map(function(name,page){var isTabActive=_this.props.activeTab===page;var renderTab=_this.props.renderTab||_this.renderTab;return renderTab(name,page,isTabActive,_this.props.goToPage,_this.measureTab.bind(_this,page),_this.props.tabStyle[page],_this.props.activeTabStyle[page],_this.props.textStyle[page],_this.props.activeTextStyle[page],_this.props.tabHeaderStyle[page]);}),_react2.default.createElement(Animated.View,{style:[tabUnderlineStyle,dynamicTabUnderline,this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:277}}))));},componentWillReceiveProps:function componentWillReceiveProps(nextProps){if(!_lodash2.default.isEqual(this.props.tabs,nextProps.tabs)&&this.state._containerWidth){this.setState({_containerWidth:null});}},onTabContainerLayout:function onTabContainerLayout(e){this._tabContainerMeasurements=e.nativeEvent.layout;var width=this._tabContainerMeasurements.width;if(width<WINDOW_WIDTH){width=WINDOW_WIDTH;}this.setState({_containerWidth:width});this.updateView({value:this.props.scrollValue._value});},onContainerLayout:function onContainerLayout(e){this._containerMeasurements=e.nativeEvent.layout;this.updateView({value:this.props.scrollValue._value});}});var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.ScrollableTab",{},_mapPropsToStyleNames2.default)(ScrollableTabBar);exports.ScrollableTab=StyledTab;var styles=StyleSheet.create({tab:{height:49,alignItems:"center",justifyContent:"center",paddingLeft:20,paddingRight:20},container:{height:50,borderWidth:1,borderTopWidth:0,borderLeftWidth:0,borderRightWidth:0,borderColor:"#ccc"},tabs:{flexDirection:"row",justifyContent:"space-around"}}); </s> remove "babel-jest": "^16.0.0", "babel-preset-react-native": "^1.9.2", </s> add "babel-jest": "23.2.0", "babel-preset-react-native": "4.0.0", </s> remove Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color); var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var deviceHeight=_reactNative.Dimensions.get("window").height; var deviceWidth=_reactNative.Dimensions.get("window").width; var platform=_reactNative.Platform.OS; var platformStyle=undefined; var isIphoneX= platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default= { platformStyle:platformStyle, platform:platform, headerStyle:"#edebed", iconStyle:"#000", contentStyle:"#f5f4f5", expandedIconStyle:"#000", accordionBorderColor:"#d3d3d3", androidRipple:true, androidRippleColor:"rgba(256, 256, 256, 0.3)", androidRippleColorDark:"rgba(0, 0, 0, 0.15)", btnUppercaseAndroidText:true, badgeBg:"#ED1727", badgeColor:"#fff", badgePadding:platform==="ios"?3:0, btnFontFamily:platform==="ios"?"System":"Roboto_medium", btnDisabledBg:"#b5b5b5", buttonPadding:6, get btnPrimaryBg(){ return this.brandPrimary; }, get btnPrimaryColor(){ return this.inverseTextColor; }, get btnInfoBg(){ return this.brandInfo; }, get btnInfoColor(){ return this.inverseTextColor; }, get btnSuccessBg(){ return this.brandSuccess; }, get btnSuccessColor(){ return this.inverseTextColor; }, get btnDangerBg(){ return this.brandDanger; }, get btnDangerColor(){ return this.inverseTextColor; }, get btnWarningBg(){ return this.brandWarning; }, get btnWarningColor(){ return this.inverseTextColor; }, get btnTextSize(){ return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1; }, get btnTextSizeLarge(){ return this.fontSizeBase*1.5; }, get btnTextSizeSmall(){ return this.fontSizeBase*0.8; }, get borderRadiusLarge(){ return this.fontSizeBase*3.8; }, get iconSizeLarge(){ return this.iconFontSize*1.5; }, get iconSizeSmall(){ return this.iconFontSize*0.6; }, cardDefaultBg:"#fff", cardBorderColor:"#ccc", cardBorderRadius:2, cardItemPadding:platform==="ios"?10:12, CheckboxRadius:platform==="ios"?13:0, CheckboxBorderWidth:platform==="ios"?1:2, CheckboxPaddingLeft:platform==="ios"?4:2, CheckboxPaddingBottom:platform==="ios"?0:5, CheckboxIconSize:platform==="ios"?21:16, CheckboxIconMarginTop:platform==="ios"?undefined:1, CheckboxFontSize:platform==="ios"?23/0.9:17, checkboxBgColor:"#039BE5", checkboxSize:20, checkboxTickColor:"#fff", brandPrimary:platform==="ios"?"#007aff":"#3F51B5", brandInfo:"#62B1F6", brandSuccess:"#5cb85c", brandDanger:"#d9534f", brandWarning:"#f0ad4e", brandDark:"#000", brandLight:"#f4f4f4", datePickerTextColor:"#000", datePickerBg:"transparent", DefaultFontSize:16, fontFamily:platform==="ios"?"System":"Roboto", fontSizeBase:15, get fontSizeH1(){ return this.fontSizeBase*1.8; }, get fontSizeH2(){ return this.fontSizeBase*1.6; }, get fontSizeH3(){ return this.fontSizeBase*1.4; }, footerHeight:55, footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", footerPaddingBottom:0, tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", tabBarTextSize:platform==="ios"?14:11, activeTab:platform==="ios"?"#007aff":"#fff", sTabBarActiveTextColor:"#007aff", tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5", toolbarBtnColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", toolbarHeight:platform==="ios"?64:56, toolbarSearchIconSize:platform==="ios"?20:23, toolbarInputColor:platform==="ios"?"#CECDD2":"#fff", searchBarHeight:platform==="ios"?30:40, searchBarInputHeight:platform==="ios"?30:50, toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff", toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5", iosStatusbar:platform==="ios"?"dark-content":"light-content", get statusBarColor(){ return(0,_color2.default)(this.toolbarDefaultBg). darken(0.2). hex(); }, get darkenHeader(){ return(0,_color2.default)(this.tabBgColor). darken(0.03). hex(); }, iconFamily:"Ionicons", iconFontSize:platform==="ios"?30:28, iconHeaderSize:platform==="ios"?33:24, inputFontSize:17, inputBorderColor:"#D9D5DC", inputSuccessBorderColor:"#2b8339", inputErrorBorderColor:"#ed2f2f", inputHeightBase:50, get inputColor(){ return this.textColor; }, get inputColorPlaceholder(){ return"#575757"; }, btnLineHeight:19, lineHeightH1:32, lineHeightH2:27, lineHeightH3:22, lineHeight:platform==="ios"?20:24, listItemSelected:platform==="ios"?"#007aff":"#3F51B5", listBg:"transparent", listBorderColor:"#c9c9c9", listDividerBg:"#f4f4f4", listBtnUnderlayColor:"#DDD", listItemPadding:platform==="ios"?10:12, listNoteColor:"#808080", listNoteSize:13, defaultProgressColor:"#E4202D", inverseProgressColor:"#1A191B", radioBtnSize:platform==="ios"?25:23, radioSelectedColorAndroid:"#3F51B5", radioBtnLineHeight:platform==="ios"?29:24, get radioColor(){ return this.brandPrimary; }, segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5", segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff", segmentTextColor:platform==="ios"?"#007aff":"#fff", segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5", segmentBorderColor:platform==="ios"?"#007aff":"#fff", segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5", defaultSpinnerColor:"#45D56E", inverseSpinnerColor:"#1A191B", tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5", topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9", topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff", topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff", topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff", tabBgColor:"#F8F8F8", tabFontSize:15, textColor:"#000", inverseTextColor:"#fff", noteFontSize:14, get defaultTextColor(){ return this.textColor; }, titleFontfamily:platform==="ios"?"System":"Roboto_medium", titleFontSize:platform==="ios"?17:19, subTitleFontSize:platform==="ios"?11:14, subtitleColor:platform==="ios"?"#8e8e93":"#FFF", titleFontColor:platform==="ios"?"#000":"#FFF", borderRadiusBase:platform==="ios"?5:2, borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1), contentPadding:10, dropdownLinkColor:"#414142", inputLineHeight:24, deviceWidth:deviceWidth, deviceHeight:deviceHeight, isIphoneX:isIphoneX, inputGroupRoundedBorderRadius:30, Inset:{ portrait:{ topInset:24, leftInset:0, rightInset:0, bottomInset:34}, landscape:{ topInset:0, leftInset:44, rightInset:44, bottomInset:21}}}; </s> add Object.defineProperty(exports,"__esModule",{value:true});var _color=require("color");var _color2=_interopRequireDefault(_color);var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var deviceHeight=_reactNative.Dimensions.get("window").height;var deviceWidth=_reactNative.Dimensions.get("window").width;var platform=_reactNative.Platform.OS;var platformStyle=undefined;var isIphoneX=platform==="ios"&&(deviceHeight===812||deviceWidth===812);exports.default={platformStyle:platformStyle,platform:platform,headerStyle:"#edebed",iconStyle:"#000",contentStyle:"#f5f4f5",expandedIconStyle:"#000",accordionBorderColor:"#d3d3d3",androidRipple:true,androidRippleColor:"rgba(256, 256, 256, 0.3)",androidRippleColorDark:"rgba(0, 0, 0, 0.15)",btnUppercaseAndroidText:true,badgeBg:"#ED1727",badgeColor:"#fff",badgePadding:platform==="ios"?3:0,btnFontFamily:platform==="ios"?"System":"Roboto_medium",btnDisabledBg:"#b5b5b5",buttonPadding:6,get btnPrimaryBg(){return this.brandPrimary;},get btnPrimaryColor(){return this.inverseTextColor;},get btnInfoBg(){return this.brandInfo;},get btnInfoColor(){return this.inverseTextColor;},get btnSuccessBg(){return this.brandSuccess;},get btnSuccessColor(){return this.inverseTextColor;},get btnDangerBg(){return this.brandDanger;},get btnDangerColor(){return this.inverseTextColor;},get btnWarningBg(){return this.brandWarning;},get btnWarningColor(){return this.inverseTextColor;},get btnTextSize(){return platform==="ios"?this.fontSizeBase*1.1:this.fontSizeBase-1;},get btnTextSizeLarge(){return this.fontSizeBase*1.5;},get btnTextSizeSmall(){return this.fontSizeBase*0.8;},get borderRadiusLarge(){return this.fontSizeBase*3.8;},get iconSizeLarge(){return this.iconFontSize*1.5;},get iconSizeSmall(){return this.iconFontSize*0.6;},cardDefaultBg:"#fff",cardBorderColor:"#ccc",cardBorderRadius:2,cardItemPadding:platform==="ios"?10:12,CheckboxRadius:platform==="ios"?13:0,CheckboxBorderWidth:platform==="ios"?1:2,CheckboxPaddingLeft:platform==="ios"?4:2,CheckboxPaddingBottom:platform==="ios"?0:5,CheckboxIconSize:platform==="ios"?21:16,CheckboxIconMarginTop:platform==="ios"?undefined:1,CheckboxFontSize:platform==="ios"?23/0.9:17,checkboxBgColor:"#039BE5",checkboxSize:20,checkboxTickColor:"#fff",brandPrimary:platform==="ios"?"#007aff":"#3F51B5",brandInfo:"#62B1F6",brandSuccess:"#5cb85c",brandDanger:"#d9534f",brandWarning:"#f0ad4e",brandDark:"#000",brandLight:"#f4f4f4",datePickerTextColor:"#000",datePickerBg:"transparent",DefaultFontSize:16,fontFamily:platform==="ios"?"System":"Roboto",fontSizeBase:15,get fontSizeH1(){return this.fontSizeBase*1.8;},get fontSizeH2(){return this.fontSizeBase*1.6;},get fontSizeH3(){return this.fontSizeBase*1.4;},footerHeight:55,footerDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",footerPaddingBottom:0,tabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",tabBarTextSize:platform==="ios"?14:11,activeTab:platform==="ios"?"#007aff":"#fff",sTabBarActiveTextColor:"#007aff",tabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",tabActiveBgColor:platform==="ios"?"#cde1f9":"#3F51B5",toolbarBtnColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",toolbarHeight:platform==="ios"?64:56,toolbarSearchIconSize:platform==="ios"?20:23,toolbarInputColor:platform==="ios"?"#CECDD2":"#fff",searchBarHeight:platform==="ios"?30:40,searchBarInputHeight:platform==="ios"?30:50,toolbarBtnTextColor:platform==="ios"?"#007aff":"#fff",toolbarDefaultBorder:platform==="ios"?"#a7a6ab":"#3F51B5",iosStatusbar:platform==="ios"?"dark-content":"light-content",get statusBarColor(){return(0,_color2.default)(this.toolbarDefaultBg).darken(0.2).hex();},get darkenHeader(){return(0,_color2.default)(this.tabBgColor).darken(0.03).hex();},iconFamily:"Ionicons",iconFontSize:platform==="ios"?30:28,iconHeaderSize:platform==="ios"?33:24,inputFontSize:17,inputBorderColor:"#D9D5DC",inputSuccessBorderColor:"#2b8339",inputErrorBorderColor:"#ed2f2f",inputHeightBase:50,get inputColor(){return this.textColor;},get inputColorPlaceholder(){return"#575757";},btnLineHeight:19,lineHeightH1:32,lineHeightH2:27,lineHeightH3:22,lineHeight:platform==="ios"?20:24,listItemSelected:platform==="ios"?"#007aff":"#3F51B5",listBg:"transparent",listBorderColor:"#c9c9c9",listDividerBg:"#f4f4f4",listBtnUnderlayColor:"#DDD",listItemPadding:platform==="ios"?10:12,listNoteColor:"#808080",listNoteSize:13,defaultProgressColor:"#E4202D",inverseProgressColor:"#1A191B",radioBtnSize:platform==="ios"?25:23,radioSelectedColorAndroid:"#3F51B5",radioBtnLineHeight:platform==="ios"?29:24,get radioColor(){return this.brandPrimary;},segmentBackgroundColor:platform==="ios"?"#F8F8F8":"#3F51B5",segmentActiveBackgroundColor:platform==="ios"?"#007aff":"#fff",segmentTextColor:platform==="ios"?"#007aff":"#fff",segmentActiveTextColor:platform==="ios"?"#fff":"#3F51B5",segmentBorderColor:platform==="ios"?"#007aff":"#fff",segmentBorderColorMain:platform==="ios"?"#a7a6ab":"#3F51B5",defaultSpinnerColor:"#45D56E",inverseSpinnerColor:"#1A191B",tabDefaultBg:platform==="ios"?"#F8F8F8":"#3F51B5",topTabBarTextColor:platform==="ios"?"#6b6b6b":"#b3c7f9",topTabBarActiveTextColor:platform==="ios"?"#007aff":"#fff",topTabBarBorderColor:platform==="ios"?"#a7a6ab":"#fff",topTabBarActiveBorderColor:platform==="ios"?"#007aff":"#fff",tabBgColor:"#F8F8F8",tabFontSize:15,textColor:"#000",inverseTextColor:"#fff",noteFontSize:14,get defaultTextColor(){return this.textColor;},titleFontfamily:platform==="ios"?"System":"Roboto_medium",titleFontSize:platform==="ios"?17:19,subTitleFontSize:platform==="ios"?11:14,subtitleColor:platform==="ios"?"#8e8e93":"#FFF",titleFontColor:platform==="ios"?"#000":"#FFF",borderRadiusBase:platform==="ios"?5:2,borderWidth:1/_reactNative.PixelRatio.getPixelSizeForLayoutSize(1),contentPadding:10,dropdownLinkColor:"#414142",inputLineHeight:24,deviceWidth:deviceWidth,deviceHeight:deviceHeight,isIphoneX:isIphoneX,inputGroupRoundedBorderRadius:30,Inset:{portrait:{topInset:24,leftInset:0,rightInset:0,bottomInset:34},landscape:{topInset:0,leftInset:44,rightInset:44,bottomInset:21}}}; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.DefaultTabBar=undefined;var _jsxFileName="src/basic/Tabs/DefaultTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react); var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _index=require("./../../index"); var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} var ReactNative=require("react-native");var StyleSheet=ReactNative.StyleSheet,View=ReactNative.View,Animated=ReactNative.Animated,Platform=ReactNative.Platform; var Button=require("./Button"); var DefaultTabBar=(0,_createReactClass2.default)({displayName:"DefaultTabBar", propTypes:{ goToPage:_propTypes2.default.func, activeTab:_propTypes2.default.number, tabs:_propTypes2.default.array, backgroundColor:_propTypes2.default.string, activeTextColor:_propTypes2.default.string, inactiveTextColor:_propTypes2.default.string, tabStyle:_utils.ViewPropTypes.style, renderTab:_propTypes2.default.func, underlineStyle:_utils.ViewPropTypes.style, tabContainerStyle:_utils.ViewPropTypes.style}, contextTypes:{ theme:_propTypes2.default.object}, getDefaultProps:function getDefaultProps(){ return{ activeTextColor:_platform2.default.topTabBarActiveTextColor, inactiveTextColor:_platform2.default.topTabBarTextColor, backgroundColor:null, tabFontSize:_platform2.default.tabFontSize}; }, renderTabOption:function renderTabOption(name,page){}, renderTab:function renderTab( name, page, isTabActive, onPressHandler, tabStyle, activeTabStyle, textStyle, activeTextStyle, tabHeaderStyle) { var headerContent= typeof name!=="string"?name.props.children:undefined;var _props= this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize; var textColor=isTabActive?activeTextColor:inactiveTextColor; var fontWeight=isTabActive?"bold":"normal"; var fontSize=tabFontSize; if(typeof name==="string"){ return( _react2.default.createElement(Button,{ style:{flex:1}, key:name, onPress:function onPress(){return onPressHandler(page);},__source:{fileName:_jsxFileName,lineNumber:62}}, _react2.default.createElement(_index.TabHeading,{ style:isTabActive?activeTabStyle:tabStyle, active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:67}}, _react2.default.createElement(_index.Text,{ style:[ isTabActive?activeTextStyle:textStyle, {fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:71}}, name)))); }else{ return( _react2.default.createElement(Button,{ style:{flex:1}, key:_lodash2.default.random(1.2,5.2), onPress:function onPress(){return onPressHandler(page);},__source:{fileName:_jsxFileName,lineNumber:84}}, _react2.default.createElement(_index.TabHeading,{style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:89}}, headerContent))); } }, render:function render(){var _this=this; var variables=this.context.theme? this.context.theme["@@shoutem.theme/themeStyle"].variables: _platform2.default; var platformStyle=variables.platformStyle; var containerWidth=this.props.containerWidth; var numberOfTabs=this.props.tabs.length; var tabUnderlineStyle={ position:"absolute", width:containerWidth/numberOfTabs, height:4, backgroundColor:variables.topTabBarActiveBorderColor, bottom:0}; var left=this.props.scrollValue.interpolate({ inputRange:[0,1], outputRange:[0,containerWidth/numberOfTabs]}); return( _react2.default.createElement(_index.TabContainer,{ style:[ {backgroundColor:variables.tabDefaultBg}, this.props.tabContainerStyle?this.props.tabContainerStyle:{}],__source:{fileName:_jsxFileName,lineNumber:117}}, this.props.tabs.map(function(name,page){ var isTabActive=_this.props.activeTab===page; var renderTab=_this.props.renderTab||_this.renderTab; return renderTab( name, page, isTabActive, _this.props.goToPage, _this.props.tabStyle[page], _this.props.activeTabStyle[page], _this.props.textStyle[page], _this.props.activeTextStyle[page], _this.props.tabHeaderStyle[page]); }), _react2.default.createElement(Animated.View,{ style:[tabUnderlineStyle,{left:left},this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:138}}))); }}); var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)( "NativeBase.DefaultTabBar", {}, _mapPropsToStyleNames2.default)( DefaultTabBar);exports. DefaultTabBar=StyledTab; </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.DefaultTabBar=undefined;var _jsxFileName="src/basic/Tabs/DefaultTabBar.js";var _react=require("react");var _react2=_interopRequireDefault(_react);var _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _createReactClass=require("create-react-class");var _createReactClass2=_interopRequireDefault(_createReactClass);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _mapPropsToStyleNames=require("../../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _platform=require("./../../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _index=require("./../../index");var _utils=require("../../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var ReactNative=require("react-native");var StyleSheet=ReactNative.StyleSheet,View=ReactNative.View,Animated=ReactNative.Animated,Platform=ReactNative.Platform;var Button=require("./Button");var DefaultTabBar=(0,_createReactClass2.default)({displayName:"DefaultTabBar",propTypes:{goToPage:_propTypes2.default.func,activeTab:_propTypes2.default.number,tabs:_propTypes2.default.array,backgroundColor:_propTypes2.default.string,activeTextColor:_propTypes2.default.string,inactiveTextColor:_propTypes2.default.string,tabStyle:_utils.ViewPropTypes.style,renderTab:_propTypes2.default.func,underlineStyle:_utils.ViewPropTypes.style,tabContainerStyle:_utils.ViewPropTypes.style},contextTypes:{theme:_propTypes2.default.object},getDefaultProps:function getDefaultProps(){return{activeTextColor:_platform2.default.topTabBarActiveTextColor,inactiveTextColor:_platform2.default.topTabBarTextColor,backgroundColor:null,tabFontSize:_platform2.default.tabFontSize};},renderTabOption:function renderTabOption(name,page){},renderTab:function renderTab(name,page,isTabActive,onPressHandler,tabStyle,activeTabStyle,textStyle,activeTextStyle,tabHeaderStyle){var headerContent=typeof name!=="string"?name.props.children:undefined;var _props=this.props,activeTextColor=_props.activeTextColor,inactiveTextColor=_props.inactiveTextColor,tabFontSize=_props.tabFontSize;var textColor=isTabActive?activeTextColor:inactiveTextColor;var fontWeight=isTabActive?"bold":"normal";var fontSize=tabFontSize;if(typeof name==="string"){return _react2.default.createElement(Button,{style:{flex:1},key:name,onPress:function onPress(){return onPressHandler(page);},__source:{fileName:_jsxFileName,lineNumber:62}},_react2.default.createElement(_index.TabHeading,{style:isTabActive?activeTabStyle:tabStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:67}},_react2.default.createElement(_index.Text,{style:[isTabActive?activeTextStyle:textStyle,{fontSize:tabFontSize}],__source:{fileName:_jsxFileName,lineNumber:71}},name)));}else{return _react2.default.createElement(Button,{style:{flex:1},key:_lodash2.default.random(1.2,5.2),onPress:function onPress(){return onPressHandler(page);},__source:{fileName:_jsxFileName,lineNumber:84}},_react2.default.createElement(_index.TabHeading,{style:tabHeaderStyle,active:isTabActive,__source:{fileName:_jsxFileName,lineNumber:89}},headerContent));}},render:function render(){var _this=this;var variables=this.context.theme?this.context.theme["@@shoutem.theme/themeStyle"].variables:_platform2.default;var platformStyle=variables.platformStyle;var containerWidth=this.props.containerWidth;var numberOfTabs=this.props.tabs.length;var tabUnderlineStyle={position:"absolute",width:containerWidth/numberOfTabs,height:4,backgroundColor:variables.topTabBarActiveBorderColor,bottom:0};var left=this.props.scrollValue.interpolate({inputRange:[0,1],outputRange:[0,containerWidth/numberOfTabs]});return _react2.default.createElement(_index.TabContainer,{style:[{backgroundColor:variables.tabDefaultBg},this.props.tabContainerStyle?this.props.tabContainerStyle:{}],__source:{fileName:_jsxFileName,lineNumber:117}},this.props.tabs.map(function(name,page){var isTabActive=_this.props.activeTab===page;var renderTab=_this.props.renderTab||_this.renderTab;return renderTab(name,page,isTabActive,_this.props.goToPage,_this.props.tabStyle[page],_this.props.activeTabStyle[page],_this.props.textStyle[page],_this.props.activeTextStyle[page],_this.props.tabHeaderStyle[page]);}),_react2.default.createElement(Animated.View,{style:[tabUnderlineStyle,{left:left},this.props.underlineStyle],__source:{fileName:_jsxFileName,lineNumber:138}}));}});var StyledTab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.DefaultTabBar",{},_mapPropsToStyleNames2.default)(DefaultTabBar);exports.DefaultTabBar=StyledTab;
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f6b810f5f0d9b1a4cfabaccbcf733cafc7edff42
package.json
import { StyleSheet } from "react-native";
<mask> "use_strict"; <mask> import _ from "lodash"; <mask> import ReactNativePropRegistry from "react-native/Libraries/Renderer/shims/ReactNativePropRegistry"; <mask> // For compatibility with RN 0.25 <mask> // import ReactNativePropRegistry from "react-native/Libraries/ReactNative/ReactNativePropRegistry"; <mask> module.exports = function(incomingProps, defaultProps) { <mask> // External props has a higher precedence <mask> let computedProps = {}; <mask> <mask> incomingProps = _.clone(incomingProps); </s> Upgraded deps and dev-deps, compatible with RN 0.56.0 </s> remove _.merge(computedPropsStyle, ReactNativePropRegistry.getByID(style)); </s> add _.merge(computedPropsStyle, StyleSheet.flatten(style)); </s> remove computedPropsStyle = ReactNativePropRegistry.getByID(incomingPropsStyle); </s> add computedPropsStyle = StyleSheet.flatten(incomingPropsStyle); </s> remove var fs=require("fs-extra"); var path=require("path"); var printMessage=require("print-message"); try{ fs.copySync( path.join(__dirname,"src","theme"), path.join(process.cwd(),"native-base-theme")); printMessage( [ "NativeBase theme has been copied at "+ path.join(process.cwd(),"native-base-theme"), "Here's how to theme your app", "", "import getTheme from './native-base-theme/components';", "export default class ThemeExample extends Component {", "render() {", " return (", " <StyleProvider style={getTheme()}>", " <Container>", " <Content>", " ...", " </Content>", " </Container>", " </StyleProvider>", " );", "}", "", "Head over to the docs (http://docs.nativebase.io/Customize.html#Customize) for detailed information on customization"], { color:"yellow", borderColor:"green"}); }catch(err){ console.log("Error: "+err); } </s> add var fs=require("fs-extra");var path=require("path");var printMessage=require("print-message");try{fs.copySync(path.join(__dirname,"src","theme"),path.join(process.cwd(),"native-base-theme"));printMessage(["NativeBase theme has been copied at "+path.join(process.cwd(),"native-base-theme"),"Here's how to theme your app","","import getTheme from './native-base-theme/components';","export default class ThemeExample extends Component {","render() {"," return ("," <StyleProvider style={getTheme()}>"," <Container>"," <Content>"," ..."," </Content>"," </Container>"," </StyleProvider>"," );","}","","Head over to the docs (http://docs.nativebase.io/Customize.html#Customize) for detailed information on customization"],{color:"yellow",borderColor:"green"});}catch(err){console.log("Error: "+err);} </s> remove var printMessage=require("print-message"); printMessage( [ "NativeBase 2.0 has been succesfully installed!", "Run `node node_modules/native-base/ejectTheme.js` to copy over theme config and variables.", "Head over to the docs for detailed information on how to make changes to the theme."], { color:"yellow", borderColor:"green"}); </s> add var printMessage=require("print-message");printMessage(["NativeBase 2.0 has been succesfully installed!","Run `node node_modules/native-base/ejectTheme.js` to copy over theme config and variables.","Head over to the docs for detailed information on how to make changes to the theme."],{color:"yellow",borderColor:"green"}); </s> remove "use_strict"; var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _ReactNativePropRegistry=require("react-native/Libraries/Renderer/shims/ReactNativePropRegistry");var _ReactNativePropRegistry2=_interopRequireDefault(_ReactNativePropRegistry);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} module.exports=function(incomingProps,defaultProps){ var computedProps={}; incomingProps=_lodash2.default.clone(incomingProps); delete incomingProps.children; var incomingPropsStyle=incomingProps.style; delete incomingProps.style; if(incomingProps){ _lodash2.default.assign(computedProps,defaultProps,incomingProps); }else{ computedProps=defaultProps; } if(incomingPropsStyle){ var computedPropsStyle={}; computedProps.style={}; if(Array.isArray(incomingPropsStyle)){ _lodash2.default.forEach(incomingPropsStyle,function(style){ if(typeof style==="number"){ _lodash2.default.merge(computedPropsStyle,_ReactNativePropRegistry2.default.getByID(style)); }else{ _lodash2.default.merge(computedPropsStyle,style); } }); }else if(typeof incomingPropsStyle==="number"){ computedPropsStyle=_ReactNativePropRegistry2.default.getByID(incomingPropsStyle); }else{ computedPropsStyle=incomingPropsStyle; } _lodash2.default.merge(computedProps.style,defaultProps.style,computedPropsStyle); } return computedProps; }; </s> add "use_strict";var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _reactNative=require("react-native");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}module.exports=function(incomingProps,defaultProps){var computedProps={};incomingProps=_lodash2.default.clone(incomingProps);delete incomingProps.children;var incomingPropsStyle=incomingProps.style;delete incomingProps.style;if(incomingProps){_lodash2.default.assign(computedProps,defaultProps,incomingProps);}else{computedProps=defaultProps;}if(incomingPropsStyle){var computedPropsStyle={};computedProps.style={};if(Array.isArray(incomingPropsStyle)){_lodash2.default.forEach(incomingPropsStyle,function(style){if(typeof style==="number"){_lodash2.default.merge(computedPropsStyle,_reactNative.StyleSheet.flatten(style));}else{_lodash2.default.merge(computedPropsStyle,style);}});}else if(typeof incomingPropsStyle==="number"){computedPropsStyle=_reactNative.StyleSheet.flatten(incomingPropsStyle);}else{computedPropsStyle=incomingPropsStyle;}_lodash2.default.merge(computedProps.style,defaultProps.style,computedPropsStyle);}return computedProps;};
[ "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f6b810f5f0d9b1a4cfabaccbcf733cafc7edff42
src/utils/computeProps.js
_.merge(computedPropsStyle, StyleSheet.flatten(style));
<mask> computedProps.style = {}; <mask> if (Array.isArray(incomingPropsStyle)) { <mask> _.forEach(incomingPropsStyle, style => { <mask> if (typeof style === "number") { <mask> _.merge(computedPropsStyle, ReactNativePropRegistry.getByID(style)); <mask> } else { <mask> _.merge(computedPropsStyle, style); <mask> } <mask> }); <mask> } else if (typeof incomingPropsStyle === "number") { </s> Upgraded deps and dev-deps, compatible with RN 0.56.0 </s> remove computedPropsStyle = ReactNativePropRegistry.getByID(incomingPropsStyle); </s> add computedPropsStyle = StyleSheet.flatten(incomingPropsStyle); </s> remove import ReactNativePropRegistry from "react-native/Libraries/Renderer/shims/ReactNativePropRegistry"; // For compatibility with RN 0.25 // import ReactNativePropRegistry from "react-native/Libraries/ReactNative/ReactNativePropRegistry"; </s> add import { StyleSheet } from "react-native"; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.Fab=undefined;var _jsxFileName="src/basic/Fab.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps); var _reactNative=require("react-native"); var _Icon=require("./Icon"); var _IconNB=require("./IconNB"); var _Button=require("./Button"); var _platform=require("./../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var _Dimensions$get= _reactNative.Dimensions.get("window"),height=_Dimensions$get.height,width=_Dimensions$get.width; var AnimatedFab=_reactNative.Animated.createAnimatedComponent(_Button.Button);var Fab=function(_Component){_inherits(Fab,_Component); function Fab(props){_classCallCheck(this,Fab);var _this=_possibleConstructorReturn(this,(Fab.__proto__||Object.getPrototypeOf(Fab)).call(this, props)); _this.containerHeight=new _reactNative.Animated.Value(56); _this.containerWidth=new _reactNative.Animated.Value(0); _this.buttonScale=new _reactNative.Animated.Value(0); _this.state={ buttons:undefined, active:false};return _this; }_createClass(Fab,[{key:"fabTopValue",value:function fabTopValue( pos) { if(pos==="topLeft"){ return{ top:20, bottom:undefined, left:20, right:undefined}; }else if(pos==="bottomRight"){ return{ top:undefined, bottom:20, left:undefined, right:20}; }else if(pos==="bottomLeft"){ return{ top:undefined, bottom:20, left:20, right:undefined}; }else if(pos==="topRight"){ return{ top:20, bottom:undefined, left:undefined, right:20}; } }},{key:"fabOtherBtns",value:function fabOtherBtns( direction,i){ if(direction==="up"){ return{ top:undefined, bottom: this.props.active===false? _reactNative.Platform.OS==="ios"?50:5: i*50+65, left:8, right:0}; }else if(direction==="left"){ return{ top:8, bottom:0, left: this.props.active===false? _reactNative.Platform.OS==="ios"?8:8: -(i*50+58), right:0}; }else if(direction==="down"){ return{ top: this.props.active===false? _reactNative.Platform.OS==="ios"?50:8: i*50+73, bottom:0, left:8, right:0}; }else if(direction==="right"){ return{ top:8, bottom:0, left: this.props.active===false? _reactNative.Platform.OS==="ios"?50:8: i*50+73, right:0}; } }},{key:"getInitialStyle",value:function getInitialStyle( iconStyle){ return{ fab:{ height:56, width:56, borderRadius:28, elevation:4, shadowColor:"#000", shadowOffset:{width:0,height:2}, shadowOpacity:0.4, justifyContent:"center", alignItems:"center", shadowRadius:2, position:"absolute", bottom:0, backgroundColor:"blue"}, container:{ position:"absolute", top:this.props.position? this.fabTopValue(this.props.position).top: undefined, bottom:this.props.position? this.fabTopValue(this.props.position).bottom: 20, right:this.props.position? this.fabTopValue(this.props.position).right: 20, left:this.props.position? this.fabTopValue(this.props.position).left: undefined, width:56, height:this.containerHeight, flexDirection:this.props.direction? this.props.direction==="left"||this.props.direction==="right"? "row": "column": "column", alignItems:"center"}, iconStyle:_extends({ color:"#fff", fontSize:24, lineHeight:_reactNative.Platform.OS=="ios"?27:undefined}, iconStyle), buttonStyle:{ position:"absolute", height:40, width:40, left:7, borderRadius:20, transform:this.state.active? [{scale:new _reactNative.Animated.Value(1)}]: [{scale:this.buttonScale}], marginBottom:10, backgroundColor:"blue"}}; }},{key:"getContainerStyle",value:function getContainerStyle() { return _lodash2.default.merge(this.getInitialStyle().container,this.props.containerStyle); }},{key:"prepareFabProps",value:function prepareFabProps() { var defaultProps={ style:this.getInitialStyle().fab}; var incomingProps=_lodash2.default.clone(this.props); delete incomingProps.onPress; return(0,_computeProps2.default)(incomingProps,defaultProps); }},{key:"getOtherButtonStyle",value:function getOtherButtonStyle( child,i){ var type={ top:this.props.direction? this.fabOtherBtns(this.props.direction,i).top: undefined, left:this.props.direction? this.fabOtherBtns(this.props.direction,i).left: 8, right:this.props.direction? this.fabOtherBtns(this.props.direction,i).right: 0, bottom:this.props.direction? this.fabOtherBtns(this.props.direction,i).bottom: this.props.active===false? _reactNative.Platform.OS==="ios"?8:8: i*50+50}; return _lodash2.default.merge(this.getInitialStyle().buttonStyle,_reactNative.StyleSheet.flatten(child.props.style),type); }},{key:"prepareButtonProps",value:function prepareButtonProps( child){ var inp=_lodash2.default.clone(child.props); delete inp.style; var defaultProps={}; return(0,_computeProps2.default)(inp,defaultProps); }},{key:"componentDidMount",value:function componentDidMount() {var _this2=this; var childrenArray=_react2.default.Children.toArray(this.props.children); var icon=_lodash2.default.remove(childrenArray,function(item){ if(item.type.displayName==="Styled(Button)"){ return true; } }); this.setState({ buttons:icon.length}); this.activeTimer=setTimeout(function(){ _this2.setState({ active:_this2.props.active}); },0); }},{key:"componentWillUnmount",value:function componentWillUnmount() { if(this.activeTimer){ clearTimeout(this.activeTimer); } }},{key:"renderFab",value:function renderFab() { var childrenArray=_react2.default.Children.toArray(this.props.children); var icon=_lodash2.default.remove(childrenArray,function(item){ if(item.type.displayName==="Styled(Button)"){ return true; } }); return _react2.default.cloneElement(childrenArray[0],{ style:this.getInitialStyle(childrenArray[0].props.style).iconStyle}); }},{key:"renderButtons",value:function renderButtons() {var _this3=this; var childrenArray=_react2.default.Children.toArray(this.props.children); var newChildren=[]; { childrenArray.slice(1).map(function(child,i){ newChildren.push( _react2.default.createElement(AnimatedFab,_extends({ style:_this3.getOtherButtonStyle(child,i)}, _this3.prepareButtonProps(child,i),{ fabButton:true, key:i,__source:{fileName:_jsxFileName,lineNumber:279}}), child.props.children)); }); } return newChildren; }},{key:"upAnimate",value:function upAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerHeight,{ toValue:this.state.buttons*51.3+56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"leftAnimate",value:function leftAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerWidth,{ toValue:this.state.buttons*51.3+56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"rightAnimate",value:function rightAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerWidth,{ toValue:this.state.buttons*51.3+56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"downAnimate",value:function downAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"_animate",value:function _animate() {var _props= this.props,direction=_props.direction,position=_props.position; if(this.props.direction){ if(this.props.direction==="up"){ this.upAnimate(); }else if(this.props.direction==="left"){ this.leftAnimate(); }else if(this.props.direction==="right"){ this.rightAnimate(); }else if(this.props.direction==="down"){ this.downAnimate(); } }else{ this.upAnimate(); } }},{key:"fabOnPress",value:function fabOnPress() {var _this4=this; if(this.props.onPress){ this.props.onPress(); this._animate(); this.activeTimer=setTimeout(function(){ _this4.setState({ active:_this4.props.active}); },100); } }},{key:"render",value:function render() {var _this5=this;var active=this.props.active; return( _react2.default.createElement(_reactNative.Animated.View,{style:this.getContainerStyle(),__source:{fileName:_jsxFileName,lineNumber:424}}, this.renderButtons(), _reactNative.Platform.OS==="ios"|| _platform2.default.androidRipple===false|| _reactNative.Platform["Version"]<=21? _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ onPress:function onPress(){return _this5.fabOnPress();}}, this.prepareFabProps(),{ activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:429}}), this.renderFab()): _react2.default.createElement(_reactNative.TouchableNativeFeedback,_extends({ onPress:function onPress(){return _this5.fabOnPress();}}, this.prepareFabProps(),{__source:{fileName:_jsxFileName,lineNumber:437}}), _react2.default.createElement(_reactNative.View,{style:[this.getInitialStyle().fab,this.props.style],__source:{fileName:_jsxFileName,lineNumber:441}}, this.renderFab())))); }}]);return Fab;}(_react.Component); var StyledFab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Fab",{},_mapPropsToStyleNames2.default)(Fab);exports. Fab=StyledFab; </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.Fab=undefined;var _jsxFileName="src/basic/Fab.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps);var _reactNative=require("react-native");var _Icon=require("./Icon");var _IconNB=require("./IconNB");var _Button=require("./Button");var _platform=require("./../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var _Dimensions$get=_reactNative.Dimensions.get("window"),height=_Dimensions$get.height,width=_Dimensions$get.width;var AnimatedFab=_reactNative.Animated.createAnimatedComponent(_Button.Button);var Fab=function(_Component){_inherits(Fab,_Component);function Fab(props){_classCallCheck(this,Fab);var _this=_possibleConstructorReturn(this,(Fab.__proto__||Object.getPrototypeOf(Fab)).call(this,props));_this.containerHeight=new _reactNative.Animated.Value(56);_this.containerWidth=new _reactNative.Animated.Value(0);_this.buttonScale=new _reactNative.Animated.Value(0);_this.state={buttons:undefined,active:false};return _this;}_createClass(Fab,[{key:"fabTopValue",value:function fabTopValue(pos){if(pos==="topLeft"){return{top:20,bottom:undefined,left:20,right:undefined};}else if(pos==="bottomRight"){return{top:undefined,bottom:20,left:undefined,right:20};}else if(pos==="bottomLeft"){return{top:undefined,bottom:20,left:20,right:undefined};}else if(pos==="topRight"){return{top:20,bottom:undefined,left:undefined,right:20};}}},{key:"fabOtherBtns",value:function fabOtherBtns(direction,i){if(direction==="up"){return{top:undefined,bottom:this.props.active===false?_reactNative.Platform.OS==="ios"?50:5:i*50+65,left:8,right:0};}else if(direction==="left"){return{top:8,bottom:0,left:this.props.active===false?_reactNative.Platform.OS==="ios"?8:8:-(i*50+58),right:0};}else if(direction==="down"){return{top:this.props.active===false?_reactNative.Platform.OS==="ios"?50:8:i*50+73,bottom:0,left:8,right:0};}else if(direction==="right"){return{top:8,bottom:0,left:this.props.active===false?_reactNative.Platform.OS==="ios"?50:8:i*50+73,right:0};}}},{key:"getInitialStyle",value:function getInitialStyle(iconStyle){return{fab:{height:56,width:56,borderRadius:28,elevation:4,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:0.4,justifyContent:"center",alignItems:"center",shadowRadius:2,position:"absolute",bottom:0,backgroundColor:"blue"},container:{position:"absolute",top:this.props.position?this.fabTopValue(this.props.position).top:undefined,bottom:this.props.position?this.fabTopValue(this.props.position).bottom:20,right:this.props.position?this.fabTopValue(this.props.position).right:20,left:this.props.position?this.fabTopValue(this.props.position).left:undefined,width:56,height:this.containerHeight,flexDirection:this.props.direction?this.props.direction==="left"||this.props.direction==="right"?"row":"column":"column",alignItems:"center"},iconStyle:_extends({color:"#fff",fontSize:24,lineHeight:_reactNative.Platform.OS=="ios"?27:undefined},iconStyle),buttonStyle:{position:"absolute",height:40,width:40,left:7,borderRadius:20,transform:this.state.active?[{scale:new _reactNative.Animated.Value(1)}]:[{scale:this.buttonScale}],marginBottom:10,backgroundColor:"blue"}};}},{key:"getContainerStyle",value:function getContainerStyle(){return _lodash2.default.merge(this.getInitialStyle().container,this.props.containerStyle);}},{key:"prepareFabProps",value:function prepareFabProps(){var defaultProps={style:this.getInitialStyle().fab};var incomingProps=_lodash2.default.clone(this.props);delete incomingProps.onPress;return(0,_computeProps2.default)(incomingProps,defaultProps);}},{key:"getOtherButtonStyle",value:function getOtherButtonStyle(child,i){var type={top:this.props.direction?this.fabOtherBtns(this.props.direction,i).top:undefined,left:this.props.direction?this.fabOtherBtns(this.props.direction,i).left:8,right:this.props.direction?this.fabOtherBtns(this.props.direction,i).right:0,bottom:this.props.direction?this.fabOtherBtns(this.props.direction,i).bottom:this.props.active===false?_reactNative.Platform.OS==="ios"?8:8:i*50+50};return _lodash2.default.merge(this.getInitialStyle().buttonStyle,_reactNative.StyleSheet.flatten(child.props.style),type);}},{key:"prepareButtonProps",value:function prepareButtonProps(child){var inp=_lodash2.default.clone(child.props);delete inp.style;var defaultProps={};return(0,_computeProps2.default)(inp,defaultProps);}},{key:"componentDidMount",value:function componentDidMount(){var _this2=this;var childrenArray=_react2.default.Children.toArray(this.props.children);var icon=_lodash2.default.remove(childrenArray,function(item){if(item.type.displayName==="Styled(Button)"){return true;}});this.setState({buttons:icon.length});this.activeTimer=setTimeout(function(){_this2.setState({active:_this2.props.active});},0);}},{key:"componentWillUnmount",value:function componentWillUnmount(){if(this.activeTimer){clearTimeout(this.activeTimer);}}},{key:"renderFab",value:function renderFab(){var childrenArray=_react2.default.Children.toArray(this.props.children);var icon=_lodash2.default.remove(childrenArray,function(item){if(item.type.displayName==="Styled(Button)"){return true;}});return _react2.default.cloneElement(childrenArray[0],{style:this.getInitialStyle(childrenArray[0].props.style).iconStyle});}},{key:"renderButtons",value:function renderButtons(){var _this3=this;var childrenArray=_react2.default.Children.toArray(this.props.children);var newChildren=[];{childrenArray.slice(1).map(function(child,i){newChildren.push(_react2.default.createElement(AnimatedFab,_extends({style:_this3.getOtherButtonStyle(child,i)},_this3.prepareButtonProps(child,i),{fabButton:true,key:i,__source:{fileName:_jsxFileName,lineNumber:279}}),child.props.children));});}return newChildren;}},{key:"upAnimate",value:function upAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerHeight,{toValue:this.state.buttons*51.3+56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"leftAnimate",value:function leftAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerWidth,{toValue:this.state.buttons*51.3+56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"rightAnimate",value:function rightAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerWidth,{toValue:this.state.buttons*51.3+56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"downAnimate",value:function downAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"_animate",value:function _animate(){var _props=this.props,direction=_props.direction,position=_props.position;if(this.props.direction){if(this.props.direction==="up"){this.upAnimate();}else if(this.props.direction==="left"){this.leftAnimate();}else if(this.props.direction==="right"){this.rightAnimate();}else if(this.props.direction==="down"){this.downAnimate();}}else{this.upAnimate();}}},{key:"fabOnPress",value:function fabOnPress(){var _this4=this;if(this.props.onPress){this.props.onPress();this._animate();this.activeTimer=setTimeout(function(){_this4.setState({active:_this4.props.active});},100);}}},{key:"render",value:function render(){var _this5=this;var active=this.props.active;return _react2.default.createElement(_reactNative.Animated.View,{style:this.getContainerStyle(),__source:{fileName:_jsxFileName,lineNumber:424}},this.renderButtons(),_reactNative.Platform.OS==="ios"||_platform2.default.androidRipple===false||_reactNative.Platform["Version"]<=21?_react2.default.createElement(_reactNative.TouchableOpacity,_extends({onPress:function onPress(){return _this5.fabOnPress();}},this.prepareFabProps(),{activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:429}}),this.renderFab()):_react2.default.createElement(_reactNative.TouchableNativeFeedback,_extends({onPress:function onPress(){return _this5.fabOnPress();}},this.prepareFabProps(),{__source:{fileName:_jsxFileName,lineNumber:437}}),_react2.default.createElement(_reactNative.View,{style:[this.getInitialStyle().fab,this.props.style],__source:{fileName:_jsxFileName,lineNumber:441}},this.renderFab())));}}]);return Fab;}(_react.Component);var StyledFab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Fab",{},_mapPropsToStyleNames2.default)(Fab);exports.Fab=StyledFab; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.SwipeRow=undefined;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 _jsxFileName="src/basic/SwipeRow.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _reactNative=require("react-native"); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _Text=require("./Text"); var _Left=require("./Left"); var _Right=require("./Right"); var _Body=require("./Body"); var _ListItem=require("./ListItem"); var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;} var PREVIEW_OPEN_DELAY=700; var PREVIEW_CLOSE_DELAY=300;var SwipeRow=function(_Component){_inherits(SwipeRow,_Component); function SwipeRow(props){_classCallCheck(this,SwipeRow);var _this=_possibleConstructorReturn(this,(SwipeRow.__proto__||Object.getPrototypeOf(SwipeRow)).call(this, props)); _this.horizontalSwipeGestureBegan=false; _this.swipeInitialX=null; _this.parentScrollEnabled=true; _this.ranPreview=false; _this.state={ dimensionsSet:false, hiddenHeight:0, hiddenWidth:0}; _this._translateX=new _reactNative.Animated.Value(0);return _this; }_createClass(SwipeRow,[{key:"componentWillMount",value:function componentWillMount() {var _this2=this; this._panResponder=_reactNative.PanResponder.create({ onMoveShouldSetPanResponder:function onMoveShouldSetPanResponder(e,gs){return _this2.handleOnMoveShouldSetPanResponder(e,gs);}, onPanResponderMove:function onPanResponderMove(e,gs){return _this2.handlePanResponderMove(e,gs);}, onPanResponderRelease:function onPanResponderRelease(e,gs){return _this2.handlePanResponderEnd(e,gs);}, onPanResponderTerminate:function onPanResponderTerminate(e,gs){return _this2.handlePanResponderEnd(e,gs);}, onShouldBlockNativeResponder:function onShouldBlockNativeResponder(_){return false;}}); }},{key:"getPreviewAnimation",value:function getPreviewAnimation( toValue,delay){ return _reactNative.Animated.timing(this._translateX,{duration:this.props.previewDuration,toValue:toValue,delay:delay}); }},{key:"onContentLayout",value:function onContentLayout( e){var _this3=this; this.setState({ dimensionsSet:!this.props.recalculateHiddenLayout, hiddenHeight:e.nativeEvent.layout.height, hiddenWidth:e.nativeEvent.layout.width}); if(this.props.preview&&!this.ranPreview){ this.ranPreview=true; var previewOpenValue=this.props.previewOpenValue||this.props.rightOpenValue*0.5; this.getPreviewAnimation(previewOpenValue,PREVIEW_OPEN_DELAY).start(function(_){ _this3.getPreviewAnimation(0,PREVIEW_CLOSE_DELAY).start(); }); } }},{key:"handleOnMoveShouldSetPanResponder",value:function handleOnMoveShouldSetPanResponder( e,gs){var dx=gs.dx; return Math.abs(dx)>this.props.directionalDistanceChangeThreshold; }},{key:"handlePanResponderMove",value:function handlePanResponderMove( e,gestureState){var dx=gestureState.dx,dy=gestureState.dy; var absDx=Math.abs(dx); var absDy=Math.abs(dy); if( absDx>this.props.directionalDistanceChangeThreshold|| absDy>this.props.directionalDistanceChangeThreshold) { if(absDy>absDx&&!this.horizontalSwipeGestureBegan){ return; } if(this.parentScrollEnabled){ this.parentScrollEnabled=false; this.props.setScrollEnabled&&this.props.setScrollEnabled(false); } if(this.swipeInitialX===null){ this.swipeInitialX=this._translateX._value; } if(!this.horizontalSwipeGestureBegan){ this.horizontalSwipeGestureBegan=true; this.props.swipeGestureBegan&&this.props.swipeGestureBegan(); } var newDX=this.swipeInitialX+dx; if(this.props.disableLeftSwipe&&newDX<0){ newDX=0; } if(this.props.disableRightSwipe&&newDX>0){ newDX=0; } if(this.props.stopLeftSwipe&&newDX>this.props.stopLeftSwipe){ newDX=this.props.stopLeftSwipe; } if(this.props.stopRightSwipe&&newDX<this.props.stopRightSwipe){ newDX=this.props.stopRightSwipe; } this._translateX.setValue(newDX); } }},{key:"handlePanResponderEnd",value:function handlePanResponderEnd( e,gestureState){ if(!this.parentScrollEnabled){ this.parentScrollEnabled=true; this.props.setScrollEnabled&&this.props.setScrollEnabled(true); } var toValue=0; if(this._translateX._value>=0){ if(this._translateX._value>this.props.leftOpenValue*(this.props.swipeToOpenPercent/100)){ toValue=this.props.leftOpenValue; } }else{ if(this._translateX._value<this.props.rightOpenValue*(this.props.swipeToOpenPercent/100)){ toValue=this.props.rightOpenValue; } } this.manuallySwipeRow(toValue); }},{key:"closeRow",value:function closeRow() { this.manuallySwipeRow(0); }},{key:"manuallySwipeRow",value:function manuallySwipeRow( toValue){var _this4=this; _reactNative.Animated.spring(this._translateX,{ toValue:toValue, friction:this.props.friction, tension:this.props.tension}). start(function(_){ if(toValue===0){ _this4.props.onRowDidClose&&_this4.props.onRowDidClose(); }else{ _this4.props.onRowDidOpen&&_this4.props.onRowDidOpen(); } }); if(toValue===0){ this.props.onRowClose&&this.props.onRowClose(); }else{ this.props.onRowOpen&&this.props.onRowOpen(toValue); } this.swipeInitialX=null; this.horizontalSwipeGestureBegan=false; }},{key:"renderMainContent",value:function renderMainContent() {var _this5=this; if(this.state.dimensionsSet){ return( _react2.default.createElement(_reactNative.Animated.View,_extends({}, this._panResponder.panHandlers,{ style:{ transform:[{translateX:this._translateX}], zIndex:2},__source:{fileName:_jsxFileName,lineNumber:191}}), !this.props.list? _react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:199}}, this.props.body): _react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:202}}, this.props.body))); }else{ return( _react2.default.createElement(_reactNative.Animated.View,_extends({}, this._panResponder.panHandlers,{ onLayout:function onLayout(e){return _this5.onContentLayout(e);}, style:{ transform:[{translateX:this._translateX}], zIndex:2},__source:{fileName:_jsxFileName,lineNumber:209}}), !this.props.list? _react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:218}}, this.props.body): _react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:221}}, this.props.body))); } }},{key:"render",value:function render() { return( _react2.default.createElement(_reactNative.View,{style:this.props.style?this.props.style:undefined,__source:{fileName:_jsxFileName,lineNumber:231}}, _react2.default.createElement(_reactNative.View,{ style:[ styles.hidden, { height:this.state.hiddenHeight, flex:1, flexDirection:"row", justifyContent:"space-between"}],__source:{fileName:_jsxFileName,lineNumber:232}}, _react2.default.createElement(_Left.Left,{style:{width:this.props.leftOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:243}}, this.props.left), _react2.default.createElement(_Body.Body,{style:{flex:0},__source:{fileName:_jsxFileName,lineNumber:246}}), _react2.default.createElement(_Right.Right,{style:{width:-this.props.rightOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:247}}, this.props.right)), this.renderMainContent())); }}]);return SwipeRow;}(_react.Component);SwipeRow.defaultProps={leftOpenValue:0,rightOpenValue:0,closeOnRowPress:true,disableLeftSwipe:false,disableRightSwipe:false,recalculateHiddenLayout:false,preview:false,previewDuration:300,directionalDistanceChangeThreshold:2,swipeToOpenPercent:50}; var styles={ container:{}, hidden:{ bottom:0, left:0, overflow:"hidden", position:"absolute", right:0, top:0}}; var StyledSwipeRow=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.SwipeRow",{},_mapPropsToStyleNames2.default)(SwipeRow);exports. SwipeRow=StyledSwipeRow; </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.SwipeRow=undefined;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 _jsxFileName="src/basic/SwipeRow.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _reactNative=require("react-native");var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _Text=require("./Text");var _Left=require("./Left");var _Right=require("./Right");var _Body=require("./Body");var _ListItem=require("./ListItem");var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var PREVIEW_OPEN_DELAY=700;var PREVIEW_CLOSE_DELAY=300;var SwipeRow=function(_Component){_inherits(SwipeRow,_Component);function SwipeRow(props){_classCallCheck(this,SwipeRow);var _this=_possibleConstructorReturn(this,(SwipeRow.__proto__||Object.getPrototypeOf(SwipeRow)).call(this,props));_this.horizontalSwipeGestureBegan=false;_this.swipeInitialX=null;_this.parentScrollEnabled=true;_this.ranPreview=false;_this.state={dimensionsSet:false,hiddenHeight:0,hiddenWidth:0};_this._translateX=new _reactNative.Animated.Value(0);return _this;}_createClass(SwipeRow,[{key:"componentWillMount",value:function componentWillMount(){var _this2=this;this._panResponder=_reactNative.PanResponder.create({onMoveShouldSetPanResponder:function onMoveShouldSetPanResponder(e,gs){return _this2.handleOnMoveShouldSetPanResponder(e,gs);},onPanResponderMove:function onPanResponderMove(e,gs){return _this2.handlePanResponderMove(e,gs);},onPanResponderRelease:function onPanResponderRelease(e,gs){return _this2.handlePanResponderEnd(e,gs);},onPanResponderTerminate:function onPanResponderTerminate(e,gs){return _this2.handlePanResponderEnd(e,gs);},onShouldBlockNativeResponder:function onShouldBlockNativeResponder(_){return false;}});}},{key:"getPreviewAnimation",value:function getPreviewAnimation(toValue,delay){return _reactNative.Animated.timing(this._translateX,{duration:this.props.previewDuration,toValue:toValue,delay:delay});}},{key:"onContentLayout",value:function onContentLayout(e){var _this3=this;this.setState({dimensionsSet:!this.props.recalculateHiddenLayout,hiddenHeight:e.nativeEvent.layout.height,hiddenWidth:e.nativeEvent.layout.width});if(this.props.preview&&!this.ranPreview){this.ranPreview=true;var previewOpenValue=this.props.previewOpenValue||this.props.rightOpenValue*0.5;this.getPreviewAnimation(previewOpenValue,PREVIEW_OPEN_DELAY).start(function(_){_this3.getPreviewAnimation(0,PREVIEW_CLOSE_DELAY).start();});}}},{key:"handleOnMoveShouldSetPanResponder",value:function handleOnMoveShouldSetPanResponder(e,gs){var dx=gs.dx;return Math.abs(dx)>this.props.directionalDistanceChangeThreshold;}},{key:"handlePanResponderMove",value:function handlePanResponderMove(e,gestureState){var dx=gestureState.dx,dy=gestureState.dy;var absDx=Math.abs(dx);var absDy=Math.abs(dy);if(absDx>this.props.directionalDistanceChangeThreshold||absDy>this.props.directionalDistanceChangeThreshold){if(absDy>absDx&&!this.horizontalSwipeGestureBegan){return;}if(this.parentScrollEnabled){this.parentScrollEnabled=false;this.props.setScrollEnabled&&this.props.setScrollEnabled(false);}if(this.swipeInitialX===null){this.swipeInitialX=this._translateX._value;}if(!this.horizontalSwipeGestureBegan){this.horizontalSwipeGestureBegan=true;this.props.swipeGestureBegan&&this.props.swipeGestureBegan();}var newDX=this.swipeInitialX+dx;if(this.props.disableLeftSwipe&&newDX<0){newDX=0;}if(this.props.disableRightSwipe&&newDX>0){newDX=0;}if(this.props.stopLeftSwipe&&newDX>this.props.stopLeftSwipe){newDX=this.props.stopLeftSwipe;}if(this.props.stopRightSwipe&&newDX<this.props.stopRightSwipe){newDX=this.props.stopRightSwipe;}this._translateX.setValue(newDX);}}},{key:"handlePanResponderEnd",value:function handlePanResponderEnd(e,gestureState){if(!this.parentScrollEnabled){this.parentScrollEnabled=true;this.props.setScrollEnabled&&this.props.setScrollEnabled(true);}var toValue=0;if(this._translateX._value>=0){if(this._translateX._value>this.props.leftOpenValue*(this.props.swipeToOpenPercent/100)){toValue=this.props.leftOpenValue;}}else{if(this._translateX._value<this.props.rightOpenValue*(this.props.swipeToOpenPercent/100)){toValue=this.props.rightOpenValue;}}this.manuallySwipeRow(toValue);}},{key:"closeRow",value:function closeRow(){this.manuallySwipeRow(0);}},{key:"manuallySwipeRow",value:function manuallySwipeRow(toValue){var _this4=this;_reactNative.Animated.spring(this._translateX,{toValue:toValue,friction:this.props.friction,tension:this.props.tension}).start(function(_){if(toValue===0){_this4.props.onRowDidClose&&_this4.props.onRowDidClose();}else{_this4.props.onRowDidOpen&&_this4.props.onRowDidOpen();}});if(toValue===0){this.props.onRowClose&&this.props.onRowClose();}else{this.props.onRowOpen&&this.props.onRowOpen(toValue);}this.swipeInitialX=null;this.horizontalSwipeGestureBegan=false;}},{key:"renderMainContent",value:function renderMainContent(){var _this5=this;if(this.state.dimensionsSet){return _react2.default.createElement(_reactNative.Animated.View,_extends({},this._panResponder.panHandlers,{style:{transform:[{translateX:this._translateX}],zIndex:2},__source:{fileName:_jsxFileName,lineNumber:191}}),!this.props.list?_react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:199}},this.props.body):_react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:202}},this.props.body));}else{return _react2.default.createElement(_reactNative.Animated.View,_extends({},this._panResponder.panHandlers,{onLayout:function onLayout(e){return _this5.onContentLayout(e);},style:{transform:[{translateX:this._translateX}],zIndex:2},__source:{fileName:_jsxFileName,lineNumber:209}}),!this.props.list?_react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:218}},this.props.body):_react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:221}},this.props.body));}}},{key:"render",value:function render(){return _react2.default.createElement(_reactNative.View,{style:this.props.style?this.props.style:undefined,__source:{fileName:_jsxFileName,lineNumber:231}},_react2.default.createElement(_reactNative.View,{style:[styles.hidden,{height:this.state.hiddenHeight,flex:1,flexDirection:"row",justifyContent:"space-between"}],__source:{fileName:_jsxFileName,lineNumber:232}},_react2.default.createElement(_Left.Left,{style:{width:this.props.leftOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:243}},this.props.left),_react2.default.createElement(_Body.Body,{style:{flex:0},__source:{fileName:_jsxFileName,lineNumber:246}}),_react2.default.createElement(_Right.Right,{style:{width:-this.props.rightOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:247}},this.props.right)),this.renderMainContent());}}]);return SwipeRow;}(_react.Component);SwipeRow.defaultProps={leftOpenValue:0,rightOpenValue:0,closeOnRowPress:true,disableLeftSwipe:false,disableRightSwipe:false,recalculateHiddenLayout:false,preview:false,previewDuration:300,directionalDistanceChangeThreshold:2,swipeToOpenPercent:50};var styles={container:{},hidden:{bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0}};var StyledSwipeRow=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.SwipeRow",{},_mapPropsToStyleNames2.default)(SwipeRow);exports.SwipeRow=StyledSwipeRow; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.Item=undefined;var _jsxFileName="src/basic/Item.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _reactNative=require("react-native"); var _Input=require("./Input"); var _Label=require("./Label"); var _Icon=require("./Icon"); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _platform=require("../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps); var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var Item=function(_Component){_inherits(Item,_Component); function Item(props){_classCallCheck(this,Item);var _this=_possibleConstructorReturn(this,(Item.__proto__||Object.getPrototypeOf(Item)).call(this, props)); _this.state={ text:"", topAnim:new _reactNative.Animated.Value(18), opacAnim:new _reactNative.Animated.Value(1)};return _this; }_createClass(Item,[{key:"componentDidMount",value:function componentDidMount() { if(this.props.floatingLabel){ if(this.inputProps&&this.inputProps.value){ this.setState({isFocused:true}); this.floatUp(-16); } if(this.inputProps&&this.inputProps.getRef) this.inputProps.getRef(this._inputRef); } }},{key:"componentWillReceiveProps",value:function componentWillReceiveProps( nextProps){var _this2=this; var childrenArray=_react2.default.Children.toArray(nextProps.children); var inputProps={}; _lodash2.default.remove(childrenArray,function(item){ if(item.type.displayName==="Styled(Input)"){ inputProps=item.props; _this2.inputProps=item.props; return item; } }); if(this.props.floatingLabel){ if(this.inputProps&&this.inputProps.value){ this.setState({isFocused:true}); this.floatUp(-16); } if(this.inputProps&&this.inputProps.getRef) this.inputProps.getRef(this._inputRef); } }},{key:"floatBack",value:function floatBack() { _reactNative.Animated.timing(this.state.topAnim,{ toValue:18, duration:150}). start(); _reactNative.Animated.timing(this.state.opacAnim,{ toValue:1, duration:150}). start(); }},{key:"floatUp",value:function floatUp( e){ _reactNative.Animated.timing(this.state.topAnim,{ toValue:e||-22, duration:150}). start(); _reactNative.Animated.timing(this.state.opacAnim,{ toValue:0.7, duration:150}). start(); }},{key:"renderLabel",value:function renderLabel( label,labelProps){ var newLabel=[]; var labelStyle=_reactNative.StyleSheet.flatten( {fontSize:15,lineHeight:30}, labelProps.style); if(this.props.floatingLabel){ if(this.state.isFocused){ newLabel.push( _react2.default.createElement(_Label.Label,_extends({}, labelProps,{ key:"newFLabel", float:true, style:labelStyle}))); this.floatUp(-16); }else{ newLabel.push(label); this.floatBack(); } }else{ newLabel.push( _react2.default.createElement(_Label.Label,_extends({}, labelProps,{ key:"newLabel"}))); } return newLabel; }},{key:"renderChildren",value:function renderChildren() {var _this3=this; var newChildren=[]; var childrenArray=_react2.default.Children.toArray(this.props.children); var label=[]; var labelProps={}; label=_lodash2.default.remove(childrenArray,function(item){ if(item.type===_Label.Label){ labelProps=item.props; return item; } }); var input=[]; var inputProps={}; input=_lodash2.default.remove(childrenArray,function(item){ if(item.type===_Input.Input){ inputProps=item.props; _this3.inputProps=item.props; return item; } }); var icon=[]; var iconProps={}; icon=_lodash2.default.remove(childrenArray,function(item){ if(item.type===_Icon.Icon){ iconProps=item.props; return item; } }); if(this.props.floatingLabel&&icon.length){ var isIcon=false; for(var i=0;i<this.props.children.length;i++){ if(this.props.children[i].props.name&&this.props.children[i].type.displayName!=="Styled(Input)"){ isIcon=true; newChildren.push( _react2.default.createElement(_Icon.Icon,_extends({key:[i]},this.props.children[i].props,{__source:{fileName:_jsxFileName,lineNumber:150}}))); } if(this.props.children[i].props.children){ newChildren.push( _react2.default.createElement(_reactNative.Animated.View,{ key:"float", style:{ position:"absolute", left: this.props.last&&isIcon? 40: this.props.last? 15: isIcon? 26: 0, right:0, top:this.state.topAnim, opacity:this.state.opacAnim, paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined, paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:155}}, _react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:174}}), this.renderLabel(label,labelProps)))); newChildren.push( _react2.default.createElement(_Input.Input,_extends({ ref:function ref(c){return _this3._inputRef=c;}, key:"l2"}, inputProps,{ onFocus:function onFocus(){ _this3.setState({isFocused:true}); inputProps.onFocus&&inputProps.onFocus(); }, onBlur:function onBlur(){ inputProps.value? _this3.setState({ isFocused:true}): !_this3.state.text.length&& _this3.setState({isFocused:false}); inputProps.onBlur&&inputProps.onBlur(); }, onChangeText:function onChangeText(text){ _this3.setState({text:text}); inputProps.onChangeText&&inputProps.onChangeText(text); },__source:{fileName:_jsxFileName,lineNumber:180}}))); } } }else if(this.props.floatingLabel){ newChildren.push( _react2.default.createElement(_reactNative.Animated.View,{ key:"float", style:{ position:"absolute", left:this.props.last?15:0, right:0, top:this.state.topAnim, opacity:this.state.opacAnim, paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined, paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:207}}, _react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:219}}),this.renderLabel(label,labelProps)))); newChildren.push( _react2.default.createElement(_Input.Input,_extends({ ref:function ref(c){return _this3._inputRef=c;}, value:this.state.text, key:"l2"}, inputProps,{ onFocus:function onFocus(){ _this3.setState({isFocused:true}); inputProps.onFocus&&inputProps.onFocus(); }, onBlur:function onBlur(){ inputProps.value? _this3.setState({ isFocused:true}): !_this3.state.text.length&&_this3.setState({isFocused:false}); inputProps.onBlur&&inputProps.onBlur(); }, onChangeText:function onChangeText(text){ _this3.setState({text:text}); inputProps.onChangeText&&inputProps.onChangeText(text); },__source:{fileName:_jsxFileName,lineNumber:223}}))); }else if(this.props.stackedLabel&&icon.length){ newChildren.push( _react2.default.createElement(_reactNative.View,{ key:"s", style:{ flexDirection:"row", flex:1, width:_platform2.default.deviceWidth-15},__source:{fileName:_jsxFileName,lineNumber:248}}, _react2.default.createElement(_Icon.Icon,_extends({key:"s1"},iconProps,{__source:{fileName:_jsxFileName,lineNumber:256}})), _react2.default.createElement(_reactNative.View,{style:{flexDirection:"column"},__source:{fileName:_jsxFileName,lineNumber:257}}, _react2.default.createElement(_Label.Label,_extends({key:"s2"},labelProps,{__source:{fileName:_jsxFileName,lineNumber:258}})), _react2.default.createElement(_Input.Input,_extends({ key:"s3"}, inputProps,{ style:{width:_platform2.default.deviceWidth-40},__source:{fileName:_jsxFileName,lineNumber:259}}))))); }else{ return this.props.children; } return newChildren; }},{key:"getInitialStyle",value:function getInitialStyle() { return{ roundedInputGroup:{ borderWidth:this.props.rounded?_platform2.default.borderWidth*2:undefined, borderRadius:this.props.rounded? _platform2.default.inputGroupRoundedBorderRadius: undefined}}; }},{key:"prepareRootProps",value:function prepareRootProps() { var defaultProps={ style:this.getInitialStyle().roundedInputGroup}; return(0,_computeProps2.default)(this.props,defaultProps); }},{key:"render",value:function render() {var _this4=this; return( _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ ref:function ref(c){return _this4._root=c;}}, this.prepareRootProps(),{ activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:292}}), this.renderChildren())); }}]);return Item;}(_react.Component); var childrenType=function childrenType(props,propName,component){ var error=void 0; var prop=props[propName]; if(!props.children.length){ error=new Error( component+" should have both Label and Input components"); }else if( props.children[0].type.displayName!=="Styled(Label)"|| props.children[1].type.displayName!=="Styled(Input)") { error=new Error( component+" should have Label and Input components only"); } return error; }; Item.propTypes=_extends({}, _reactNative.TouchableOpacity.propTypes,{ style:_propTypes2.default.oneOfType([ _propTypes2.default.object, _propTypes2.default.number, _propTypes2.default.array]), inlineLabel:_propTypes2.default.bool, floatingLabel:_propTypes2.default.bool, stackedLabel:_propTypes2.default.bool, fixedLabel:_propTypes2.default.bool, success:_propTypes2.default.bool, error:_propTypes2.default.bool}); var StyledItem=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Item",{},_mapPropsToStyleNames2.default)( Item);exports. Item=StyledItem; </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.Item=undefined;var _jsxFileName="src/basic/Item.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _reactNative=require("react-native");var _Input=require("./Input");var _Label=require("./Label");var _Icon=require("./Icon");var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _platform=require("../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps);var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var Item=function(_Component){_inherits(Item,_Component);function Item(props){_classCallCheck(this,Item);var _this=_possibleConstructorReturn(this,(Item.__proto__||Object.getPrototypeOf(Item)).call(this,props));_this.state={text:"",topAnim:new _reactNative.Animated.Value(18),opacAnim:new _reactNative.Animated.Value(1)};return _this;}_createClass(Item,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.floatingLabel){if(this.inputProps&&this.inputProps.value){this.setState({isFocused:true});this.floatUp(-16);}if(this.inputProps&&this.inputProps.getRef)this.inputProps.getRef(this._inputRef);}}},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(nextProps){var _this2=this;var childrenArray=_react2.default.Children.toArray(nextProps.children);var inputProps={};_lodash2.default.remove(childrenArray,function(item){if(item.type.displayName==="Styled(Input)"){inputProps=item.props;_this2.inputProps=item.props;return item;}});if(this.props.floatingLabel){if(this.inputProps&&this.inputProps.value){this.setState({isFocused:true});this.floatUp(-16);}if(this.inputProps&&this.inputProps.getRef)this.inputProps.getRef(this._inputRef);}}},{key:"floatBack",value:function floatBack(){_reactNative.Animated.timing(this.state.topAnim,{toValue:18,duration:150}).start();_reactNative.Animated.timing(this.state.opacAnim,{toValue:1,duration:150}).start();}},{key:"floatUp",value:function floatUp(e){_reactNative.Animated.timing(this.state.topAnim,{toValue:e||-22,duration:150}).start();_reactNative.Animated.timing(this.state.opacAnim,{toValue:0.7,duration:150}).start();}},{key:"renderLabel",value:function renderLabel(label,labelProps){var newLabel=[];var labelStyle=_reactNative.StyleSheet.flatten({fontSize:15,lineHeight:30},labelProps.style);if(this.props.floatingLabel){if(this.state.isFocused){newLabel.push(_react2.default.createElement(_Label.Label,_extends({},labelProps,{key:"newFLabel",float:true,style:labelStyle})));this.floatUp(-16);}else{newLabel.push(label);this.floatBack();}}else{newLabel.push(_react2.default.createElement(_Label.Label,_extends({},labelProps,{key:"newLabel"})));}return newLabel;}},{key:"renderChildren",value:function renderChildren(){var _this3=this;var newChildren=[];var childrenArray=_react2.default.Children.toArray(this.props.children);var label=[];var labelProps={};label=_lodash2.default.remove(childrenArray,function(item){if(item.type===_Label.Label){labelProps=item.props;return item;}});var input=[];var inputProps={};input=_lodash2.default.remove(childrenArray,function(item){if(item.type===_Input.Input){inputProps=item.props;_this3.inputProps=item.props;return item;}});var icon=[];var iconProps={};icon=_lodash2.default.remove(childrenArray,function(item){if(item.type===_Icon.Icon){iconProps=item.props;return item;}});if(this.props.floatingLabel&&icon.length){var isIcon=false;for(var i=0;i<this.props.children.length;i++){if(this.props.children[i].props.name&&this.props.children[i].type.displayName!=="Styled(Input)"){isIcon=true;newChildren.push(_react2.default.createElement(_Icon.Icon,_extends({key:[i]},this.props.children[i].props,{__source:{fileName:_jsxFileName,lineNumber:150}})));}if(this.props.children[i].props.children){newChildren.push(_react2.default.createElement(_reactNative.Animated.View,{key:"float",style:{position:"absolute",left:this.props.last&&isIcon?40:this.props.last?15:isIcon?26:0,right:0,top:this.state.topAnim,opacity:this.state.opacAnim,paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined,paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:155}},_react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:174}}),this.renderLabel(label,labelProps))));newChildren.push(_react2.default.createElement(_Input.Input,_extends({ref:function ref(c){return _this3._inputRef=c;},key:"l2"},inputProps,{onFocus:function onFocus(){_this3.setState({isFocused:true});inputProps.onFocus&&inputProps.onFocus();},onBlur:function onBlur(){inputProps.value?_this3.setState({isFocused:true}):!_this3.state.text.length&&_this3.setState({isFocused:false});inputProps.onBlur&&inputProps.onBlur();},onChangeText:function onChangeText(text){_this3.setState({text:text});inputProps.onChangeText&&inputProps.onChangeText(text);},__source:{fileName:_jsxFileName,lineNumber:180}})));}}}else if(this.props.floatingLabel){newChildren.push(_react2.default.createElement(_reactNative.Animated.View,{key:"float",style:{position:"absolute",left:this.props.last?15:0,right:0,top:this.state.topAnim,opacity:this.state.opacAnim,paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined,paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:207}},_react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:219}}),this.renderLabel(label,labelProps))));newChildren.push(_react2.default.createElement(_Input.Input,_extends({ref:function ref(c){return _this3._inputRef=c;},value:this.state.text,key:"l2"},inputProps,{onFocus:function onFocus(){_this3.setState({isFocused:true});inputProps.onFocus&&inputProps.onFocus();},onBlur:function onBlur(){inputProps.value?_this3.setState({isFocused:true}):!_this3.state.text.length&&_this3.setState({isFocused:false});inputProps.onBlur&&inputProps.onBlur();},onChangeText:function onChangeText(text){_this3.setState({text:text});inputProps.onChangeText&&inputProps.onChangeText(text);},__source:{fileName:_jsxFileName,lineNumber:223}})));}else if(this.props.stackedLabel&&icon.length){newChildren.push(_react2.default.createElement(_reactNative.View,{key:"s",style:{flexDirection:"row",flex:1,width:_platform2.default.deviceWidth-15},__source:{fileName:_jsxFileName,lineNumber:248}},_react2.default.createElement(_Icon.Icon,_extends({key:"s1"},iconProps,{__source:{fileName:_jsxFileName,lineNumber:256}})),_react2.default.createElement(_reactNative.View,{style:{flexDirection:"column"},__source:{fileName:_jsxFileName,lineNumber:257}},_react2.default.createElement(_Label.Label,_extends({key:"s2"},labelProps,{__source:{fileName:_jsxFileName,lineNumber:258}})),_react2.default.createElement(_Input.Input,_extends({key:"s3"},inputProps,{style:{width:_platform2.default.deviceWidth-40},__source:{fileName:_jsxFileName,lineNumber:259}})))));}else{return this.props.children;}return newChildren;}},{key:"getInitialStyle",value:function getInitialStyle(){return{roundedInputGroup:{borderWidth:this.props.rounded?_platform2.default.borderWidth*2:undefined,borderRadius:this.props.rounded?_platform2.default.inputGroupRoundedBorderRadius:undefined}};}},{key:"prepareRootProps",value:function prepareRootProps(){var defaultProps={style:this.getInitialStyle().roundedInputGroup};return(0,_computeProps2.default)(this.props,defaultProps);}},{key:"render",value:function render(){var _this4=this;return _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ref:function ref(c){return _this4._root=c;}},this.prepareRootProps(),{activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:292}}),this.renderChildren());}}]);return Item;}(_react.Component);var childrenType=function childrenType(props,propName,component){var error=void 0;var prop=props[propName];if(!props.children.length){error=new Error(component+" should have both Label and Input components");}else if(props.children[0].type.displayName!=="Styled(Label)"||props.children[1].type.displayName!=="Styled(Input)"){error=new Error(component+" should have Label and Input components only");}return error;};Item.propTypes=_extends({},_reactNative.TouchableOpacity.propTypes,{style:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.number,_propTypes2.default.array]),inlineLabel:_propTypes2.default.bool,floatingLabel:_propTypes2.default.bool,stackedLabel:_propTypes2.default.bool,fixedLabel:_propTypes2.default.bool,success:_propTypes2.default.bool,error:_propTypes2.default.bool});var StyledItem=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Item",{},_mapPropsToStyleNames2.default)(Item);exports.Item=StyledItem;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f6b810f5f0d9b1a4cfabaccbcf733cafc7edff42
src/utils/computeProps.js
computedPropsStyle = StyleSheet.flatten(incomingPropsStyle);
<mask> _.merge(computedPropsStyle, style); <mask> } <mask> }); <mask> } else if (typeof incomingPropsStyle === "number") { <mask> computedPropsStyle = ReactNativePropRegistry.getByID(incomingPropsStyle); <mask> } else { <mask> computedPropsStyle = incomingPropsStyle; <mask> } <mask> <mask> _.merge(computedProps.style, defaultProps.style, computedPropsStyle); </s> Upgraded deps and dev-deps, compatible with RN 0.56.0 </s> remove _.merge(computedPropsStyle, ReactNativePropRegistry.getByID(style)); </s> add _.merge(computedPropsStyle, StyleSheet.flatten(style)); </s> remove import ReactNativePropRegistry from "react-native/Libraries/Renderer/shims/ReactNativePropRegistry"; // For compatibility with RN 0.25 // import ReactNativePropRegistry from "react-native/Libraries/ReactNative/ReactNativePropRegistry"; </s> add import { StyleSheet } from "react-native"; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.SwipeRow=undefined;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 _jsxFileName="src/basic/SwipeRow.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _reactNative=require("react-native"); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _Text=require("./Text"); var _Left=require("./Left"); var _Right=require("./Right"); var _Body=require("./Body"); var _ListItem=require("./ListItem"); var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;} var PREVIEW_OPEN_DELAY=700; var PREVIEW_CLOSE_DELAY=300;var SwipeRow=function(_Component){_inherits(SwipeRow,_Component); function SwipeRow(props){_classCallCheck(this,SwipeRow);var _this=_possibleConstructorReturn(this,(SwipeRow.__proto__||Object.getPrototypeOf(SwipeRow)).call(this, props)); _this.horizontalSwipeGestureBegan=false; _this.swipeInitialX=null; _this.parentScrollEnabled=true; _this.ranPreview=false; _this.state={ dimensionsSet:false, hiddenHeight:0, hiddenWidth:0}; _this._translateX=new _reactNative.Animated.Value(0);return _this; }_createClass(SwipeRow,[{key:"componentWillMount",value:function componentWillMount() {var _this2=this; this._panResponder=_reactNative.PanResponder.create({ onMoveShouldSetPanResponder:function onMoveShouldSetPanResponder(e,gs){return _this2.handleOnMoveShouldSetPanResponder(e,gs);}, onPanResponderMove:function onPanResponderMove(e,gs){return _this2.handlePanResponderMove(e,gs);}, onPanResponderRelease:function onPanResponderRelease(e,gs){return _this2.handlePanResponderEnd(e,gs);}, onPanResponderTerminate:function onPanResponderTerminate(e,gs){return _this2.handlePanResponderEnd(e,gs);}, onShouldBlockNativeResponder:function onShouldBlockNativeResponder(_){return false;}}); }},{key:"getPreviewAnimation",value:function getPreviewAnimation( toValue,delay){ return _reactNative.Animated.timing(this._translateX,{duration:this.props.previewDuration,toValue:toValue,delay:delay}); }},{key:"onContentLayout",value:function onContentLayout( e){var _this3=this; this.setState({ dimensionsSet:!this.props.recalculateHiddenLayout, hiddenHeight:e.nativeEvent.layout.height, hiddenWidth:e.nativeEvent.layout.width}); if(this.props.preview&&!this.ranPreview){ this.ranPreview=true; var previewOpenValue=this.props.previewOpenValue||this.props.rightOpenValue*0.5; this.getPreviewAnimation(previewOpenValue,PREVIEW_OPEN_DELAY).start(function(_){ _this3.getPreviewAnimation(0,PREVIEW_CLOSE_DELAY).start(); }); } }},{key:"handleOnMoveShouldSetPanResponder",value:function handleOnMoveShouldSetPanResponder( e,gs){var dx=gs.dx; return Math.abs(dx)>this.props.directionalDistanceChangeThreshold; }},{key:"handlePanResponderMove",value:function handlePanResponderMove( e,gestureState){var dx=gestureState.dx,dy=gestureState.dy; var absDx=Math.abs(dx); var absDy=Math.abs(dy); if( absDx>this.props.directionalDistanceChangeThreshold|| absDy>this.props.directionalDistanceChangeThreshold) { if(absDy>absDx&&!this.horizontalSwipeGestureBegan){ return; } if(this.parentScrollEnabled){ this.parentScrollEnabled=false; this.props.setScrollEnabled&&this.props.setScrollEnabled(false); } if(this.swipeInitialX===null){ this.swipeInitialX=this._translateX._value; } if(!this.horizontalSwipeGestureBegan){ this.horizontalSwipeGestureBegan=true; this.props.swipeGestureBegan&&this.props.swipeGestureBegan(); } var newDX=this.swipeInitialX+dx; if(this.props.disableLeftSwipe&&newDX<0){ newDX=0; } if(this.props.disableRightSwipe&&newDX>0){ newDX=0; } if(this.props.stopLeftSwipe&&newDX>this.props.stopLeftSwipe){ newDX=this.props.stopLeftSwipe; } if(this.props.stopRightSwipe&&newDX<this.props.stopRightSwipe){ newDX=this.props.stopRightSwipe; } this._translateX.setValue(newDX); } }},{key:"handlePanResponderEnd",value:function handlePanResponderEnd( e,gestureState){ if(!this.parentScrollEnabled){ this.parentScrollEnabled=true; this.props.setScrollEnabled&&this.props.setScrollEnabled(true); } var toValue=0; if(this._translateX._value>=0){ if(this._translateX._value>this.props.leftOpenValue*(this.props.swipeToOpenPercent/100)){ toValue=this.props.leftOpenValue; } }else{ if(this._translateX._value<this.props.rightOpenValue*(this.props.swipeToOpenPercent/100)){ toValue=this.props.rightOpenValue; } } this.manuallySwipeRow(toValue); }},{key:"closeRow",value:function closeRow() { this.manuallySwipeRow(0); }},{key:"manuallySwipeRow",value:function manuallySwipeRow( toValue){var _this4=this; _reactNative.Animated.spring(this._translateX,{ toValue:toValue, friction:this.props.friction, tension:this.props.tension}). start(function(_){ if(toValue===0){ _this4.props.onRowDidClose&&_this4.props.onRowDidClose(); }else{ _this4.props.onRowDidOpen&&_this4.props.onRowDidOpen(); } }); if(toValue===0){ this.props.onRowClose&&this.props.onRowClose(); }else{ this.props.onRowOpen&&this.props.onRowOpen(toValue); } this.swipeInitialX=null; this.horizontalSwipeGestureBegan=false; }},{key:"renderMainContent",value:function renderMainContent() {var _this5=this; if(this.state.dimensionsSet){ return( _react2.default.createElement(_reactNative.Animated.View,_extends({}, this._panResponder.panHandlers,{ style:{ transform:[{translateX:this._translateX}], zIndex:2},__source:{fileName:_jsxFileName,lineNumber:191}}), !this.props.list? _react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:199}}, this.props.body): _react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:202}}, this.props.body))); }else{ return( _react2.default.createElement(_reactNative.Animated.View,_extends({}, this._panResponder.panHandlers,{ onLayout:function onLayout(e){return _this5.onContentLayout(e);}, style:{ transform:[{translateX:this._translateX}], zIndex:2},__source:{fileName:_jsxFileName,lineNumber:209}}), !this.props.list? _react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:218}}, this.props.body): _react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:221}}, this.props.body))); } }},{key:"render",value:function render() { return( _react2.default.createElement(_reactNative.View,{style:this.props.style?this.props.style:undefined,__source:{fileName:_jsxFileName,lineNumber:231}}, _react2.default.createElement(_reactNative.View,{ style:[ styles.hidden, { height:this.state.hiddenHeight, flex:1, flexDirection:"row", justifyContent:"space-between"}],__source:{fileName:_jsxFileName,lineNumber:232}}, _react2.default.createElement(_Left.Left,{style:{width:this.props.leftOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:243}}, this.props.left), _react2.default.createElement(_Body.Body,{style:{flex:0},__source:{fileName:_jsxFileName,lineNumber:246}}), _react2.default.createElement(_Right.Right,{style:{width:-this.props.rightOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:247}}, this.props.right)), this.renderMainContent())); }}]);return SwipeRow;}(_react.Component);SwipeRow.defaultProps={leftOpenValue:0,rightOpenValue:0,closeOnRowPress:true,disableLeftSwipe:false,disableRightSwipe:false,recalculateHiddenLayout:false,preview:false,previewDuration:300,directionalDistanceChangeThreshold:2,swipeToOpenPercent:50}; var styles={ container:{}, hidden:{ bottom:0, left:0, overflow:"hidden", position:"absolute", right:0, top:0}}; var StyledSwipeRow=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.SwipeRow",{},_mapPropsToStyleNames2.default)(SwipeRow);exports. SwipeRow=StyledSwipeRow; </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.SwipeRow=undefined;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 _jsxFileName="src/basic/SwipeRow.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _reactNative=require("react-native");var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _Text=require("./Text");var _Left=require("./Left");var _Right=require("./Right");var _Body=require("./Body");var _ListItem=require("./ListItem");var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var PREVIEW_OPEN_DELAY=700;var PREVIEW_CLOSE_DELAY=300;var SwipeRow=function(_Component){_inherits(SwipeRow,_Component);function SwipeRow(props){_classCallCheck(this,SwipeRow);var _this=_possibleConstructorReturn(this,(SwipeRow.__proto__||Object.getPrototypeOf(SwipeRow)).call(this,props));_this.horizontalSwipeGestureBegan=false;_this.swipeInitialX=null;_this.parentScrollEnabled=true;_this.ranPreview=false;_this.state={dimensionsSet:false,hiddenHeight:0,hiddenWidth:0};_this._translateX=new _reactNative.Animated.Value(0);return _this;}_createClass(SwipeRow,[{key:"componentWillMount",value:function componentWillMount(){var _this2=this;this._panResponder=_reactNative.PanResponder.create({onMoveShouldSetPanResponder:function onMoveShouldSetPanResponder(e,gs){return _this2.handleOnMoveShouldSetPanResponder(e,gs);},onPanResponderMove:function onPanResponderMove(e,gs){return _this2.handlePanResponderMove(e,gs);},onPanResponderRelease:function onPanResponderRelease(e,gs){return _this2.handlePanResponderEnd(e,gs);},onPanResponderTerminate:function onPanResponderTerminate(e,gs){return _this2.handlePanResponderEnd(e,gs);},onShouldBlockNativeResponder:function onShouldBlockNativeResponder(_){return false;}});}},{key:"getPreviewAnimation",value:function getPreviewAnimation(toValue,delay){return _reactNative.Animated.timing(this._translateX,{duration:this.props.previewDuration,toValue:toValue,delay:delay});}},{key:"onContentLayout",value:function onContentLayout(e){var _this3=this;this.setState({dimensionsSet:!this.props.recalculateHiddenLayout,hiddenHeight:e.nativeEvent.layout.height,hiddenWidth:e.nativeEvent.layout.width});if(this.props.preview&&!this.ranPreview){this.ranPreview=true;var previewOpenValue=this.props.previewOpenValue||this.props.rightOpenValue*0.5;this.getPreviewAnimation(previewOpenValue,PREVIEW_OPEN_DELAY).start(function(_){_this3.getPreviewAnimation(0,PREVIEW_CLOSE_DELAY).start();});}}},{key:"handleOnMoveShouldSetPanResponder",value:function handleOnMoveShouldSetPanResponder(e,gs){var dx=gs.dx;return Math.abs(dx)>this.props.directionalDistanceChangeThreshold;}},{key:"handlePanResponderMove",value:function handlePanResponderMove(e,gestureState){var dx=gestureState.dx,dy=gestureState.dy;var absDx=Math.abs(dx);var absDy=Math.abs(dy);if(absDx>this.props.directionalDistanceChangeThreshold||absDy>this.props.directionalDistanceChangeThreshold){if(absDy>absDx&&!this.horizontalSwipeGestureBegan){return;}if(this.parentScrollEnabled){this.parentScrollEnabled=false;this.props.setScrollEnabled&&this.props.setScrollEnabled(false);}if(this.swipeInitialX===null){this.swipeInitialX=this._translateX._value;}if(!this.horizontalSwipeGestureBegan){this.horizontalSwipeGestureBegan=true;this.props.swipeGestureBegan&&this.props.swipeGestureBegan();}var newDX=this.swipeInitialX+dx;if(this.props.disableLeftSwipe&&newDX<0){newDX=0;}if(this.props.disableRightSwipe&&newDX>0){newDX=0;}if(this.props.stopLeftSwipe&&newDX>this.props.stopLeftSwipe){newDX=this.props.stopLeftSwipe;}if(this.props.stopRightSwipe&&newDX<this.props.stopRightSwipe){newDX=this.props.stopRightSwipe;}this._translateX.setValue(newDX);}}},{key:"handlePanResponderEnd",value:function handlePanResponderEnd(e,gestureState){if(!this.parentScrollEnabled){this.parentScrollEnabled=true;this.props.setScrollEnabled&&this.props.setScrollEnabled(true);}var toValue=0;if(this._translateX._value>=0){if(this._translateX._value>this.props.leftOpenValue*(this.props.swipeToOpenPercent/100)){toValue=this.props.leftOpenValue;}}else{if(this._translateX._value<this.props.rightOpenValue*(this.props.swipeToOpenPercent/100)){toValue=this.props.rightOpenValue;}}this.manuallySwipeRow(toValue);}},{key:"closeRow",value:function closeRow(){this.manuallySwipeRow(0);}},{key:"manuallySwipeRow",value:function manuallySwipeRow(toValue){var _this4=this;_reactNative.Animated.spring(this._translateX,{toValue:toValue,friction:this.props.friction,tension:this.props.tension}).start(function(_){if(toValue===0){_this4.props.onRowDidClose&&_this4.props.onRowDidClose();}else{_this4.props.onRowDidOpen&&_this4.props.onRowDidOpen();}});if(toValue===0){this.props.onRowClose&&this.props.onRowClose();}else{this.props.onRowOpen&&this.props.onRowOpen(toValue);}this.swipeInitialX=null;this.horizontalSwipeGestureBegan=false;}},{key:"renderMainContent",value:function renderMainContent(){var _this5=this;if(this.state.dimensionsSet){return _react2.default.createElement(_reactNative.Animated.View,_extends({},this._panResponder.panHandlers,{style:{transform:[{translateX:this._translateX}],zIndex:2},__source:{fileName:_jsxFileName,lineNumber:191}}),!this.props.list?_react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:199}},this.props.body):_react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:202}},this.props.body));}else{return _react2.default.createElement(_reactNative.Animated.View,_extends({},this._panResponder.panHandlers,{onLayout:function onLayout(e){return _this5.onContentLayout(e);},style:{transform:[{translateX:this._translateX}],zIndex:2},__source:{fileName:_jsxFileName,lineNumber:209}}),!this.props.list?_react2.default.createElement(_ListItem.ListItem,{list:true,style:this.props.style,__source:{fileName:_jsxFileName,lineNumber:218}},this.props.body):_react2.default.createElement(_reactNative.View,{style:[{backgroundColor:'#FFF'},this.props.style],__source:{fileName:_jsxFileName,lineNumber:221}},this.props.body));}}},{key:"render",value:function render(){return _react2.default.createElement(_reactNative.View,{style:this.props.style?this.props.style:undefined,__source:{fileName:_jsxFileName,lineNumber:231}},_react2.default.createElement(_reactNative.View,{style:[styles.hidden,{height:this.state.hiddenHeight,flex:1,flexDirection:"row",justifyContent:"space-between"}],__source:{fileName:_jsxFileName,lineNumber:232}},_react2.default.createElement(_Left.Left,{style:{width:this.props.leftOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:243}},this.props.left),_react2.default.createElement(_Body.Body,{style:{flex:0},__source:{fileName:_jsxFileName,lineNumber:246}}),_react2.default.createElement(_Right.Right,{style:{width:-this.props.rightOpenValue,zIndex:1},__source:{fileName:_jsxFileName,lineNumber:247}},this.props.right)),this.renderMainContent());}}]);return SwipeRow;}(_react.Component);SwipeRow.defaultProps={leftOpenValue:0,rightOpenValue:0,closeOnRowPress:true,disableLeftSwipe:false,disableRightSwipe:false,recalculateHiddenLayout:false,preview:false,previewDuration:300,directionalDistanceChangeThreshold:2,swipeToOpenPercent:50};var styles={container:{},hidden:{bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0}};var StyledSwipeRow=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.SwipeRow",{},_mapPropsToStyleNames2.default)(SwipeRow);exports.SwipeRow=StyledSwipeRow; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.Item=undefined;var _jsxFileName="src/basic/Item.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _reactNative=require("react-native"); var _Input=require("./Input"); var _Label=require("./Label"); var _Icon=require("./Icon"); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme"); var _platform=require("../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps); var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var Item=function(_Component){_inherits(Item,_Component); function Item(props){_classCallCheck(this,Item);var _this=_possibleConstructorReturn(this,(Item.__proto__||Object.getPrototypeOf(Item)).call(this, props)); _this.state={ text:"", topAnim:new _reactNative.Animated.Value(18), opacAnim:new _reactNative.Animated.Value(1)};return _this; }_createClass(Item,[{key:"componentDidMount",value:function componentDidMount() { if(this.props.floatingLabel){ if(this.inputProps&&this.inputProps.value){ this.setState({isFocused:true}); this.floatUp(-16); } if(this.inputProps&&this.inputProps.getRef) this.inputProps.getRef(this._inputRef); } }},{key:"componentWillReceiveProps",value:function componentWillReceiveProps( nextProps){var _this2=this; var childrenArray=_react2.default.Children.toArray(nextProps.children); var inputProps={}; _lodash2.default.remove(childrenArray,function(item){ if(item.type.displayName==="Styled(Input)"){ inputProps=item.props; _this2.inputProps=item.props; return item; } }); if(this.props.floatingLabel){ if(this.inputProps&&this.inputProps.value){ this.setState({isFocused:true}); this.floatUp(-16); } if(this.inputProps&&this.inputProps.getRef) this.inputProps.getRef(this._inputRef); } }},{key:"floatBack",value:function floatBack() { _reactNative.Animated.timing(this.state.topAnim,{ toValue:18, duration:150}). start(); _reactNative.Animated.timing(this.state.opacAnim,{ toValue:1, duration:150}). start(); }},{key:"floatUp",value:function floatUp( e){ _reactNative.Animated.timing(this.state.topAnim,{ toValue:e||-22, duration:150}). start(); _reactNative.Animated.timing(this.state.opacAnim,{ toValue:0.7, duration:150}). start(); }},{key:"renderLabel",value:function renderLabel( label,labelProps){ var newLabel=[]; var labelStyle=_reactNative.StyleSheet.flatten( {fontSize:15,lineHeight:30}, labelProps.style); if(this.props.floatingLabel){ if(this.state.isFocused){ newLabel.push( _react2.default.createElement(_Label.Label,_extends({}, labelProps,{ key:"newFLabel", float:true, style:labelStyle}))); this.floatUp(-16); }else{ newLabel.push(label); this.floatBack(); } }else{ newLabel.push( _react2.default.createElement(_Label.Label,_extends({}, labelProps,{ key:"newLabel"}))); } return newLabel; }},{key:"renderChildren",value:function renderChildren() {var _this3=this; var newChildren=[]; var childrenArray=_react2.default.Children.toArray(this.props.children); var label=[]; var labelProps={}; label=_lodash2.default.remove(childrenArray,function(item){ if(item.type===_Label.Label){ labelProps=item.props; return item; } }); var input=[]; var inputProps={}; input=_lodash2.default.remove(childrenArray,function(item){ if(item.type===_Input.Input){ inputProps=item.props; _this3.inputProps=item.props; return item; } }); var icon=[]; var iconProps={}; icon=_lodash2.default.remove(childrenArray,function(item){ if(item.type===_Icon.Icon){ iconProps=item.props; return item; } }); if(this.props.floatingLabel&&icon.length){ var isIcon=false; for(var i=0;i<this.props.children.length;i++){ if(this.props.children[i].props.name&&this.props.children[i].type.displayName!=="Styled(Input)"){ isIcon=true; newChildren.push( _react2.default.createElement(_Icon.Icon,_extends({key:[i]},this.props.children[i].props,{__source:{fileName:_jsxFileName,lineNumber:150}}))); } if(this.props.children[i].props.children){ newChildren.push( _react2.default.createElement(_reactNative.Animated.View,{ key:"float", style:{ position:"absolute", left: this.props.last&&isIcon? 40: this.props.last? 15: isIcon? 26: 0, right:0, top:this.state.topAnim, opacity:this.state.opacAnim, paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined, paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:155}}, _react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:174}}), this.renderLabel(label,labelProps)))); newChildren.push( _react2.default.createElement(_Input.Input,_extends({ ref:function ref(c){return _this3._inputRef=c;}, key:"l2"}, inputProps,{ onFocus:function onFocus(){ _this3.setState({isFocused:true}); inputProps.onFocus&&inputProps.onFocus(); }, onBlur:function onBlur(){ inputProps.value? _this3.setState({ isFocused:true}): !_this3.state.text.length&& _this3.setState({isFocused:false}); inputProps.onBlur&&inputProps.onBlur(); }, onChangeText:function onChangeText(text){ _this3.setState({text:text}); inputProps.onChangeText&&inputProps.onChangeText(text); },__source:{fileName:_jsxFileName,lineNumber:180}}))); } } }else if(this.props.floatingLabel){ newChildren.push( _react2.default.createElement(_reactNative.Animated.View,{ key:"float", style:{ position:"absolute", left:this.props.last?15:0, right:0, top:this.state.topAnim, opacity:this.state.opacAnim, paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined, paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:207}}, _react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:219}}),this.renderLabel(label,labelProps)))); newChildren.push( _react2.default.createElement(_Input.Input,_extends({ ref:function ref(c){return _this3._inputRef=c;}, value:this.state.text, key:"l2"}, inputProps,{ onFocus:function onFocus(){ _this3.setState({isFocused:true}); inputProps.onFocus&&inputProps.onFocus(); }, onBlur:function onBlur(){ inputProps.value? _this3.setState({ isFocused:true}): !_this3.state.text.length&&_this3.setState({isFocused:false}); inputProps.onBlur&&inputProps.onBlur(); }, onChangeText:function onChangeText(text){ _this3.setState({text:text}); inputProps.onChangeText&&inputProps.onChangeText(text); },__source:{fileName:_jsxFileName,lineNumber:223}}))); }else if(this.props.stackedLabel&&icon.length){ newChildren.push( _react2.default.createElement(_reactNative.View,{ key:"s", style:{ flexDirection:"row", flex:1, width:_platform2.default.deviceWidth-15},__source:{fileName:_jsxFileName,lineNumber:248}}, _react2.default.createElement(_Icon.Icon,_extends({key:"s1"},iconProps,{__source:{fileName:_jsxFileName,lineNumber:256}})), _react2.default.createElement(_reactNative.View,{style:{flexDirection:"column"},__source:{fileName:_jsxFileName,lineNumber:257}}, _react2.default.createElement(_Label.Label,_extends({key:"s2"},labelProps,{__source:{fileName:_jsxFileName,lineNumber:258}})), _react2.default.createElement(_Input.Input,_extends({ key:"s3"}, inputProps,{ style:{width:_platform2.default.deviceWidth-40},__source:{fileName:_jsxFileName,lineNumber:259}}))))); }else{ return this.props.children; } return newChildren; }},{key:"getInitialStyle",value:function getInitialStyle() { return{ roundedInputGroup:{ borderWidth:this.props.rounded?_platform2.default.borderWidth*2:undefined, borderRadius:this.props.rounded? _platform2.default.inputGroupRoundedBorderRadius: undefined}}; }},{key:"prepareRootProps",value:function prepareRootProps() { var defaultProps={ style:this.getInitialStyle().roundedInputGroup}; return(0,_computeProps2.default)(this.props,defaultProps); }},{key:"render",value:function render() {var _this4=this; return( _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ ref:function ref(c){return _this4._root=c;}}, this.prepareRootProps(),{ activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:292}}), this.renderChildren())); }}]);return Item;}(_react.Component); var childrenType=function childrenType(props,propName,component){ var error=void 0; var prop=props[propName]; if(!props.children.length){ error=new Error( component+" should have both Label and Input components"); }else if( props.children[0].type.displayName!=="Styled(Label)"|| props.children[1].type.displayName!=="Styled(Input)") { error=new Error( component+" should have Label and Input components only"); } return error; }; Item.propTypes=_extends({}, _reactNative.TouchableOpacity.propTypes,{ style:_propTypes2.default.oneOfType([ _propTypes2.default.object, _propTypes2.default.number, _propTypes2.default.array]), inlineLabel:_propTypes2.default.bool, floatingLabel:_propTypes2.default.bool, stackedLabel:_propTypes2.default.bool, fixedLabel:_propTypes2.default.bool, success:_propTypes2.default.bool, error:_propTypes2.default.bool}); var StyledItem=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Item",{},_mapPropsToStyleNames2.default)( Item);exports. Item=StyledItem; </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.Item=undefined;var _jsxFileName="src/basic/Item.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _reactNative=require("react-native");var _Input=require("./Input");var _Label=require("./Label");var _Icon=require("./Icon");var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");var _platform=require("../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps);var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var Item=function(_Component){_inherits(Item,_Component);function Item(props){_classCallCheck(this,Item);var _this=_possibleConstructorReturn(this,(Item.__proto__||Object.getPrototypeOf(Item)).call(this,props));_this.state={text:"",topAnim:new _reactNative.Animated.Value(18),opacAnim:new _reactNative.Animated.Value(1)};return _this;}_createClass(Item,[{key:"componentDidMount",value:function componentDidMount(){if(this.props.floatingLabel){if(this.inputProps&&this.inputProps.value){this.setState({isFocused:true});this.floatUp(-16);}if(this.inputProps&&this.inputProps.getRef)this.inputProps.getRef(this._inputRef);}}},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(nextProps){var _this2=this;var childrenArray=_react2.default.Children.toArray(nextProps.children);var inputProps={};_lodash2.default.remove(childrenArray,function(item){if(item.type.displayName==="Styled(Input)"){inputProps=item.props;_this2.inputProps=item.props;return item;}});if(this.props.floatingLabel){if(this.inputProps&&this.inputProps.value){this.setState({isFocused:true});this.floatUp(-16);}if(this.inputProps&&this.inputProps.getRef)this.inputProps.getRef(this._inputRef);}}},{key:"floatBack",value:function floatBack(){_reactNative.Animated.timing(this.state.topAnim,{toValue:18,duration:150}).start();_reactNative.Animated.timing(this.state.opacAnim,{toValue:1,duration:150}).start();}},{key:"floatUp",value:function floatUp(e){_reactNative.Animated.timing(this.state.topAnim,{toValue:e||-22,duration:150}).start();_reactNative.Animated.timing(this.state.opacAnim,{toValue:0.7,duration:150}).start();}},{key:"renderLabel",value:function renderLabel(label,labelProps){var newLabel=[];var labelStyle=_reactNative.StyleSheet.flatten({fontSize:15,lineHeight:30},labelProps.style);if(this.props.floatingLabel){if(this.state.isFocused){newLabel.push(_react2.default.createElement(_Label.Label,_extends({},labelProps,{key:"newFLabel",float:true,style:labelStyle})));this.floatUp(-16);}else{newLabel.push(label);this.floatBack();}}else{newLabel.push(_react2.default.createElement(_Label.Label,_extends({},labelProps,{key:"newLabel"})));}return newLabel;}},{key:"renderChildren",value:function renderChildren(){var _this3=this;var newChildren=[];var childrenArray=_react2.default.Children.toArray(this.props.children);var label=[];var labelProps={};label=_lodash2.default.remove(childrenArray,function(item){if(item.type===_Label.Label){labelProps=item.props;return item;}});var input=[];var inputProps={};input=_lodash2.default.remove(childrenArray,function(item){if(item.type===_Input.Input){inputProps=item.props;_this3.inputProps=item.props;return item;}});var icon=[];var iconProps={};icon=_lodash2.default.remove(childrenArray,function(item){if(item.type===_Icon.Icon){iconProps=item.props;return item;}});if(this.props.floatingLabel&&icon.length){var isIcon=false;for(var i=0;i<this.props.children.length;i++){if(this.props.children[i].props.name&&this.props.children[i].type.displayName!=="Styled(Input)"){isIcon=true;newChildren.push(_react2.default.createElement(_Icon.Icon,_extends({key:[i]},this.props.children[i].props,{__source:{fileName:_jsxFileName,lineNumber:150}})));}if(this.props.children[i].props.children){newChildren.push(_react2.default.createElement(_reactNative.Animated.View,{key:"float",style:{position:"absolute",left:this.props.last&&isIcon?40:this.props.last?15:isIcon?26:0,right:0,top:this.state.topAnim,opacity:this.state.opacAnim,paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined,paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:155}},_react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:174}}),this.renderLabel(label,labelProps))));newChildren.push(_react2.default.createElement(_Input.Input,_extends({ref:function ref(c){return _this3._inputRef=c;},key:"l2"},inputProps,{onFocus:function onFocus(){_this3.setState({isFocused:true});inputProps.onFocus&&inputProps.onFocus();},onBlur:function onBlur(){inputProps.value?_this3.setState({isFocused:true}):!_this3.state.text.length&&_this3.setState({isFocused:false});inputProps.onBlur&&inputProps.onBlur();},onChangeText:function onChangeText(text){_this3.setState({text:text});inputProps.onChangeText&&inputProps.onChangeText(text);},__source:{fileName:_jsxFileName,lineNumber:180}})));}}}else if(this.props.floatingLabel){newChildren.push(_react2.default.createElement(_reactNative.Animated.View,{key:"float",style:{position:"absolute",left:this.props.last?15:0,right:0,top:this.state.topAnim,opacity:this.state.opacAnim,paddingTop:_reactNative.Platform.OS==="ios"?undefined:undefined,paddingBottom:_reactNative.Platform.OS==="ios"?undefined:12},__source:{fileName:_jsxFileName,lineNumber:207}},_react2.default.createElement(_Label.Label,_extends({},labelProps,{__source:{fileName:_jsxFileName,lineNumber:219}}),this.renderLabel(label,labelProps))));newChildren.push(_react2.default.createElement(_Input.Input,_extends({ref:function ref(c){return _this3._inputRef=c;},value:this.state.text,key:"l2"},inputProps,{onFocus:function onFocus(){_this3.setState({isFocused:true});inputProps.onFocus&&inputProps.onFocus();},onBlur:function onBlur(){inputProps.value?_this3.setState({isFocused:true}):!_this3.state.text.length&&_this3.setState({isFocused:false});inputProps.onBlur&&inputProps.onBlur();},onChangeText:function onChangeText(text){_this3.setState({text:text});inputProps.onChangeText&&inputProps.onChangeText(text);},__source:{fileName:_jsxFileName,lineNumber:223}})));}else if(this.props.stackedLabel&&icon.length){newChildren.push(_react2.default.createElement(_reactNative.View,{key:"s",style:{flexDirection:"row",flex:1,width:_platform2.default.deviceWidth-15},__source:{fileName:_jsxFileName,lineNumber:248}},_react2.default.createElement(_Icon.Icon,_extends({key:"s1"},iconProps,{__source:{fileName:_jsxFileName,lineNumber:256}})),_react2.default.createElement(_reactNative.View,{style:{flexDirection:"column"},__source:{fileName:_jsxFileName,lineNumber:257}},_react2.default.createElement(_Label.Label,_extends({key:"s2"},labelProps,{__source:{fileName:_jsxFileName,lineNumber:258}})),_react2.default.createElement(_Input.Input,_extends({key:"s3"},inputProps,{style:{width:_platform2.default.deviceWidth-40},__source:{fileName:_jsxFileName,lineNumber:259}})))));}else{return this.props.children;}return newChildren;}},{key:"getInitialStyle",value:function getInitialStyle(){return{roundedInputGroup:{borderWidth:this.props.rounded?_platform2.default.borderWidth*2:undefined,borderRadius:this.props.rounded?_platform2.default.inputGroupRoundedBorderRadius:undefined}};}},{key:"prepareRootProps",value:function prepareRootProps(){var defaultProps={style:this.getInitialStyle().roundedInputGroup};return(0,_computeProps2.default)(this.props,defaultProps);}},{key:"render",value:function render(){var _this4=this;return _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ref:function ref(c){return _this4._root=c;}},this.prepareRootProps(),{activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:292}}),this.renderChildren());}}]);return Item;}(_react.Component);var childrenType=function childrenType(props,propName,component){var error=void 0;var prop=props[propName];if(!props.children.length){error=new Error(component+" should have both Label and Input components");}else if(props.children[0].type.displayName!=="Styled(Label)"||props.children[1].type.displayName!=="Styled(Input)"){error=new Error(component+" should have Label and Input components only");}return error;};Item.propTypes=_extends({},_reactNative.TouchableOpacity.propTypes,{style:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.number,_propTypes2.default.array]),inlineLabel:_propTypes2.default.bool,floatingLabel:_propTypes2.default.bool,stackedLabel:_propTypes2.default.bool,fixedLabel:_propTypes2.default.bool,success:_propTypes2.default.bool,error:_propTypes2.default.bool});var StyledItem=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Item",{},_mapPropsToStyleNames2.default)(Item);exports.Item=StyledItem; </s> remove Object.defineProperty(exports,"__esModule",{value:true});exports.Fab=undefined;var _jsxFileName="src/basic/Fab.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes); var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps); var _reactNative=require("react-native"); var _Icon=require("./Icon"); var _IconNB=require("./IconNB"); var _Button=require("./Button"); var _platform=require("./../theme/variables/platform");var _platform2=_interopRequireDefault(_platform); var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash); var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames); var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var _Dimensions$get= _reactNative.Dimensions.get("window"),height=_Dimensions$get.height,width=_Dimensions$get.width; var AnimatedFab=_reactNative.Animated.createAnimatedComponent(_Button.Button);var Fab=function(_Component){_inherits(Fab,_Component); function Fab(props){_classCallCheck(this,Fab);var _this=_possibleConstructorReturn(this,(Fab.__proto__||Object.getPrototypeOf(Fab)).call(this, props)); _this.containerHeight=new _reactNative.Animated.Value(56); _this.containerWidth=new _reactNative.Animated.Value(0); _this.buttonScale=new _reactNative.Animated.Value(0); _this.state={ buttons:undefined, active:false};return _this; }_createClass(Fab,[{key:"fabTopValue",value:function fabTopValue( pos) { if(pos==="topLeft"){ return{ top:20, bottom:undefined, left:20, right:undefined}; }else if(pos==="bottomRight"){ return{ top:undefined, bottom:20, left:undefined, right:20}; }else if(pos==="bottomLeft"){ return{ top:undefined, bottom:20, left:20, right:undefined}; }else if(pos==="topRight"){ return{ top:20, bottom:undefined, left:undefined, right:20}; } }},{key:"fabOtherBtns",value:function fabOtherBtns( direction,i){ if(direction==="up"){ return{ top:undefined, bottom: this.props.active===false? _reactNative.Platform.OS==="ios"?50:5: i*50+65, left:8, right:0}; }else if(direction==="left"){ return{ top:8, bottom:0, left: this.props.active===false? _reactNative.Platform.OS==="ios"?8:8: -(i*50+58), right:0}; }else if(direction==="down"){ return{ top: this.props.active===false? _reactNative.Platform.OS==="ios"?50:8: i*50+73, bottom:0, left:8, right:0}; }else if(direction==="right"){ return{ top:8, bottom:0, left: this.props.active===false? _reactNative.Platform.OS==="ios"?50:8: i*50+73, right:0}; } }},{key:"getInitialStyle",value:function getInitialStyle( iconStyle){ return{ fab:{ height:56, width:56, borderRadius:28, elevation:4, shadowColor:"#000", shadowOffset:{width:0,height:2}, shadowOpacity:0.4, justifyContent:"center", alignItems:"center", shadowRadius:2, position:"absolute", bottom:0, backgroundColor:"blue"}, container:{ position:"absolute", top:this.props.position? this.fabTopValue(this.props.position).top: undefined, bottom:this.props.position? this.fabTopValue(this.props.position).bottom: 20, right:this.props.position? this.fabTopValue(this.props.position).right: 20, left:this.props.position? this.fabTopValue(this.props.position).left: undefined, width:56, height:this.containerHeight, flexDirection:this.props.direction? this.props.direction==="left"||this.props.direction==="right"? "row": "column": "column", alignItems:"center"}, iconStyle:_extends({ color:"#fff", fontSize:24, lineHeight:_reactNative.Platform.OS=="ios"?27:undefined}, iconStyle), buttonStyle:{ position:"absolute", height:40, width:40, left:7, borderRadius:20, transform:this.state.active? [{scale:new _reactNative.Animated.Value(1)}]: [{scale:this.buttonScale}], marginBottom:10, backgroundColor:"blue"}}; }},{key:"getContainerStyle",value:function getContainerStyle() { return _lodash2.default.merge(this.getInitialStyle().container,this.props.containerStyle); }},{key:"prepareFabProps",value:function prepareFabProps() { var defaultProps={ style:this.getInitialStyle().fab}; var incomingProps=_lodash2.default.clone(this.props); delete incomingProps.onPress; return(0,_computeProps2.default)(incomingProps,defaultProps); }},{key:"getOtherButtonStyle",value:function getOtherButtonStyle( child,i){ var type={ top:this.props.direction? this.fabOtherBtns(this.props.direction,i).top: undefined, left:this.props.direction? this.fabOtherBtns(this.props.direction,i).left: 8, right:this.props.direction? this.fabOtherBtns(this.props.direction,i).right: 0, bottom:this.props.direction? this.fabOtherBtns(this.props.direction,i).bottom: this.props.active===false? _reactNative.Platform.OS==="ios"?8:8: i*50+50}; return _lodash2.default.merge(this.getInitialStyle().buttonStyle,_reactNative.StyleSheet.flatten(child.props.style),type); }},{key:"prepareButtonProps",value:function prepareButtonProps( child){ var inp=_lodash2.default.clone(child.props); delete inp.style; var defaultProps={}; return(0,_computeProps2.default)(inp,defaultProps); }},{key:"componentDidMount",value:function componentDidMount() {var _this2=this; var childrenArray=_react2.default.Children.toArray(this.props.children); var icon=_lodash2.default.remove(childrenArray,function(item){ if(item.type.displayName==="Styled(Button)"){ return true; } }); this.setState({ buttons:icon.length}); this.activeTimer=setTimeout(function(){ _this2.setState({ active:_this2.props.active}); },0); }},{key:"componentWillUnmount",value:function componentWillUnmount() { if(this.activeTimer){ clearTimeout(this.activeTimer); } }},{key:"renderFab",value:function renderFab() { var childrenArray=_react2.default.Children.toArray(this.props.children); var icon=_lodash2.default.remove(childrenArray,function(item){ if(item.type.displayName==="Styled(Button)"){ return true; } }); return _react2.default.cloneElement(childrenArray[0],{ style:this.getInitialStyle(childrenArray[0].props.style).iconStyle}); }},{key:"renderButtons",value:function renderButtons() {var _this3=this; var childrenArray=_react2.default.Children.toArray(this.props.children); var newChildren=[]; { childrenArray.slice(1).map(function(child,i){ newChildren.push( _react2.default.createElement(AnimatedFab,_extends({ style:_this3.getOtherButtonStyle(child,i)}, _this3.prepareButtonProps(child,i),{ fabButton:true, key:i,__source:{fileName:_jsxFileName,lineNumber:279}}), child.props.children)); }); } return newChildren; }},{key:"upAnimate",value:function upAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerHeight,{ toValue:this.state.buttons*51.3+56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"leftAnimate",value:function leftAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerWidth,{ toValue:this.state.buttons*51.3+56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"rightAnimate",value:function rightAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerWidth,{ toValue:this.state.buttons*51.3+56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"downAnimate",value:function downAnimate() { if(!this.props.active){ _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:1}). start(); }else{ this.setState({ active:false}); _reactNative.Animated.spring(this.containerHeight,{ toValue:56}). start(); _reactNative.Animated.spring(this.buttonScale,{ toValue:0}). start(); } }},{key:"_animate",value:function _animate() {var _props= this.props,direction=_props.direction,position=_props.position; if(this.props.direction){ if(this.props.direction==="up"){ this.upAnimate(); }else if(this.props.direction==="left"){ this.leftAnimate(); }else if(this.props.direction==="right"){ this.rightAnimate(); }else if(this.props.direction==="down"){ this.downAnimate(); } }else{ this.upAnimate(); } }},{key:"fabOnPress",value:function fabOnPress() {var _this4=this; if(this.props.onPress){ this.props.onPress(); this._animate(); this.activeTimer=setTimeout(function(){ _this4.setState({ active:_this4.props.active}); },100); } }},{key:"render",value:function render() {var _this5=this;var active=this.props.active; return( _react2.default.createElement(_reactNative.Animated.View,{style:this.getContainerStyle(),__source:{fileName:_jsxFileName,lineNumber:424}}, this.renderButtons(), _reactNative.Platform.OS==="ios"|| _platform2.default.androidRipple===false|| _reactNative.Platform["Version"]<=21? _react2.default.createElement(_reactNative.TouchableOpacity,_extends({ onPress:function onPress(){return _this5.fabOnPress();}}, this.prepareFabProps(),{ activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:429}}), this.renderFab()): _react2.default.createElement(_reactNative.TouchableNativeFeedback,_extends({ onPress:function onPress(){return _this5.fabOnPress();}}, this.prepareFabProps(),{__source:{fileName:_jsxFileName,lineNumber:437}}), _react2.default.createElement(_reactNative.View,{style:[this.getInitialStyle().fab,this.props.style],__source:{fileName:_jsxFileName,lineNumber:441}}, this.renderFab())))); }}]);return Fab;}(_react.Component); var StyledFab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Fab",{},_mapPropsToStyleNames2.default)(Fab);exports. Fab=StyledFab; </s> add Object.defineProperty(exports,"__esModule",{value:true});exports.Fab=undefined;var _jsxFileName="src/basic/Fab.js";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 _propTypes=require("prop-types");var _propTypes2=_interopRequireDefault(_propTypes);var _computeProps=require("../utils/computeProps");var _computeProps2=_interopRequireDefault(_computeProps);var _reactNative=require("react-native");var _Icon=require("./Icon");var _IconNB=require("./IconNB");var _Button=require("./Button");var _platform=require("./../theme/variables/platform");var _platform2=_interopRequireDefault(_platform);var _lodash=require("lodash");var _lodash2=_interopRequireDefault(_lodash);var _mapPropsToStyleNames=require("../utils/mapPropsToStyleNames");var _mapPropsToStyleNames2=_interopRequireDefault(_mapPropsToStyleNames);var _nativeBaseShoutemTheme=require("native-base-shoutem-theme");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}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;}var _Dimensions$get=_reactNative.Dimensions.get("window"),height=_Dimensions$get.height,width=_Dimensions$get.width;var AnimatedFab=_reactNative.Animated.createAnimatedComponent(_Button.Button);var Fab=function(_Component){_inherits(Fab,_Component);function Fab(props){_classCallCheck(this,Fab);var _this=_possibleConstructorReturn(this,(Fab.__proto__||Object.getPrototypeOf(Fab)).call(this,props));_this.containerHeight=new _reactNative.Animated.Value(56);_this.containerWidth=new _reactNative.Animated.Value(0);_this.buttonScale=new _reactNative.Animated.Value(0);_this.state={buttons:undefined,active:false};return _this;}_createClass(Fab,[{key:"fabTopValue",value:function fabTopValue(pos){if(pos==="topLeft"){return{top:20,bottom:undefined,left:20,right:undefined};}else if(pos==="bottomRight"){return{top:undefined,bottom:20,left:undefined,right:20};}else if(pos==="bottomLeft"){return{top:undefined,bottom:20,left:20,right:undefined};}else if(pos==="topRight"){return{top:20,bottom:undefined,left:undefined,right:20};}}},{key:"fabOtherBtns",value:function fabOtherBtns(direction,i){if(direction==="up"){return{top:undefined,bottom:this.props.active===false?_reactNative.Platform.OS==="ios"?50:5:i*50+65,left:8,right:0};}else if(direction==="left"){return{top:8,bottom:0,left:this.props.active===false?_reactNative.Platform.OS==="ios"?8:8:-(i*50+58),right:0};}else if(direction==="down"){return{top:this.props.active===false?_reactNative.Platform.OS==="ios"?50:8:i*50+73,bottom:0,left:8,right:0};}else if(direction==="right"){return{top:8,bottom:0,left:this.props.active===false?_reactNative.Platform.OS==="ios"?50:8:i*50+73,right:0};}}},{key:"getInitialStyle",value:function getInitialStyle(iconStyle){return{fab:{height:56,width:56,borderRadius:28,elevation:4,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:0.4,justifyContent:"center",alignItems:"center",shadowRadius:2,position:"absolute",bottom:0,backgroundColor:"blue"},container:{position:"absolute",top:this.props.position?this.fabTopValue(this.props.position).top:undefined,bottom:this.props.position?this.fabTopValue(this.props.position).bottom:20,right:this.props.position?this.fabTopValue(this.props.position).right:20,left:this.props.position?this.fabTopValue(this.props.position).left:undefined,width:56,height:this.containerHeight,flexDirection:this.props.direction?this.props.direction==="left"||this.props.direction==="right"?"row":"column":"column",alignItems:"center"},iconStyle:_extends({color:"#fff",fontSize:24,lineHeight:_reactNative.Platform.OS=="ios"?27:undefined},iconStyle),buttonStyle:{position:"absolute",height:40,width:40,left:7,borderRadius:20,transform:this.state.active?[{scale:new _reactNative.Animated.Value(1)}]:[{scale:this.buttonScale}],marginBottom:10,backgroundColor:"blue"}};}},{key:"getContainerStyle",value:function getContainerStyle(){return _lodash2.default.merge(this.getInitialStyle().container,this.props.containerStyle);}},{key:"prepareFabProps",value:function prepareFabProps(){var defaultProps={style:this.getInitialStyle().fab};var incomingProps=_lodash2.default.clone(this.props);delete incomingProps.onPress;return(0,_computeProps2.default)(incomingProps,defaultProps);}},{key:"getOtherButtonStyle",value:function getOtherButtonStyle(child,i){var type={top:this.props.direction?this.fabOtherBtns(this.props.direction,i).top:undefined,left:this.props.direction?this.fabOtherBtns(this.props.direction,i).left:8,right:this.props.direction?this.fabOtherBtns(this.props.direction,i).right:0,bottom:this.props.direction?this.fabOtherBtns(this.props.direction,i).bottom:this.props.active===false?_reactNative.Platform.OS==="ios"?8:8:i*50+50};return _lodash2.default.merge(this.getInitialStyle().buttonStyle,_reactNative.StyleSheet.flatten(child.props.style),type);}},{key:"prepareButtonProps",value:function prepareButtonProps(child){var inp=_lodash2.default.clone(child.props);delete inp.style;var defaultProps={};return(0,_computeProps2.default)(inp,defaultProps);}},{key:"componentDidMount",value:function componentDidMount(){var _this2=this;var childrenArray=_react2.default.Children.toArray(this.props.children);var icon=_lodash2.default.remove(childrenArray,function(item){if(item.type.displayName==="Styled(Button)"){return true;}});this.setState({buttons:icon.length});this.activeTimer=setTimeout(function(){_this2.setState({active:_this2.props.active});},0);}},{key:"componentWillUnmount",value:function componentWillUnmount(){if(this.activeTimer){clearTimeout(this.activeTimer);}}},{key:"renderFab",value:function renderFab(){var childrenArray=_react2.default.Children.toArray(this.props.children);var icon=_lodash2.default.remove(childrenArray,function(item){if(item.type.displayName==="Styled(Button)"){return true;}});return _react2.default.cloneElement(childrenArray[0],{style:this.getInitialStyle(childrenArray[0].props.style).iconStyle});}},{key:"renderButtons",value:function renderButtons(){var _this3=this;var childrenArray=_react2.default.Children.toArray(this.props.children);var newChildren=[];{childrenArray.slice(1).map(function(child,i){newChildren.push(_react2.default.createElement(AnimatedFab,_extends({style:_this3.getOtherButtonStyle(child,i)},_this3.prepareButtonProps(child,i),{fabButton:true,key:i,__source:{fileName:_jsxFileName,lineNumber:279}}),child.props.children));});}return newChildren;}},{key:"upAnimate",value:function upAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerHeight,{toValue:this.state.buttons*51.3+56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"leftAnimate",value:function leftAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerWidth,{toValue:this.state.buttons*51.3+56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"rightAnimate",value:function rightAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerWidth,{toValue:this.state.buttons*51.3+56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"downAnimate",value:function downAnimate(){if(!this.props.active){_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:1}).start();}else{this.setState({active:false});_reactNative.Animated.spring(this.containerHeight,{toValue:56}).start();_reactNative.Animated.spring(this.buttonScale,{toValue:0}).start();}}},{key:"_animate",value:function _animate(){var _props=this.props,direction=_props.direction,position=_props.position;if(this.props.direction){if(this.props.direction==="up"){this.upAnimate();}else if(this.props.direction==="left"){this.leftAnimate();}else if(this.props.direction==="right"){this.rightAnimate();}else if(this.props.direction==="down"){this.downAnimate();}}else{this.upAnimate();}}},{key:"fabOnPress",value:function fabOnPress(){var _this4=this;if(this.props.onPress){this.props.onPress();this._animate();this.activeTimer=setTimeout(function(){_this4.setState({active:_this4.props.active});},100);}}},{key:"render",value:function render(){var _this5=this;var active=this.props.active;return _react2.default.createElement(_reactNative.Animated.View,{style:this.getContainerStyle(),__source:{fileName:_jsxFileName,lineNumber:424}},this.renderButtons(),_reactNative.Platform.OS==="ios"||_platform2.default.androidRipple===false||_reactNative.Platform["Version"]<=21?_react2.default.createElement(_reactNative.TouchableOpacity,_extends({onPress:function onPress(){return _this5.fabOnPress();}},this.prepareFabProps(),{activeOpacity:1,__source:{fileName:_jsxFileName,lineNumber:429}}),this.renderFab()):_react2.default.createElement(_reactNative.TouchableNativeFeedback,_extends({onPress:function onPress(){return _this5.fabOnPress();}},this.prepareFabProps(),{__source:{fileName:_jsxFileName,lineNumber:437}}),_react2.default.createElement(_reactNative.View,{style:[this.getInitialStyle().fab,this.props.style],__source:{fileName:_jsxFileName,lineNumber:441}},this.renderFab())));}}]);return Fab;}(_react.Component);var StyledFab=(0,_nativeBaseShoutemTheme.connectStyle)("NativeBase.Fab",{},_mapPropsToStyleNames2.default)(Fab);exports.Fab=StyledFab;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f6b810f5f0d9b1a4cfabaccbcf733cafc7edff42
src/utils/computeProps.js
/* @flow */ 'use strict'; import React from 'react'; import {View} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Text from './Text'; export default class BadgeNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object } prepareRootProps() { var type = { backgroundColor:this.props.primary ? this.getTheme().brandPrimary : this.props.success ? this.getTheme().brandSuccess : this.props.info ? this.getTheme().brandInfo : this.props.warning ? this.getTheme().brandWarning : this.props.danger ? this.getTheme().brandDanger : this.getTheme().badgeBg, padding: 3, paddingHorizontal: 10, alignSelf: 'flex-start', borderRadius: 13.5, height: 27 } var defaultProps = { style: type } return computeProps(this.props, defaultProps); } render() { return( <View {...this.prepareRootProps()}> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, textAlign: 'center'}}>{this.props.children} </Text> </View> ); } }
<mask> /* @flow */ <mask> 'use strict'; <mask> <mask> import React from 'react'; <mask> import {View} from 'react-native'; <mask> import NativeBaseComponent from '../Base/NativeBaseComponent'; <mask> import computeProps from '../../Utils/computeProps'; <mask> import Text from './Text'; <mask> <mask> <mask> export default class BadgeNB extends NativeBaseComponent { <mask> <mask> propTypes: { <mask> style : React.PropTypes.object <mask> } <mask> <mask> prepareRootProps() { <mask> <mask> var type = { <mask> <mask> backgroundColor:this.props.primary ? <mask> this.getTheme().brandPrimary : <mask> this.props.success ? <mask> this.getTheme().brandSuccess : <mask> this.props.info ? <mask> this.getTheme().brandInfo : <mask> this.props.warning ? <mask> this.getTheme().brandWarning : <mask> this.props.danger ? <mask> this.getTheme().brandDanger : <mask> this.getTheme().badgeBg, <mask> padding: 3, <mask> paddingHorizontal: 10, <mask> alignSelf: 'flex-start', <mask> borderRadius: 13.5, <mask> height: 27 <mask> <mask> } <mask> <mask> var defaultProps = { <mask> style: type <mask> } <mask> <mask> return computeProps(this.props, defaultProps); <mask> <mask> } <mask> render() { <mask> return( <mask> <View {...this.prepareRootProps()}> <mask> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, <mask> fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, <mask> lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, <mask> textAlign: 'center'}}>{this.props.children} <mask> </Text> <mask> </View> <mask> ); <mask> } <mask> <mask> } </s> fix inconsistent line ending style. </s> remove /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> add /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> remove var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } }
[ "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/Badge.js
/* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } }
<mask> /* @flow */ <mask> 'use strict'; <mask> <mask> import React from 'react'; <mask> import { TouchableOpacity, Platform } from 'react-native'; <mask> import NativeBaseComponent from '../Base/NativeBaseComponent'; <mask> import computeProps from '../../Utils/computeProps'; <mask> import IconNB from './Icon'; <mask> import Icon from './Icon'; <mask> import Text from './Text'; <mask> import _ from 'lodash'; <mask> <mask> <mask> export default class Button extends NativeBaseComponent { <mask> <mask> propTypes: { <mask> style : React.PropTypes.object, <mask> textStyle : React.PropTypes.object, <mask> block : React.PropTypes.bool, <mask> primary : React.PropTypes.bool, <mask> transparent : React.PropTypes.bool, <mask> success : React.PropTypes.bool, <mask> danger : React.PropTypes.bool, <mask> warning : React.PropTypes.bool, <mask> info : React.PropTypes.bool, <mask> bordered : React.PropTypes.bool, <mask> disabled : React.PropTypes.bool, <mask> rounded : React.PropTypes.bool, <mask> large : React.PropTypes.bool, <mask> small : React.PropTypes.bool, <mask> inputButton : React.PropTypes.bool <mask> } <mask> <mask> getInitialStyle() { <mask> return { <mask> button: { <mask> paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, <mask> paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, <mask> justifyContent: (this.props.block) ? 'center' : 'space-around', <mask> flexDirection: (this.props.vertical) ? 'column' : 'row', <mask> alignSelf: 'center', <mask> alignItems: 'center', <mask> backgroundColor: this.getTheme().btnPrimaryBg, <mask> elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, <mask> shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', <mask> shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, <mask> shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, <mask> shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 <mask> } <mask> } <mask> } <mask> <mask> prepareRootProps() { <mask> <mask> var type = { <mask> backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : <mask> ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : <mask> (this.props.success) ? this.getTheme().btnSuccessBg : <mask> (this.props.danger) ? this.getTheme().btnDangerBg : <mask> (this.props.warning) ? this.getTheme().btnWarningBg : <mask> (this.props.info) ? this.getTheme().btnInfoBg : <mask> (this.props.backgroundColor) ? this.props.backgroundColor : <mask> (this.props.disabled) ? this.getTheme().btnDisabledBg : <mask> this.getInitialStyle().button.backgroundColor, <mask> borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, <mask> borderWidth: (this.props.bordered) ? 1 : 0, <mask> borderColor: (this.props.primary) ? this.getTheme().primary : <mask> (this.props.success) ? this.getTheme().btnSuccessBg : <mask> (this.props.danger) ? this.getTheme().btnDangerBg : <mask> (this.props.warning) ? this.getTheme().btnWarningBg : <mask> (this.props.info) ? this.getTheme().btnInfoBg : <mask> this.getInitialStyle().button.backgroundColor, <mask> height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, <mask> alignSelf: (this.props.block) ? 'stretch' : 'flex-start' <mask> } <mask> <mask> var addedProps = _.merge(this.getInitialStyle().button,type); <mask> <mask> var defaultProps = { <mask> style: addedProps, <mask> capitalize: true <mask> } <mask> <mask> return computeProps(this.props, defaultProps); <mask> } <mask> <mask> getTextStyle() { <mask> <mask> var mergedStyle = {}; <mask> var btnType = { <mask> fontFamily: this.getTheme().btnFontFamily, <mask> marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, <mask> marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, <mask> color: <mask> ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : <mask> ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : <mask> ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : <mask> ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : <mask> ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : <mask> ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : <mask> (this.props.color) ? this.props.color : <mask> (this.props.transparent) ? this.getContextForegroundColor() : <mask> this.getTheme().inverseTextColor, <mask> <mask> fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, <mask> <mask> lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight <mask> } <mask> <mask> return _.merge(mergedStyle, btnType, this.props.textStyle); <mask> } <mask> <mask> getIconProps(icon) { <mask> <mask> var defaultStyle = { <mask> color: <mask> ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : <mask> ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : <mask> ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : <mask> ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : <mask> ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : <mask> (this.props.bordered) ? this.getTheme().btnPrimaryBg : <mask> (this.props.color) ? this.props.color : <mask> (this.props.header) ? this.getTheme().toolbarTextColor : <mask> (this.props.transparent) ? this.getContextForegroundColor() : <mask> this.getTheme().inverseTextColor, <mask> <mask> fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, <mask> lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 <mask> } <mask> <mask> var defaultProps = { <mask> style: defaultStyle <mask> } <mask> <mask> return computeProps(icon.props, defaultProps); <mask> } <mask> iconPresent() { <mask> var iconComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Icon) <mask> iconComponentPresent = true; <mask> }) <mask> return iconComponentPresent; <mask> } <mask> renderChildren() { <mask> <mask> if(typeof this.props.children == 'string') { <mask> return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> <mask> } <mask> <mask> else if(this.props.children.type == IconNB) { <mask> return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); <mask> } <mask> <mask> else if(Array.isArray(this.props.children)) { <mask> var newChildren = []; <mask> <mask> var childrenArray = React.Children.toArray(this.props.children); <mask> <mask> var iconElement = []; <mask> iconElement = _.remove(childrenArray, function(item) { <mask> if(item.type == IconNB) { <mask> return true; <mask> } <mask> }); <mask> <mask> if(this.props.iconRight) { <mask> if (childrenArray[0].type==undefined) { <mask> newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); <mask> } else { <mask> newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); <mask> } <mask> <mask> newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); <mask> } <mask> <mask> else if(this.props.iconLeft || iconElement.length>0) { <mask> newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); <mask> <mask> if (childrenArray[0].type==undefined) { <mask> newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); <mask> } else { <mask> newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); <mask> } <mask> } <mask> else { <mask> return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> <mask> } <mask> <mask> return newChildren; <mask> <mask> } <mask> <mask> else <mask> return React.cloneElement(this.props.children); <mask> <mask> } <mask> <mask> render() { <mask> return( <mask> <TouchableOpacity {...this.prepareRootProps()} > <mask> {this.renderChildren()} <mask> </TouchableOpacity> <mask> ); <mask> } <mask> } </s> fix inconsistent line ending style. </s> remove /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> add /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> remove /* @flow */ 'use strict'; import React from 'react'; import {View} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Text from './Text'; export default class BadgeNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object } prepareRootProps() { var type = { backgroundColor:this.props.primary ? this.getTheme().brandPrimary : this.props.success ? this.getTheme().brandSuccess : this.props.info ? this.getTheme().brandInfo : this.props.warning ? this.getTheme().brandWarning : this.props.danger ? this.getTheme().brandDanger : this.getTheme().badgeBg, padding: 3, paddingHorizontal: 10, alignSelf: 'flex-start', borderRadius: 13.5, height: 27 } var defaultProps = { style: type } return computeProps(this.props, defaultProps); } render() { return( <View {...this.prepareRootProps()}> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, textAlign: 'center'}}>{this.props.children} </Text> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import {View} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Text from './Text'; export default class BadgeNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object } prepareRootProps() { var type = { backgroundColor:this.props.primary ? this.getTheme().brandPrimary : this.props.success ? this.getTheme().brandSuccess : this.props.info ? this.getTheme().brandInfo : this.props.warning ? this.getTheme().brandWarning : this.props.danger ? this.getTheme().brandDanger : this.getTheme().badgeBg, padding: 3, paddingHorizontal: 10, alignSelf: 'flex-start', borderRadius: 13.5, height: 27 } var defaultProps = { style: type } return computeProps(this.props, defaultProps); } render() { return( <View {...this.prepareRootProps()}> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, textAlign: 'center'}}>{this.props.children} </Text> </View> ); } } </s> remove var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> remove console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> add console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } }
[ "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/Button.js
/* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } }
<mask> /* @flow */ <mask> 'use strict'; <mask> <mask> import React from 'react'; <mask> import clamp from 'clamp'; <mask> import {Animated, PanResponder} from 'react-native'; <mask> import NativeBaseComponent from '../Base/NativeBaseComponent'; <mask> import View from './View'; <mask> <mask> <mask> var SWIPE_THRESHOLD = 120; <mask> <mask> export default class CardSwiper extends NativeBaseComponent { <mask> <mask> constructor(props) { <mask> super(props); <mask> this.state = { <mask> pan: new Animated.ValueXY(), <mask> enter: new Animated.Value(0.5) <mask> } <mask> } <mask> <mask> componentDidMount() { <mask> this._animateEntrance(); <mask> } <mask> <mask> _animateEntrance() { <mask> Animated.spring( <mask> this.state.enter, <mask> { toValue: 1, friction: 8 } <mask> ).start(); <mask> } <mask> <mask> componentWillMount() { <mask> this._panResponder = PanResponder.create({ <mask> onMoveShouldSetResponderCapture: () => true, <mask> onMoveShouldSetPanResponderCapture: () => true, <mask> <mask> onPanResponderGrant: (e, gestureState) => { <mask> this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); <mask> this.state.pan.setValue({x: 0, y: 0}); <mask> }, <mask> <mask> onPanResponderMove: Animated.event([ <mask> null, {dx: this.state.pan.x, dy: this.state.pan.y}, <mask> ]), <mask> <mask> onPanResponderRelease: (e, {vx, vy}) => { <mask> this.state.pan.flattenOffset(); <mask> var velocity; <mask> <mask> if (vx >= 0) { <mask> velocity = clamp(vx, 3, 5); <mask> } else if (vx < 0) { <mask> velocity = clamp(vx * -1, 3, 5) * -1; <mask> } <mask> <mask> if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { <mask> if (velocity>0) { <mask> this.props.onSwipeRight(); <mask> } else { <mask> this.props.onSwipeLeft(); <mask> } <mask> Animated.decay(this.state.pan, { <mask> velocity: {x: velocity, y: vy}, <mask> deceleration: 0.98 <mask> }).start(this._resetState.bind(this)) <mask> } else { <mask> Animated.spring(this.state.pan, { <mask> toValue: {x: 0, y: 0}, <mask> friction: 4 <mask> }).start() <mask> } <mask> } <mask> }) <mask> } <mask> <mask> _resetState() { <mask> this.state.pan.setValue({x: 0, y: 0}); <mask> this.state.enter.setValue(0); <mask> this._animateEntrance(); <mask> } <mask> <mask> render() { <mask> <mask> let { pan, enter, } = this.state; <mask> <mask> let [translateX, translateY] = [pan.x, pan.y]; <mask> <mask> let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); <mask> let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) <mask> let scale = enter; <mask> <mask> let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; <mask> <mask> <mask> <mask> return( <mask> <View> <mask> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > <mask> {this.props.children} <mask> </Animated.View> <mask> </View> <mask> ); <mask> } <mask> <mask> } </s> fix inconsistent line ending style. </s> remove console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> add console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> remove }, onPanResponderRelease: (e, {vx, vy}) => { var velocity; if (vx >= 0) { velocity = clamp(vx, 4.5, 10); console.log('velocity', velocity); } else if (vx < 0) { </s> add }, onPanResponderRelease: (e, {vx, vy}) => { var velocity; if (vx >= 0) { velocity = clamp(vx, 4.5, 10); console.log('velocity', velocity); } else if (vx < 0) { </s> remove /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> add /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> remove /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } }
[ "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/CardSwiper.js
/* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); },
<mask> /* @flow */ <mask> 'use strict'; <mask> <mask> import React from 'react'; <mask> import clamp from 'clamp'; <mask> import {Animated, PanResponder, Platform} from 'react-native'; <mask> import NativeBaseComponent from '../Base/NativeBaseComponent'; <mask> import View from './View'; <mask> <mask> var SWIPE_THRESHOLD = 120; <mask> <mask> export default class CardSwiper extends NativeBaseComponent { <mask> <mask> constructor(props) { <mask> super(props); <mask> this.state = { <mask> pan: new Animated.ValueXY(), <mask> pan2: new Animated.ValueXY(), <mask> enter: new Animated.Value(0.8), <mask> selectedItem : this.props.dataSource[0], <mask> selectedItem2 : this.props.dataSource[1], <mask> card1Top: true, <mask> card2Top: false, <mask> fadeAnim: new Animated.Value(0.8) <mask> } <mask> } <mask> <mask> getInitialStyle() { <mask> return { <mask> topCard: { <mask> position: 'absolute', <mask> top: 0, <mask> right: 0, <mask> left: 0 <mask> } <mask> } <mask> } <mask> <mask> <mask> findNextIndexes() { <mask> let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); <mask> let newIdx = currentIndex + 1; <mask> let newIdx2 = currentIndex + 2; <mask> console.log(currentIndex, newIdx, newIdx2); <mask> <mask> if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { <mask> console.log("return", newIdx, 0); <mask> return [newIdx, 0]; <mask> } else if (newIdx > this.props.dataSource.length - 1) { <mask> console.log("return", 0, 1); <mask> return [0, 1]; <mask> } else { <mask> console.log("return", newIdx, newIdx2); <mask> return [newIdx, newIdx2]; <mask> } <mask> } <mask> <mask> selectNext() { <mask> let nextIndexes = this.findNextIndexes(); <mask> setTimeout( () => { <mask> this.setState({ <mask> selectedItem: this.props.dataSource[nextIndexes[0]] <mask> }); <mask> setTimeout( () => { <mask> this.setState({ <mask> selectedItem2: this.props.dataSource[nextIndexes[1]] <mask> }); <mask> console.log(this.state); <mask> }, 350); <mask> }, 50); <mask> <mask> } <mask> <mask> componentWillMount() { <mask> this._panResponder = PanResponder.create({ <mask> onMoveShouldSetResponderCapture: () => true, <mask> onMoveShouldSetPanResponderCapture: () => true, <mask> <mask> onPanResponderGrant: (e, gestureState) => { <mask> this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); <mask> this.state.pan.setValue({x: 0, y: 0}); <mask> }, <mask> <mask> onPanResponderMove: (e, gestureState) => { <mask> let val = Math.abs((gestureState.dx*.0013)); <mask> let opa = Math.abs((gestureState.dx*.0022)); <mask> if (val>0.2) { <mask> val = 0.2; </s> fix inconsistent line ending style. </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> add /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> remove /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } } </s> remove console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> add console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import {View} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Text from './Text'; export default class BadgeNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object } prepareRootProps() { var type = { backgroundColor:this.props.primary ? this.getTheme().brandPrimary : this.props.success ? this.getTheme().brandSuccess : this.props.info ? this.getTheme().brandInfo : this.props.warning ? this.getTheme().brandWarning : this.props.danger ? this.getTheme().brandDanger : this.getTheme().badgeBg, padding: 3, paddingHorizontal: 10, alignSelf: 'flex-start', borderRadius: 13.5, height: 27 } var defaultProps = { style: type } return computeProps(this.props, defaultProps); } render() { return( <View {...this.prepareRootProps()}> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, textAlign: 'center'}}>{this.props.children} </Text> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import {View} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Text from './Text'; export default class BadgeNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object } prepareRootProps() { var type = { backgroundColor:this.props.primary ? this.getTheme().brandPrimary : this.props.success ? this.getTheme().brandSuccess : this.props.info ? this.getTheme().brandInfo : this.props.warning ? this.getTheme().brandWarning : this.props.danger ? this.getTheme().brandDanger : this.getTheme().badgeBg, padding: 3, paddingHorizontal: 10, alignSelf: 'flex-start', borderRadius: 13.5, height: 27 } var defaultProps = { style: type } return computeProps(this.props, defaultProps); } render() { return( <View {...this.prepareRootProps()}> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, textAlign: 'center'}}>{this.props.children} </Text> </View> ); } }
[ "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/DeckSwiper.js
Animated.spring( this.state.enter, { toValue: 0.8+val, friction: 7 } ).start(); Animated.event([ null, {dx: this.state.pan.x},
<mask> Animated.timing( <mask> this.state.fadeAnim, <mask> {toValue: 0.8+val} <mask> ).start(); <mask> Animated.spring( <mask> this.state.enter, <mask> { toValue: 0.8+val, friction: 7 } <mask> ).start(); <mask> Animated.event([ <mask> null, {dx: this.state.pan.x}, <mask> ])(e, gestureState) <mask> }, <mask> <mask> onPanResponderRelease: (e, {vx, vy}) => { <mask> var velocity; </s> fix inconsistent line ending style. </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> remove }, onPanResponderRelease: (e, {vx, vy}) => { var velocity; if (vx >= 0) { velocity = clamp(vx, 4.5, 10); console.log('velocity', velocity); } else if (vx < 0) { </s> add }, onPanResponderRelease: (e, {vx, vy}) => { var velocity; if (vx >= 0) { velocity = clamp(vx, 4.5, 10); console.log('velocity', velocity); } else if (vx < 0) { </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> remove console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> add console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> add /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/DeckSwiper.js
}, onPanResponderRelease: (e, {vx, vy}) => { var velocity; if (vx >= 0) { velocity = clamp(vx, 4.5, 10); console.log('velocity', velocity); } else if (vx < 0) {
<mask> ).start(); <mask> Animated.event([ <mask> null, {dx: this.state.pan.x}, <mask> ])(e, gestureState) <mask> }, <mask> <mask> onPanResponderRelease: (e, {vx, vy}) => { <mask> var velocity; <mask> <mask> if (vx >= 0) { <mask> velocity = clamp(vx, 4.5, 10); <mask> console.log('velocity', velocity); <mask> } else if (vx < 0) { <mask> velocity = clamp(vx * -1, 4.5, 10) * -1; <mask> console.log('velocity', velocity); <mask> } <mask> <mask> if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { </s> fix inconsistent line ending style. </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> remove console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> add console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } } </s> remove Animated.spring( this.state.enter, { toValue: 0.8+val, friction: 7 } ).start(); Animated.event([ null, {dx: this.state.pan.x}, </s> add Animated.spring( this.state.enter, { toValue: 0.8+val, friction: 7 } ).start(); Animated.event([ null, {dx: this.state.pan.x}, </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> remove var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/DeckSwiper.js
console.log('velocity', velocity); } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.selectNext(); } else { this.selectNext(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0.8); this.state.fadeAnim.setValue(0.8); this.setState({ card1Top: !this.state.card1Top, card2Top: !this.state.card2Top }); } getCardStyles() { let { pan, pan2, enter } = this.state; let [translateX, translateY] = [pan.x, pan.y]; // let [translateX, translateY] = [pan2.x, pan2.y]; let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; let animatedCardStyles2 = {transform: [{scale}]}; return [animatedCardStyles, animatedCardStyles2] } render() { return( <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : (<View> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> {this.props.renderItem(this.state.selectedItem2)} </Animated.View> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > {this.props.renderItem(this.state.selectedItem)} </Animated.View> </View> ) } </View> ); } }
<mask> velocity = clamp(vx, 4.5, 10); <mask> console.log('velocity', velocity); <mask> } else if (vx < 0) { <mask> velocity = clamp(vx * -1, 4.5, 10) * -1; <mask> console.log('velocity', velocity); <mask> } <mask> <mask> if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { <mask> <mask> if (velocity>0) { <mask> this.selectNext(); <mask> } else { <mask> this.selectNext(); <mask> } <mask> <mask> Animated.decay(this.state.pan, { <mask> velocity: {x: velocity, y: vy}, <mask> deceleration: 0.98 <mask> }).start(this._resetState.bind(this)) <mask> } else { <mask> Animated.spring(this.state.pan, { <mask> toValue: {x: 0, y: 0}, <mask> friction: 4 <mask> }).start() <mask> } <mask> } <mask> }) <mask> } <mask> <mask> _resetState() { <mask> this.state.pan.setValue({x: 0, y: 0}); <mask> this.state.enter.setValue(0.8); <mask> this.state.fadeAnim.setValue(0.8); <mask> this.setState({ <mask> card1Top: !this.state.card1Top, <mask> card2Top: !this.state.card2Top <mask> }); <mask> <mask> } <mask> <mask> getCardStyles() { <mask> <mask> let { pan, pan2, enter } = this.state; <mask> <mask> let [translateX, translateY] = [pan.x, pan.y]; <mask> // let [translateX, translateY] = [pan2.x, pan2.y]; <mask> <mask> let rotate = pan.x.interpolate({inputRange: [-700, 0, 700], outputRange: ['-10deg', '0deg', '10deg']}); <mask> <mask> let opacity = pan.x.interpolate({inputRange: [-320, 0, 320], outputRange: [0.9, 1, 0.9]}) <mask> let scale = enter; <mask> <mask> let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}], opacity}; <mask> let animatedCardStyles2 = {transform: [{scale}]}; <mask> <mask> return [animatedCardStyles, animatedCardStyles2] <mask> } <mask> <mask> render() { <mask> <mask> <mask> return( <mask> <View style={{position: 'relative', flexDirection: 'column'}}>{(this.state.selectedItem)===undefined ? (<View />) : <mask> (<View> <mask> <Animated.View style={[this.getCardStyles()[1],{opacity: this.state.fadeAnim}]} {...this._panResponder.panHandlers}> <mask> {this.props.renderItem(this.state.selectedItem2)} <mask> </Animated.View> <mask> <Animated.View style={[ this.getCardStyles()[0], this.getInitialStyle().topCard] } {...this._panResponder.panHandlers} > <mask> {this.props.renderItem(this.state.selectedItem)} <mask> </Animated.View> <mask> </View> <mask> ) <mask> } <mask> </View> <mask> ); <mask> } <mask> <mask> } </s> fix inconsistent line ending style. </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> remove }, onPanResponderRelease: (e, {vx, vy}) => { var velocity; if (vx >= 0) { velocity = clamp(vx, 4.5, 10); console.log('velocity', velocity); } else if (vx < 0) { </s> add }, onPanResponderRelease: (e, {vx, vy}) => { var velocity; if (vx >= 0) { velocity = clamp(vx, 4.5, 10); console.log('velocity', velocity); } else if (vx < 0) { </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> remove var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() { </s> add /* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/DeckSwiper.js
/* @flow */ 'use strict'; import React from 'react'; import {Image, TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Icon from './Icon'; import Text from './Text'; import View from './View'; import Button from './Button'; import Badge from './Badge'; import Thumbnail from './Thumbnail'; import CheckBox from './Checkbox'; import Picker from './Picker'; import Radio from './Radio'; import InputGroup from './InputGroup'; import _ from 'lodash'; export default class ListItemNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, header : React.PropTypes.bool, iconRight : React.PropTypes.bool, iconLeft : React.PropTypes.bool, button : React.PropTypes.bool, itemDivider : React.PropTypes.bool } getInitialStyle() { return { listItem: { borderBottomWidth: this.getTheme().borderWidth, // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, marginLeft: 15, padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, paddingLeft: 2, justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', flexDirection: this.stackedPresent() ? 'column' : 'row', alignItems: 'center', borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor }, listItemDivider: { borderBottomWidth: this.getTheme().borderWidth, height: this.getTheme().listItemHeight, padding: this.getTheme().listItemPadding, backgroundColor: this.getTheme().listDividerBg, justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', flexDirection: 'row', borderColor: this.getTheme().listBorderColor }, itemText: { fontSize: 16, marginLeft: (this.props.iconLeft) ? 10 : 0, color: this.getContextForegroundColor() }, dividerItemText: { fontSize: 16, fontWeight: '500' }, itemIcon: { fontSize: this.getTheme().iconFontSize, color: this.getContextForegroundColor(), lineHeight: (Platform.OS === 'ios') ? 34 : undefined }, itemNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, alignSelf: 'center', fontWeight: '100', flex: 1, textAlign: 'right' }, itemSubNote: { fontSize: this.getTheme().listNoteSize, color: this.getTheme().listNoteColor, lineHeight: 16 }, thumbnail: { alignSelf: 'center' }, fullImage: { width: 300, height: 300 }, itemButton: {} } } getRightStyle() { return { right : { flex: 1, paddingLeft: 10 }, right2 : { flex: 1, flexDirection: 'row', paddingLeft: 10, alignItems: 'center', justifyContent: 'space-between' }, right3 : { flex: 1, flexDirection: 'column', paddingLeft: 10, alignSelf: 'flex-start' } } } thumbnailPresent() { var thumbnailComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Thumbnail) thumbnailComponentPresent = true; }) return thumbnailComponentPresent; } checkBoxPresent() { var checkBoxComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == CheckBox) checkBoxComponentPresent = true; }) return checkBoxComponentPresent; } radioPresent() { var radioComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Radio) radioComponentPresent = true; }) return radioComponentPresent; } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } pickerPresent() { var pickerComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Picker) pickerComponentPresent = true; }) return pickerComponentPresent; } badgePresent() { var badgeComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Badge) badgeComponentPresent = true; }) return badgeComponentPresent; } inputPresent() { var inputComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup) inputComponentPresent = true; }) return inputComponentPresent; } buttonPresent() { var buttonComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Button) buttonComponentPresent = true; }) return buttonComponentPresent; } getChildProps(child) { var defaultProps = {}; if(child.type == Image && !Array.isArray(this.props.children)) { defaultProps = { resizeMode: 'stretch', style: this.getInitialStyle().fullImage } } else if(child.type == Button) { defaultProps = { small: true, style: this.getInitialStyle().itemButton } } else if(child.type == InputGroup) { defaultProps = { style: { borderColor:(this.props.children.props.success) ? this.getTheme().inputSuccessBorderColor : (this.props.children.props.error) ? this.getTheme().inputErrorBorderColor : this.getTheme().listBorderColor }, foregroundColor: this.getContextForegroundColor() } } else if(child.type == Text) { if (this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().dividerItemText } } else { if(child.props.note && this.thumbnailPresent()) { defaultProps = { style: this.getInitialStyle().itemSubNote } } else if(child.props.note) { defaultProps = { style: this.getInitialStyle().itemNote } } else { defaultProps = { style: this.getInitialStyle().itemText } } } } else if(child.type == Icon) { defaultProps = { style: this.getInitialStyle().itemIcon } } else if(child.type == Picker) { defaultProps = { style: { flex: .45, alignSelf: 'flex-end', paddingVertical: 5, height: 30 }, textStyle: { color: '#7a7a7a' } } } else if(child.type == Thumbnail) { defaultProps = { style: this.getInitialStyle().thumbnail } } else { defaultProps = { foregroundColor: this.getContextForegroundColor() } } return computeProps(child.props, defaultProps); } prepareRootProps() { var defaultProps = {}; if(this.props.itemDivider) { defaultProps = { style: this.getInitialStyle().listItemDivider }; } else { defaultProps = { style: this.getInitialStyle().listItem }; } return computeProps(this.props, defaultProps); } notePresent() { var notePresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Text && child.props.note) notePresent = true; }) return notePresent; } insetPresent() { var insetPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == InputGroup && child.props.inset) insetPresent = true; }) return insetPresent; } inlinePresent() { var inlineComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { inlineComponentPresent = true; } else inlineComponentPresent = false; } return inlineComponentPresent; } stackedPresent() { var stackedComponentPresent = false; if (this.inputPresent()) { if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { stackedComponentPresent = true; } else stackedComponentPresent = false; } return stackedComponentPresent; } squareThumbs() { var squareThumbs = false; if (this.thumbnailPresent()) { React.Children.forEach(this.props.children, function (child) { if(child.props.square) squareThumbs = true; }) } return squareThumbs; } renderChildren() {
<mask> /* @flow */ <mask> 'use strict'; <mask> <mask> import React from 'react'; <mask> import {Image, TouchableOpacity, Platform } from 'react-native'; <mask> import NativeBaseComponent from '../Base/NativeBaseComponent'; <mask> import computeProps from '../../Utils/computeProps'; <mask> import Icon from './Icon'; <mask> import Text from './Text'; <mask> import View from './View'; <mask> import Button from './Button'; <mask> import Badge from './Badge'; <mask> import Thumbnail from './Thumbnail'; <mask> import CheckBox from './Checkbox'; <mask> import Picker from './Picker'; <mask> import Radio from './Radio'; <mask> import InputGroup from './InputGroup'; <mask> import _ from 'lodash'; <mask> <mask> export default class ListItemNB extends NativeBaseComponent { <mask> <mask> propTypes: { <mask> style : React.PropTypes.object, <mask> header : React.PropTypes.bool, <mask> iconRight : React.PropTypes.bool, <mask> iconLeft : React.PropTypes.bool, <mask> button : React.PropTypes.bool, <mask> itemDivider : React.PropTypes.bool <mask> } <mask> <mask> getInitialStyle() { <mask> <mask> return { <mask> listItem: { <mask> borderBottomWidth: this.getTheme().borderWidth, <mask> // height: (this.inputPresent()) ? undefined: this.getTheme().listItemHeight, <mask> marginLeft: 15, <mask> padding: this.inputPresent() ? 0 : this.getTheme().listItemPadding, <mask> paddingLeft: 2, <mask> justifyContent: ((this.props.iconRight && !this.props.iconLeft) || (this.props.iconRight && this.props.iconLeft)) ? 'space-between' : 'flex-start', <mask> flexDirection: this.stackedPresent() ? 'column' : 'row', <mask> alignItems: 'center', <mask> borderColor: (this.inputPresent() && !this.inlinePresent() ) ? 'transparent' : this.getTheme().listBorderColor <mask> }, <mask> listItemDivider: { <mask> borderBottomWidth: this.getTheme().borderWidth, <mask> height: this.getTheme().listItemHeight, <mask> padding: this.getTheme().listItemPadding, <mask> backgroundColor: this.getTheme().listDividerBg, <mask> justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start', <mask> flexDirection: 'row', <mask> borderColor: this.getTheme().listBorderColor <mask> }, <mask> itemText: { <mask> fontSize: 16, <mask> marginLeft: (this.props.iconLeft) ? 10 : 0, <mask> color: this.getContextForegroundColor() <mask> }, <mask> dividerItemText: { <mask> fontSize: 16, <mask> fontWeight: '500' <mask> }, <mask> itemIcon: { <mask> fontSize: this.getTheme().iconFontSize, <mask> color: this.getContextForegroundColor(), <mask> lineHeight: (Platform.OS === 'ios') ? 34 : undefined <mask> }, <mask> itemNote: { <mask> fontSize: this.getTheme().listNoteSize, <mask> color: this.getTheme().listNoteColor, <mask> alignSelf: 'center', <mask> fontWeight: '100', <mask> flex: 1, <mask> textAlign: 'right' <mask> }, <mask> itemSubNote: { <mask> fontSize: this.getTheme().listNoteSize, <mask> color: this.getTheme().listNoteColor, <mask> lineHeight: 16 <mask> }, <mask> thumbnail: { <mask> alignSelf: 'center' <mask> }, <mask> fullImage: { <mask> width: 300, <mask> height: 300 <mask> }, <mask> itemButton: {} <mask> <mask> } <mask> } <mask> <mask> getRightStyle() { <mask> return { <mask> right : { <mask> flex: 1, <mask> paddingLeft: 10 <mask> <mask> }, <mask> right2 : { <mask> flex: 1, <mask> flexDirection: 'row', <mask> paddingLeft: 10, <mask> alignItems: 'center', <mask> justifyContent: 'space-between' <mask> <mask> }, <mask> right3 : { <mask> flex: 1, <mask> flexDirection: 'column', <mask> paddingLeft: 10, <mask> alignSelf: 'flex-start' <mask> <mask> } <mask> } <mask> } <mask> <mask> thumbnailPresent() { <mask> var thumbnailComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Thumbnail) <mask> thumbnailComponentPresent = true; <mask> }) <mask> <mask> return thumbnailComponentPresent; <mask> } <mask> <mask> checkBoxPresent() { <mask> var checkBoxComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == CheckBox) <mask> checkBoxComponentPresent = true; <mask> }) <mask> <mask> return checkBoxComponentPresent; <mask> } <mask> <mask> radioPresent() { <mask> var radioComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Radio) <mask> radioComponentPresent = true; <mask> }) <mask> <mask> return radioComponentPresent; <mask> } <mask> <mask> iconPresent() { <mask> var iconComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Icon) <mask> iconComponentPresent = true; <mask> }) <mask> return iconComponentPresent; <mask> } <mask> <mask> pickerPresent() { <mask> var pickerComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Picker) <mask> pickerComponentPresent = true; <mask> }) <mask> <mask> return pickerComponentPresent; <mask> } <mask> <mask> badgePresent() { <mask> var badgeComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Badge) <mask> badgeComponentPresent = true; <mask> }) <mask> <mask> return badgeComponentPresent; <mask> } <mask> <mask> inputPresent() { <mask> var inputComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == InputGroup) <mask> inputComponentPresent = true; <mask> }) <mask> return inputComponentPresent; <mask> } <mask> <mask> buttonPresent() { <mask> var buttonComponentPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Button) <mask> buttonComponentPresent = true; <mask> }) <mask> <mask> return buttonComponentPresent; <mask> } <mask> <mask> getChildProps(child) { <mask> var defaultProps = {}; <mask> <mask> if(child.type == Image && !Array.isArray(this.props.children)) { <mask> defaultProps = { <mask> resizeMode: 'stretch', <mask> style: this.getInitialStyle().fullImage <mask> } <mask> } <mask> else if(child.type == Button) { <mask> defaultProps = { <mask> small: true, <mask> style: this.getInitialStyle().itemButton <mask> } <mask> } <mask> else if(child.type == InputGroup) { <mask> <mask> defaultProps = { <mask> style: { <mask> borderColor:(this.props.children.props.success) ? <mask> this.getTheme().inputSuccessBorderColor : <mask> (this.props.children.props.error) ? <mask> this.getTheme().inputErrorBorderColor : <mask> this.getTheme().listBorderColor <mask> }, <mask> foregroundColor: this.getContextForegroundColor() <mask> } <mask> } <mask> else if(child.type == Text) { <mask> if (this.props.itemDivider) { <mask> defaultProps = { <mask> style: this.getInitialStyle().dividerItemText <mask> } <mask> } else { <mask> if(child.props.note && this.thumbnailPresent()) { <mask> defaultProps = { <mask> style: this.getInitialStyle().itemSubNote <mask> } <mask> } <mask> else if(child.props.note) { <mask> defaultProps = { <mask> style: this.getInitialStyle().itemNote <mask> } <mask> } <mask> else { <mask> defaultProps = { <mask> style: this.getInitialStyle().itemText <mask> } <mask> } <mask> <mask> } <mask> } <mask> else if(child.type == Icon) { <mask> defaultProps = { <mask> style: this.getInitialStyle().itemIcon <mask> } <mask> } <mask> else if(child.type == Picker) { <mask> defaultProps = { <mask> style: { <mask> flex: .45, <mask> alignSelf: 'flex-end', <mask> paddingVertical: 5, <mask> height: 30 <mask> }, <mask> textStyle: { <mask> color: '#7a7a7a' <mask> } <mask> } <mask> } <mask> else if(child.type == Thumbnail) { <mask> defaultProps = { <mask> style: this.getInitialStyle().thumbnail <mask> } <mask> } <mask> else { <mask> defaultProps = { <mask> foregroundColor: this.getContextForegroundColor() <mask> } <mask> } <mask> return computeProps(child.props, defaultProps); <mask> } <mask> <mask> prepareRootProps() { <mask> var defaultProps = {}; <mask> <mask> if(this.props.itemDivider) { <mask> defaultProps = { <mask> style: this.getInitialStyle().listItemDivider <mask> }; <mask> } <mask> else { <mask> defaultProps = { <mask> style: this.getInitialStyle().listItem <mask> }; <mask> } <mask> return computeProps(this.props, defaultProps); <mask> } <mask> <mask> <mask> notePresent() { <mask> <mask> var notePresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == Text && child.props.note) <mask> notePresent = true; <mask> }) <mask> return notePresent; <mask> <mask> } <mask> <mask> insetPresent() { <mask> <mask> var insetPresent = false; <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.type == InputGroup && child.props.inset) <mask> insetPresent = true; <mask> }) <mask> <mask> return insetPresent; <mask> <mask> } <mask> <mask> <mask> inlinePresent() { <mask> var inlineComponentPresent = false; <mask> if (this.inputPresent()) { <mask> if (this.props.children.props.children.props && this.props.children.props.children.props.inlineLabel) { <mask> inlineComponentPresent = true; <mask> } <mask> else <mask> inlineComponentPresent = false; <mask> } <mask> return inlineComponentPresent; <mask> } <mask> <mask> stackedPresent() { <mask> var stackedComponentPresent = false; <mask> if (this.inputPresent()) { <mask> if (this.props.children.props.children.props && this.props.children.props.children.props.stackedLabel) { <mask> stackedComponentPresent = true; <mask> } <mask> else <mask> stackedComponentPresent = false; <mask> } <mask> <mask> return stackedComponentPresent; <mask> } <mask> <mask> <mask> <mask> squareThumbs() { <mask> var squareThumbs = false; <mask> if (this.thumbnailPresent()) { <mask> React.Children.forEach(this.props.children, function (child) { <mask> if(child.props.square) <mask> squareThumbs = true; <mask> }) <mask> <mask> } <mask> return squareThumbs; <mask> <mask> } <mask> <mask> renderChildren() { <mask> this.iconPresent(); <mask> <mask> var newChildren = []; <mask> if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { <mask> newChildren.push( </s> fix inconsistent line ending style. </s> remove /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import { TouchableOpacity, Platform } from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import IconNB from './Icon'; import Icon from './Icon'; import Text from './Text'; import _ from 'lodash'; export default class Button extends NativeBaseComponent { propTypes: { style : React.PropTypes.object, textStyle : React.PropTypes.object, block : React.PropTypes.bool, primary : React.PropTypes.bool, transparent : React.PropTypes.bool, success : React.PropTypes.bool, danger : React.PropTypes.bool, warning : React.PropTypes.bool, info : React.PropTypes.bool, bordered : React.PropTypes.bool, disabled : React.PropTypes.bool, rounded : React.PropTypes.bool, large : React.PropTypes.bool, small : React.PropTypes.bool, inputButton : React.PropTypes.bool } getInitialStyle() { return { button: { paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding, paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2, justifyContent: (this.props.block) ? 'center' : 'space-around', flexDirection: (this.props.vertical) ? 'column' : 'row', alignSelf: 'center', alignItems: 'center', backgroundColor: this.getTheme().btnPrimaryBg, elevation: (this.props.transparent || this.props.bordered) ? 0 : 3, shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000', shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2}, shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2, shadowRadius: (this.props.transparent || this.props.bordered) ? undefined : 2 } } } prepareRootProps() { var type = { backgroundColor: (this.props.primary) ? this.getTheme().btnPrimaryBg : ((this.props.transparent) || (this.props.bordered)) ? 'rgba(0,0,0,0)' : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : (this.props.backgroundColor) ? this.props.backgroundColor : (this.props.disabled) ? this.getTheme().btnDisabledBg : this.getInitialStyle().button.backgroundColor, borderRadius: (this.props.rounded) ? this.getTheme().borderRadiusLarge : this.getTheme().borderRadiusBase, borderWidth: (this.props.bordered) ? 1 : 0, borderColor: (this.props.primary) ? this.getTheme().primary : (this.props.success) ? this.getTheme().btnSuccessBg : (this.props.danger) ? this.getTheme().btnDangerBg : (this.props.warning) ? this.getTheme().btnWarningBg : (this.props.info) ? this.getTheme().btnInfoBg : this.getInitialStyle().button.backgroundColor, height: (this.props.large) ? 60 : (this.props.small) ? 35 : 38, alignSelf: (this.props.block) ? 'stretch' : 'flex-start' } var addedProps = _.merge(this.getInitialStyle().button,type); var defaultProps = { style: addedProps, capitalize: true } return computeProps(this.props, defaultProps); } getTextStyle() { var mergedStyle = {}; var btnType = { fontFamily: this.getTheme().btnFontFamily, marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0, marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0, color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : ((this.props.bordered)) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().btnTextSizeLarge : (this.props.small) ? this.getTheme().btnTextSizeSmall : this.getTheme().btnTextSize, lineHeight: (this.props.large) ? 29 : (this.props.small) ? 16 : this.getTheme().btnLineHeight } return _.merge(mergedStyle, btnType, this.props.textStyle); } getIconProps(icon) { var defaultStyle = { color: ((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg : ((this.props.bordered) && (this.props.success)) ? this.getTheme().btnSuccessBg : ((this.props.bordered) && (this.props.danger)) ? this.getTheme().btnDangerBg : ((this.props.bordered) && (this.props.warning)) ? this.getTheme().btnWarningBg : ((this.props.bordered) && (this.props.info)) ? this.getTheme().btnInfoBg : (this.props.bordered) ? this.getTheme().btnPrimaryBg : (this.props.color) ? this.props.color : (this.props.header) ? this.getTheme().toolbarTextColor : (this.props.transparent) ? this.getContextForegroundColor() : this.getTheme().inverseTextColor, fontSize: (this.props.large) ? this.getTheme().iconSizeLarge : (this.props.small) ? this.getTheme().iconSizeSmall : (this.props.inputButton) ? this.getTheme().toolbarIconSize : this.getTheme().iconFontSize-5, lineHeight: (this.props.large) ? 52: (this.props.small || this.props.inputButton) ? 22 : this.getTheme().iconLineHeight-9 } var defaultProps = { style: defaultStyle } return computeProps(icon.props, defaultProps); } iconPresent() { var iconComponentPresent = false; React.Children.forEach(this.props.children, function (child) { if(child.type == Icon) iconComponentPresent = true; }) return iconComponentPresent; } renderChildren() { if(typeof this.props.children == 'string') { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? this.props.children : this.props.children.toUpperCase()}</Text> } else if(this.props.children.type == IconNB) { return React.cloneElement(this.props.children, this.getIconProps(this.props.children)); } else if(Array.isArray(this.props.children)) { var newChildren = []; var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; iconElement = _.remove(childrenArray, function(item) { if(item.type == IconNB) { return true; } }); if(this.props.iconRight) { if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); } else if(this.props.iconLeft || iconElement.length>0) { newChildren.push(<Text key='icon'>{React.cloneElement(iconElement[0], this.getIconProps(iconElement[0]))}</Text>); if (childrenArray[0].type==undefined) { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0] : childrenArray[0].toUpperCase()}</Text>); } else { newChildren.push(<Text key='label' style={this.getTextStyle()}>{(Platform.OS==='ios' || !this.props.capitalize) ? childrenArray[0].props.children : childrenArray[0].props.children.toUpperCase()}</Text>); } } else { return <Text style={this.getTextStyle()}>{(Platform.OS==='ios') ? this.props.children : this.props.children.toUpperCase()}</Text> } return newChildren; } else return React.cloneElement(this.props.children); } render() { return( <TouchableOpacity {...this.prepareRootProps()} > {this.renderChildren()} </TouchableOpacity> ); } } </s> remove var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> add var newChildren = []; if(!Array.isArray(this.props.children) && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push( <View key='listItem' style={{alignSelf: 'stretch', flex:1, justifyContent: 'center'}}> {React.cloneElement(this.props.children, this.getChildProps(this.props.children))} </View> ); } else { var childrenArray = React.Children.toArray(this.props.children); var iconElement = []; if (this.props.iconLeft && !this.props.iconRight) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', justifyContent: 'space-between', flex: 1}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.pickerPresent()) { let pickerElement = _.remove(childrenArray, function(item) { if(item.type == Picker) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(pickerElement[0], {...this.getChildProps(pickerElement[0]), key: 'listItem1' })); } else if (this.props.iconRight && !this.props.iconLeft) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem1'})); } else if (this.badgePresent()) { var badgeElement = _.remove(childrenArray, function(item) { if(item.type == Badge) { return true; } }); newChildren.push(<View key='listItem0' > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(badgeElement[0], {...this.getChildProps(badgeElement[0]), key: 'listItem1'})); } else if (this.props.iconLeft && this.props.iconRight) { iconElement = _.filter(childrenArray, function(item) { if(item.type == Icon) { return true; } }); newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between'}} > {childrenArray.slice(0,2).map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(React.cloneElement(iconElement[1], {...this.getChildProps(iconElement[1]), key: 'listItem1'})); } else if (this.thumbnailPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Thumbnail) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], {...this.getChildProps(iconElement[0]), key: 'listItem0'})); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.checkBoxPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == CheckBox) { return true; } }); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', paddingLeft: 15, alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); } else if (this.radioPresent()) { iconElement = _.remove(childrenArray, function(item) { if(item.type == Radio) { return true; } }); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: (this.squareThumbs()) ? 'flex-start' : 'center', flex: 1 }} > {childrenArray.map((child) => { return React.cloneElement(child, this.getChildProps(child)); })} </View>); newChildren.push(React.cloneElement(iconElement[0], this.getChildProps(iconElement[0]))); } else if (this.inputPresent() && !this.inlinePresent() && !this.stackedPresent() && !this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'column', alignSelf: 'center', flex: 1 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } else if (this.inlinePresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'center', flex: 1, borderColor: this.getTheme().listBorderColor, alignItems: 'center', height: this.getTheme().inputHeightBase }} > <Text style={{color: this.getTheme().inputColorPlaceholder }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'column', alignSelf: 'center', flex: 2.2 }} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{borderWidth: 0}}); })} </View>); } else if (this.stackedPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', justifyContent: 'flex-start', alignSelf: 'stretch', alignItems: 'center', height: this.getTheme().inputHeightBase, paddingLeft: 10 }} > <Text style={{color: this.getTheme().inputColorPlaceholder, textAlign: 'left', fontSize: 15 }}>{this.props.children.props.children.props.label}</Text> </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i, style:{flex:1}}); })} </View>); } else if (this.insetPresent()) { newChildren.push(<View key='listItem0' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); newChildren.push(<View key='listItem1' style={{flexDirection: 'row', alignSelf: 'stretch', flex: 1 , padding: 0}} > {childrenArray.map((child, i) => { return React.cloneElement(child, {...this.getChildProps(child), key: i}); })} </View>); } } return newChildren; } render() { return( <TouchableOpacity {...this.prepareRootProps()} activeOpacity={ (this.props.button) ? 0.2 : 1} > {this.renderChildren()} </TouchableOpacity> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import {View} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Text from './Text'; export default class BadgeNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object } prepareRootProps() { var type = { backgroundColor:this.props.primary ? this.getTheme().brandPrimary : this.props.success ? this.getTheme().brandSuccess : this.props.info ? this.getTheme().brandInfo : this.props.warning ? this.getTheme().brandWarning : this.props.danger ? this.getTheme().brandDanger : this.getTheme().badgeBg, padding: 3, paddingHorizontal: 10, alignSelf: 'flex-start', borderRadius: 13.5, height: 27 } var defaultProps = { style: type } return computeProps(this.props, defaultProps); } render() { return( <View {...this.prepareRootProps()}> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, textAlign: 'center'}}>{this.props.children} </Text> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import {View} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import computeProps from '../../Utils/computeProps'; import Text from './Text'; export default class BadgeNB extends NativeBaseComponent { propTypes: { style : React.PropTypes.object } prepareRootProps() { var type = { backgroundColor:this.props.primary ? this.getTheme().brandPrimary : this.props.success ? this.getTheme().brandSuccess : this.props.info ? this.getTheme().brandInfo : this.props.warning ? this.getTheme().brandWarning : this.props.danger ? this.getTheme().brandDanger : this.getTheme().badgeBg, padding: 3, paddingHorizontal: 10, alignSelf: 'flex-start', borderRadius: 13.5, height: 27 } var defaultProps = { style: type } return computeProps(this.props, defaultProps); } render() { return( <View {...this.prepareRootProps()}> <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, textAlign: 'center'}}>{this.props.children} </Text> </View> ); } } </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder, Platform} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), pan2: new Animated.ValueXY(), enter: new Animated.Value(0.8), selectedItem : this.props.dataSource[0], selectedItem2 : this.props.dataSource[1], card1Top: true, card2Top: false, fadeAnim: new Animated.Value(0.8) } } getInitialStyle() { return { topCard: { position: 'absolute', top: 0, right: 0, left: 0 } } } findNextIndexes() { let currentIndex = this.props.dataSource.indexOf(this.state.selectedItem); let newIdx = currentIndex + 1; let newIdx2 = currentIndex + 2; console.log(currentIndex, newIdx, newIdx2); if(newIdx2 > this.props.dataSource.length - 1 && newIdx === this.props.dataSource.length - 1) { console.log("return", newIdx, 0); return [newIdx, 0]; } else if (newIdx > this.props.dataSource.length - 1) { console.log("return", 0, 1); return [0, 1]; } else { console.log("return", newIdx, newIdx2); return [newIdx, newIdx2]; } } selectNext() { let nextIndexes = this.findNextIndexes(); setTimeout( () => { this.setState({ selectedItem: this.props.dataSource[nextIndexes[0]] }); setTimeout( () => { this.setState({ selectedItem2: this.props.dataSource[nextIndexes[1]] }); console.log(this.state); }, 350); }, 50); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, </s> remove /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } } </s> add /* @flow */ 'use strict'; import React from 'react'; import clamp from 'clamp'; import {Animated, PanResponder} from 'react-native'; import NativeBaseComponent from '../Base/NativeBaseComponent'; import View from './View'; var SWIPE_THRESHOLD = 120; export default class CardSwiper extends NativeBaseComponent { constructor(props) { super(props); this.state = { pan: new Animated.ValueXY(), enter: new Animated.Value(0.5) } } componentDidMount() { this._animateEntrance(); } _animateEntrance() { Animated.spring( this.state.enter, { toValue: 1, friction: 8 } ).start(); } componentWillMount() { this._panResponder = PanResponder.create({ onMoveShouldSetResponderCapture: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: (e, gestureState) => { this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value}); this.state.pan.setValue({x: 0, y: 0}); }, onPanResponderMove: Animated.event([ null, {dx: this.state.pan.x, dy: this.state.pan.y}, ]), onPanResponderRelease: (e, {vx, vy}) => { this.state.pan.flattenOffset(); var velocity; if (vx >= 0) { velocity = clamp(vx, 3, 5); } else if (vx < 0) { velocity = clamp(vx * -1, 3, 5) * -1; } if (Math.abs(this.state.pan.x._value) > SWIPE_THRESHOLD) { if (velocity>0) { this.props.onSwipeRight(); } else { this.props.onSwipeLeft(); } Animated.decay(this.state.pan, { velocity: {x: velocity, y: vy}, deceleration: 0.98 }).start(this._resetState.bind(this)) } else { Animated.spring(this.state.pan, { toValue: {x: 0, y: 0}, friction: 4 }).start() } } }) } _resetState() { this.state.pan.setValue({x: 0, y: 0}); this.state.enter.setValue(0); this._animateEntrance(); } render() { let { pan, enter, } = this.state; let [translateX, translateY] = [pan.x, pan.y]; let rotate = pan.x.interpolate({inputRange: [-300, 0, 300], outputRange: ['-30deg', '0deg', '30deg']}); let opacity = pan.x.interpolate({inputRange: [-150, 0, 150], outputRange: [0.5, 1, 0.5]}) let scale = enter; let animatedCardStyles = {transform: [{translateX}, {translateY}, {rotate}, {scale}], opacity}; return( <View> <Animated.View style={ animatedCardStyles } {...this._panResponder.panHandlers} > {this.props.children} </Animated.View> </View> ); } }
[ "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/GeekyAnts/NativeBase/commit/f76c9c4d30829ce12136d73e4bb63d556af8bea3
Components/Widgets/ListItem.js