{"size": 9605, "ext": "js", "max_stars_repo_path": "dist/components/CarouselHeader.js", "max_stars_repo_name": "wlc-/react-native-carousel-component", "max_stars_repo_stars_event_min_datetime": "2017-02-20T06:15:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-03T18:30:07.000Z", "max_issues_repo_path": "dist/components/CarouselHeader.js", "max_issues_repo_name": "wlc-/react-native-carousel-component", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dist/components/CarouselHeader.js", "max_forks_repo_name": "wlc-/react-native-carousel-component", "max_forks_repo_forks_event_min_datetime": "2017-02-24T15:18:28.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-06T02:44:52.000Z"}
{"max_stars_count": 67, "max_issues_count": null, "max_forks_count": 10, "avg_line_length": 9605.0, "max_line_length": 9605, "alphanum_fraction": 0.8125976054}
Object.defineProperty(exports,"__esModule",{value:true});var _jsxFileName='src/components/CarouselHeader.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 _reactNative=require('react-native');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}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 STATUS_BAR_HEIGHT=_reactNative.Platform.OS==='ios'?20:25;var HEADER_HEIGHT=_reactNative.Platform.OS==='ios'?44+STATUS_BAR_HEIGHT:56+STATUS_BAR_HEIGHT;var styles=_reactNative.StyleSheet.create({toolbarContainer:{paddingTop:STATUS_BAR_HEIGHT},toolbar:{height:HEADER_HEIGHT-STATUS_BAR_HEIGHT},header:{backgroundColor:'transparent',paddingTop:STATUS_BAR_HEIGHT,height:HEADER_HEIGHT,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},titleText:{color:'white',fontWeight:'bold',fontSize:20},leftItem:{flex:1,alignItems:'flex-start'},centerItem:{flex:2,alignItems:'center'},rightItem:{flex:1,alignItems:'flex-end'},itemWrapper:{padding:11},itemText:{letterSpacing:1,fontSize:12,color:'white'}});var defaultProps={title:null,leftItem:null,rightItem:null,extraItems:null,foreground:null,style:null,children:null};var HeaderAndroid=function(_Component){_inherits(HeaderAndroid,_Component);function HeaderAndroid(props){_classCallCheck(this,HeaderAndroid);var _this=_possibleConstructorReturn(this,(HeaderAndroid.__proto__||Object.getPrototypeOf(HeaderAndroid)).call(this,props));_this.handleActionSelected=_this.handleActionSelected.bind(_this);return _this;}_createClass(HeaderAndroid,[{key:'handleActionSelected',value:function handleActionSelected(position){var _props=this.props,rightItem=_props.rightItem,extraItems=_props.extraItems;var items=extraItems||[];if(rightItem){items=[rightItem].concat(_toConsumableArray(items));}var item=items[position];if(item&&item.onPress){item.onPress();}}},{key:'render',value:function render(){var _props2=this.props,style=_props2.style,leftItem=_props2.leftItem,rightItem=_props2.rightItem,extraItems=_props2.extraItems,foreground=_props2.foreground,children=_props2.children;var actions=[];if(rightItem){var _title=rightItem.title,_icon=rightItem.icon,_layout=rightItem.layout;actions.push({icon:_layout!=='title'?_icon:undefined,title:_title,show:'always'});}if(extraItems){actions=actions.concat(extraItems.map(function(item){return{title:item.title,show:'never'};}));}var textColor=foreground==='dark'?'#032250':'white';var content=void 0;if(_react2.default.Children.count(children)>0){content=_react2.default.createElement(_reactNative.View,{collapsable:false,style:{flex:1},__source:{fileName:_jsxFileName,lineNumber:152}},children);}return _react2.default.createElement(_reactNative.View,{style:[styles.toolbarContainer,style],__source:{fileName:_jsxFileName,lineNumber:159}},_react2.default.createElement(_reactNative.ToolbarAndroid,{navIcon:leftItem&&leftItem.icon,onIconClicked:leftItem&&leftItem.onPress,title:this.props.title,titleColor:textColor,subtitleColor:textColor,actions:actions,onActionSelected:this.handleActionSelected,style:styles.toolbar,__source:{fileName:_jsxFileName,lineNumber:160}},content));}}]);return HeaderAndroid;}(_react.Component);HeaderAndroid.defaultProps=defaultProps;HeaderAndroid.propTypes={title:require('prop-types').string,leftItem:require('prop-types').shape({title:require('prop-types').string,icon:require('prop-types').number,layout:require('prop-types').oneOf(['default','icon','title']),onPress:require('prop-types').func}),rightItem:require('prop-types').shape({title:require('prop-types').string,icon:require('prop-types').number,layout:require('prop-types').oneOf(['default','icon','title']),onPress:require('prop-types').func}),extraItems:require('prop-types').arrayOf(require('prop-types').shape({title:require('prop-types').string,icon:require('prop-types').number,layout:require('prop-types').oneOf(['default','icon','title']),onPress:require('prop-types').func})),foreground:require('prop-types').oneOf(['light','dark']),style:require('prop-types').any,children:require('prop-types').any};var HeaderIOS=function(_Component2){_inherits(HeaderIOS,_Component2);function HeaderIOS(){_classCallCheck(this,HeaderIOS);return _possibleConstructorReturn(this,(HeaderIOS.__proto__||Object.getPrototypeOf(HeaderIOS)).apply(this,arguments));}_createClass(HeaderIOS,[{key:'render',value:function render(){var _props3=this.props,leftItem=_props3.leftItem,title=_props3.title,rightItem=_props3.rightItem,foreground=_props3.foreground;var titleColor=foreground==='dark'?'#032250':'white';var itemsColor=foreground==='dark'?'#7F91A7':'white';var content=_react2.default.Children.count(this.props.children)===0?_react2.default.createElement(_reactNative.Text,{style:[styles.titleText,{color:titleColor}],__source:{fileName:_jsxFileName,lineNumber:190}},title):this.props.children;return _react2.default.createElement(_reactNative.View,{style:[styles.header,this.props.style],__source:{fileName:_jsxFileName,lineNumber:195}},_react2.default.createElement(_reactNative.View,{style:styles.leftItem,__source:{fileName:_jsxFileName,lineNumber:196}},_react2.default.createElement(ItemWrapperIOS,{color:itemsColor,item:leftItem,__source:{fileName:_jsxFileName,lineNumber:197}})),_react2.default.createElement(_reactNative.View,{accessible:true,accessibilityLabel:title,accessibilityTraits:'header',style:styles.centerItem,__source:{fileName:_jsxFileName,lineNumber:199}},content),_react2.default.createElement(_reactNative.View,{style:styles.rightItem,__source:{fileName:_jsxFileName,lineNumber:207}},_react2.default.createElement(ItemWrapperIOS,{color:itemsColor,item:rightItem,__source:{fileName:_jsxFileName,lineNumber:208}})));}}]);return HeaderIOS;}(_react.Component);HeaderIOS.defaultProps=defaultProps;HeaderIOS.propTypes={title:require('prop-types').string,leftItem:require('prop-types').shape({title:require('prop-types').string,icon:require('prop-types').number,layout:require('prop-types').oneOf(['default','icon','title']),onPress:require('prop-types').func}),rightItem:require('prop-types').shape({title:require('prop-types').string,icon:require('prop-types').number,layout:require('prop-types').oneOf(['default','icon','title']),onPress:require('prop-types').func}),extraItems:require('prop-types').arrayOf(require('prop-types').shape({title:require('prop-types').string,icon:require('prop-types').number,layout:require('prop-types').oneOf(['default','icon','title']),onPress:require('prop-types').func})),foreground:require('prop-types').oneOf(['light','dark']),style:require('prop-types').any,children:require('prop-types').any};var ItemWrapperIOS=function(_Component3){_inherits(ItemWrapperIOS,_Component3);function ItemWrapperIOS(){_classCallCheck(this,ItemWrapperIOS);return _possibleConstructorReturn(this,(ItemWrapperIOS.__proto__||Object.getPrototypeOf(ItemWrapperIOS)).apply(this,arguments));}_createClass(ItemWrapperIOS,[{key:'render',value:function render(){var _props4=this.props,item=_props4.item,color=_props4.color;if(!item){return null;}var content=void 0;var title=item.title,icon=item.icon,layout=item.layout,onPress=item.onPress;if(layout!=='icon'&&title){content=_react2.default.createElement(_reactNative.Text,{style:[styles.itemText,{color:color}],__source:{fileName:_jsxFileName,lineNumber:238}},title.toUpperCase());}else if(icon){content=_react2.default.createElement(_reactNative.Image,{source:icon,__source:{fileName:_jsxFileName,lineNumber:243}});}return _react2.default.createElement(_reactNative.TouchableOpacity,{accessibilityLabel:title,accessibilityTraits:'button',onPress:onPress,style:styles.itemWrapper,__source:{fileName:_jsxFileName,lineNumber:247}},content);}}]);return ItemWrapperIOS;}(_react.Component);ItemWrapperIOS.defaultProps={item:null,color:null};ItemWrapperIOS.propTypes={item:require('prop-types').shape({title:require('prop-types').string,icon:require('prop-types').number,layout:require('prop-types').oneOf(['default','icon','title']),onPress:require('prop-types').func}),color:require('prop-types').string};var CarouselHeader=_reactNative.Platform.OS==='ios'?HeaderIOS:HeaderAndroid;CarouselHeader.height=HEADER_HEIGHT;exports.default=CarouselHeader;