Permalink
Browse files

changes to footerTab

  • Loading branch information...
1 parent c365eff commit 1a0a6bbc5cf4fe9303aa5fd1abc9b8ab1d874910 @sankhadeeproy007 sankhadeeproy007 committed Dec 28, 2016
@@ -10,6 +10,7 @@ import Text from './Text';
import View from './View';
import Button from './Button';
import Thumbnail from './Thumbnail';
+import Gravatar from './Gravatar';
export default class CardItemNB extends NativeBaseComponent {
@@ -27,7 +28,7 @@ export default class CardItemNB extends NativeBaseComponent {
this.getTheme().listItemPadding,
backgroundColor: this.getTheme().listBg,
justifyContent: (this.buttonPresent()) ? 'space-between' : 'flex-start',
- flexDirection: (this.thumbnailPresent() || this.iconPresent() || (this.notePresent() && this.ifShowCase())) ? 'row' : 'column',
+ flexDirection: (this.thumbnailPresent() || this.gravatarPresent() || this.iconPresent() || (this.notePresent() && this.ifShowCase())) ? 'row' : 'column',
borderColor: this.getTheme().listBorderColor
},
listItemDivider: {
@@ -68,6 +69,9 @@ export default class CardItemNB extends NativeBaseComponent {
thumbnail: {
alignSelf: 'center'
},
+ gravatar: {
+ alignSelf: 'center'
+ },
fullImage: {
alignSelf: 'stretch',
height: this.ifShowCase() ? 120 : 300
@@ -110,6 +114,16 @@ export default class CardItemNB extends NativeBaseComponent {
return thumbnailComponentPresent;
}
+ gravatarPresent() {
+ var gravatarComponentPresent = false;
+ React.Children.forEach(this.props.children, function (child) {
+ if(child.type == Gravatar)
+ gravatarComponentPresent = true;
+ })
+
+ return gravatarComponentPresent;
+ }
+
imagePresent() {
let imagePresent = false;
React.Children.forEach(this.props.children, (child) => {
@@ -161,7 +175,7 @@ export default class CardItemNB extends NativeBaseComponent {
squareThumbs() {
let squareThumbs = false;
- if (this.thumbnailPresent()) {
+ if (this.thumbnailPresent() || this.gravatarPresent()) {
React.Children.forEach(this.props.children, (child) => {
if (child && child.props.square) {
squareThumbs = true;
@@ -190,7 +204,7 @@ export default class CardItemNB extends NativeBaseComponent {
defaultProps = {
style: this.getInitialStyle().dividerItemText
};
- } else if (child.props.note && this.thumbnailPresent()) {
+ } else if (child.props.note && (this.thumbnailPresent() || this.gravatarPresent())) {
defaultProps = {
style: this.getInitialStyle().itemSubNote
};
@@ -211,6 +225,10 @@ export default class CardItemNB extends NativeBaseComponent {
defaultProps = {
style: this.getInitialStyle().thumbnail
};
+ } else if(child.type == Gravatar) {
+ defaultProps = {
+ style: this.getInitialStyle().gravatar
+ };
} else if (child.type === Image) {
defaultProps = {
style: this.getInitialStyle().fullImage
@@ -248,7 +266,7 @@ export default class CardItemNB extends NativeBaseComponent {
let childrenArray = React.Children.toArray(this.props.children);
childrenArray = childrenArray.filter(child => !!child);
- if (!this.thumbnailPresent() && !this.iconPresent()) {
+ if ((!this.thumbnailPresent() || !this.gravatarPresent()) && !this.iconPresent()) {
newChildren = childrenArray.map((child, i) =>
React.cloneElement(child, { ...this.getChildProps(child), key: i })
);
@@ -11,7 +11,7 @@ import Icon from './Icon';
import Badge from './Badge';
import IconNB from './Icon';
import Text from './Text';
-
+import _ from 'lodash';
export default class Footer extends NativeBaseComponent {
propTypes: {
@@ -139,7 +139,7 @@ export default class Footer extends NativeBaseComponent {
key={i} onPress={child.props.onPress}>
<Icon
style={{color: (child.props.active) ? this.getTheme().tabBarActiveTextColor : this.getTheme().tabBarTextColor,
- fontSize: 28}}
+ fontSize: 28, height: 30, lineHeight: 28}}
name={children.props.name} />
</Button>
);
@@ -0,0 +1,62 @@
+/* @flow */
+'use strict';
+
+import React from 'react';
+import {Image} from 'react-native';
+import NativeBaseComponent from '../Base/NativeBaseComponent';
+import computeProps from '../../Utils/computeProps';
+import _ from 'lodash';
+import md5 from 'blueimp-md5';
+
+const GRAVATAR_URI = 'https://www.gravatar.com/avatar/';
+
+export default class GravatarNB extends NativeBaseComponent {
+
+ propTypes: {
+ email: React.PropTypes.string.isRequired,
+ style : React.PropTypes.object,
+ size : React.PropTypes.number,
+ circular : React.PropTypes.bool,
+ square : React.PropTypes.bool
+ }
+
+ getInitialStyle() {
+ return {
+ gravatar: {
+ borderRadius: this.props.size ? this.props.size/2 : 15,
+ width: this.props.size ? this.props.size : 30,
+ height: this.props.size ? this.props.size : 30,
+ resizeMode: this.props.contain ? 'contain' : undefined
+ }
+ }
+ }
+
+ prepareRootProps() {
+ var gravatarStyle = {};
+ if(this.props.circular) {
+ gravatarStyle.width = this.props.size;
+ gravatarStyle.height = this.props.size;
+ gravatarStyle.borderRadius = this.props.size/2;
+ }
+ else if(this.props.square) {
+ gravatarStyle.width = this.props.size;
+ gravatarStyle.height = this.props.size;
+ gravatarStyle.borderRadius = 0;
+ }
+
+ var defaultProps = {
+ style: _.merge(this.getInitialStyle().gravatar, gravatarStyle)
+ };
+
+ return computeProps(this.props, defaultProps);
+ }
+
+ render() {
+ const props = this.prepareRootProps();
+
+ const uri = GRAVATAR_URI + md5(this.props.email) + '?s='+props.style.height;
+ return(
+ <Image ref={c => this._root = c} {...props} source={{uri:uri}}/>
+ );
+ }
+}
@@ -20,35 +20,35 @@ export default class IconNB extends NativeBaseComponent {
}
contextTypes: {
- theme: React.PropTypes.object
+ theme: React.PropTypes.object
}
componentWillMount() {
- switch(this.getTheme().iconFamily) {
- case 'Ionicons':
- this.Icon = Ionicons;
- break;
- case 'Entypo':
- this.Icon = Entypo;
- break;
- case 'FontAwesome':
- this.Icon = FontAwesome;
- break;
- case 'Foundation':
- this.Icon = Foundation;
- break;
- case 'MaterialIcons':
- this.Icon = MaterialIcons;
- break;
- case 'Octicons':
- this.Icon = Octicons;
- break;
- case 'Zocial':
- this.Icon = Zocial;
- break;
- default:
- this.Icon = Ionicons;
- }
+ switch(this.getTheme().iconFamily) {
+ case 'Ionicons':
+ this.Icon = Ionicons;
+ break;
+ case 'Entypo':
+ this.Icon = Entypo;
+ break;
+ case 'FontAwesome':
+ this.Icon = FontAwesome;
+ break;
+ case 'Foundation':
+ this.Icon = Foundation;
+ break;
+ case 'MaterialIcons':
+ this.Icon = MaterialIcons;
+ break;
+ case 'Octicons':
+ this.Icon = Octicons;
+ break;
+ case 'Zocial':
+ this.Icon = Zocial;
+ break;
+ default:
+ this.Icon = Ionicons;
+ }
}
static getImageSource = FontAwesome.getImageSource
@@ -8,6 +8,7 @@ import Icon from './Icon';
import Button from './Button';
import computeProps from '../../Utils/computeProps';
import Input from './Input';
+import Picker from './Picker';
import _ from 'lodash';
export default class InputGroup extends NativeBaseComponent {
@@ -145,7 +146,7 @@ export default class InputGroup extends NativeBaseComponent {
});
var inp = _.find(childrenArray, function(item) {
- if(item && item.type == Input) {
+ if(item && (item.type == Input || item.type == Picker)) {
return true;
}
});
@@ -172,13 +173,16 @@ export default class InputGroup extends NativeBaseComponent {
newChildren.push(React.cloneElement(iconElement[0],this.getIconProps(iconElement[0])));
}
else if(buttonElement.length>0) {
- newChildren.push(React.cloneElement(
- iconElement[0],
- {
- ...this.getIconProps(iconElement[0]),
- key: 'icon0'
- }
- ));
+ if (iconElement.length > 0) {
+ newChildren.push(React.cloneElement(
+ iconElement[0],
+ {
+ ...this.getIconProps(iconElement[0]),
+ key: 'icon0'
+ }
+ ));
+ }
+
if(clonedInp) {
newChildren.push(clonedInp);
}
@@ -11,6 +11,7 @@ import View from './View';
import Button from './Button';
import Badge from './Badge';
import Thumbnail from './Thumbnail';
+import Gravatar from './Gravatar';
import CheckBox from './Checkbox';
import Picker from './Picker';
import Radio from './Radio';
@@ -82,6 +83,9 @@ export default class ListItemNB extends NativeBaseComponent {
thumbnail: {
alignSelf: 'center'
},
+ Gravatar: {
+ alignSelf: 'center'
+ },
fullImage: {
width: 300,
height: 300
@@ -126,6 +130,16 @@ export default class ListItemNB extends NativeBaseComponent {
return thumbnailComponentPresent;
}
+ gravatarPresent() {
+ var gravatarComponentPresent = false;
+ React.Children.forEach(this.props.children, function (child) {
+ if(child && child.type == Gravatar)
+ gravatarComponentPresent = true;
+ })
+
+ return gravatarComponentPresent;
+ }
+
checkBoxPresent() {
var checkBoxComponentPresent = false;
React.Children.forEach(this.props.children, function (child) {
@@ -228,7 +242,7 @@ export default class ListItemNB extends NativeBaseComponent {
style: this.getInitialStyle().dividerItemText
}
} else {
- if(child.props.note && this.thumbnailPresent()) {
+ if(child.props.note && (this.thumbnailPresent() || this.gravatarPresent())) {
defaultProps = {
style: this.getInitialStyle().itemSubNote
}
@@ -269,6 +283,11 @@ export default class ListItemNB extends NativeBaseComponent {
style: this.getInitialStyle().thumbnail
}
}
+ else if(child && child.type == Gravatar) {
+ defaultProps = {
+ style: this.getInitialStyle().gravatar
+ }
+ }
else {
defaultProps = {
foregroundColor: this.getContextForegroundColor()
@@ -347,13 +366,14 @@ export default class ListItemNB extends NativeBaseComponent {
squareThumbs() {
var squareThumbs = false;
- if (this.thumbnailPresent()) {
+ if (this.thumbnailPresent() || this.gravatarPresent()) {
React.Children.forEach(this.props.children, function (child) {
if(child.props.square)
squareThumbs = true;
})
}
+
return squareThumbs;
}
@@ -466,6 +486,20 @@ export default class ListItemNB extends NativeBaseComponent {
})}
</View>);
}
+ else if (this.gravatarPresent()) {
+
+ iconElement = _.remove(childrenArray, function(item) {
+ if(item.type == Gravatar) {
+ 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) {
Oops, something went wrong.

0 comments on commit 1a0a6bb

Please sign in to comment.