Skip to content

Commit 880250c

Browse files
author
Sankhadeep
committed
footer tab added
1 parent 52d45d6 commit 880250c

File tree

3 files changed

+120
-8
lines changed

3 files changed

+120
-8
lines changed

Components/Widgets/Button.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ export default class Button extends NativeBaseComponent {
3434
getInitialStyle() {
3535
return {
3636
button: {
37-
paddingVertical: this.getTheme().buttonPadding,
38-
paddingHorizontal: this.getTheme().buttonPadding+2,
37+
paddingVertical: (this.props.vertical) ? 0 :this.getTheme().buttonPadding,
38+
paddingHorizontal: (this.props.vertical) ? 5 :this.getTheme().buttonPadding+2,
3939
justifyContent: (this.props.block) ? 'center' : 'space-around',
40-
flexDirection: 'row',
40+
flexDirection: (this.props.vertical) ? 'column' : 'row',
4141
alignSelf: 'center',
4242
alignItems: 'center',
4343
backgroundColor: this.getTheme().btnPrimaryBg,
44-
elevation: (this.props.transparent || this.props.bordered) ? 0 : 4,
44+
elevation: (this.props.transparent || this.props.bordered) ? 0 : 3,
4545
shadowColor: (this.props.transparent || this.props.bordered) ? undefined : '#000',
4646
shadowOffset: (this.props.transparent || this.props.bordered) ? undefined : {width: 0, height: 2},
4747
shadowOpacity: (this.props.transparent || this.props.bordered) ? undefined : 0.2,
@@ -89,7 +89,7 @@ export default class Button extends NativeBaseComponent {
8989
var mergedStyle = {};
9090
var btnType = {
9191
fontFamily: this.getTheme().btnFontFamily,
92-
marginLeft: (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0,
92+
marginLeft: (this.props.vertical) ? 0 : (this.iconPresent() && !this.props.iconRight) ? this.getTheme().iconMargin : 0,
9393
marginRight: (this.iconPresent() && this.props.iconRight) ? this.getTheme().iconMargin : 0,
9494
color:
9595
((this.props.bordered) && (this.props.primary)) ? this.getTheme().btnPrimaryBg :

Components/Widgets/Footer.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ export default class Footer extends NativeBaseComponent {
1616
return {
1717
navbar: {
1818
shadowColor: '#000',
19-
shadowOffset: {width: 0, height: 2},
19+
shadowOffset: {width: 0, height: -2},
2020
shadowOpacity: 0.1,
2121
shadowRadius: 1.5,
2222
flexDirection: 'row',
2323
alignItems: 'center',
2424
justifyContent: (!Array.isArray(this.props.children)) ? 'center' : 'space-between',
2525
height: this.getTheme().footerHeight,
26-
backgroundColor: this.getTheme().footerDefaultBg
26+
backgroundColor: this.getTheme().footerDefaultBg,
27+
elevation: 18
2728
}
2829
}
2930
}
@@ -43,7 +44,7 @@ export default class Footer extends NativeBaseComponent {
4344
return(
4445
<View {...this.prepareRootProps()}>
4546
{ !Array.isArray(this.props.children) &&
46-
<View >
47+
<View style={{flex: 1, alignItems: 'center'}} >
4748
{this.props.children}
4849
</View>}
4950

Components/Widgets/FooterTab.js

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* @flow */
2+
'use strict';
3+
4+
import React from 'react';
5+
import NativeBaseComponent from '../Base/NativeBaseComponent';
6+
import computeProps from '../../Utils/computeProps';
7+
import Button from './Button';
8+
import { Platform } from 'react-native';
9+
import View from './View';
10+
import Icon from './Icon';
11+
import IconNB from './Icon';
12+
import Text from './Text';
13+
14+
export default class Footer extends NativeBaseComponent {
15+
16+
propTypes: {
17+
style : React.PropTypes.object
18+
}
19+
20+
getInitialStyle() {
21+
return {
22+
footerTab: {
23+
flexDirection: 'row',
24+
justifyContent: 'space-between',
25+
flex: 1,
26+
alignSelf: 'stretch',
27+
paddingHorizontal: 15
28+
},
29+
btnTextStyle: {
30+
color: this.getTheme().tabBarTextColor,
31+
fontSize: 14
32+
},
33+
btnActiveTextStyle: {
34+
color: this.getTheme().tabBarActiveTextColor,
35+
fontSize: 14
36+
},
37+
btnStyle: {
38+
alignSelf: 'center'
39+
}
40+
}
41+
}
42+
43+
prepareRootProps() {
44+
45+
var defaultProps = {
46+
style: this.getInitialStyle().footerTab
47+
};
48+
49+
return computeProps(this.props, defaultProps);
50+
51+
}
52+
53+
renderFooter() {
54+
var childrenArray = React.Children.toArray(this.props.children);
55+
var newChildren = [];
56+
57+
{childrenArray.map((child, i) => {
58+
if (typeof child.props.children==='string') {
59+
newChildren.push(React.cloneElement(child, {
60+
style: this.getInitialStyle().btnStyle,
61+
vertical: true,
62+
transparent:true,
63+
textStyle: (child.props.active) ? this.getInitialStyle().btnActiveTextStyle : this.getInitialStyle().btnTextStyle,
64+
key: i}));
65+
}
66+
else {
67+
let iconElement = [];
68+
iconElement = _.remove(child.props.children, function(item) {
69+
if(item.type == IconNB) {
70+
return true;
71+
}
72+
});
73+
if (iconElement.length>0) {
74+
newChildren.push(
75+
<Button transparent vertical
76+
style={this.getInitialStyle().btnStyle}
77+
textStyle={(child.props.active) ? this.getInitialStyle().btnActiveTextStyle : this.getInitialStyle().btnTextStyle}
78+
key={i}>
79+
{child.props.children}
80+
<Icon
81+
style={{color: (child.props.active) ? this.getTheme().tabBarActiveTextColor : this.getTheme().tabBarTextColor}}
82+
name={iconElement[0].props.name} />
83+
</Button>
84+
);
85+
}
86+
else {
87+
newChildren.push(
88+
<Button transparent vertical
89+
style={this.getInitialStyle().btnStyle}
90+
textStyle={(child.props.active) ? this.getInitialStyle().btnActiveTextStyle : this.getInitialStyle().btnTextStyle}
91+
key={i}>
92+
<Icon
93+
style={{color: (child.props.active) ? this.getTheme().tabBarActiveTextColor : this.getTheme().tabBarTextColor}}
94+
name={child.props.children.props.name} />
95+
</Button>
96+
);
97+
}
98+
};
99+
})}
100+
return newChildren;
101+
}
102+
103+
render() {
104+
105+
return(
106+
<View {...this.prepareRootProps()} >
107+
{this.renderFooter()}
108+
</View>
109+
);
110+
}
111+
}

0 commit comments

Comments
 (0)