Skip to content

Commit f5af7a2

Browse files
authored
v3.3.0
2 parents 15d288a + bbdbe93 commit f5af7a2

File tree

6 files changed

+36
-7
lines changed

6 files changed

+36
-7
lines changed

src/__tests__/__snapshots__/main.test.js.snap

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`Main should apply custom fontFamily to tab 1`] = `
44
<View
55
barColor="#13897b"
6+
barHeight={48}
67
onLayout={[Function]}
78
style={
89
Array [
@@ -21,6 +22,7 @@ exports[`Main should apply custom fontFamily to tab 1`] = `
2122
>
2223
<View>
2324
<View
25+
barHeight={48}
2426
style={
2527
Array [
2628
Object {
@@ -69,6 +71,7 @@ exports[`Main should apply custom fontFamily to tab 1`] = `
6971
undefined,
7072
]
7173
}
74+
tabHeight={48}
7275
>
7376
<Text
7477
accessible={true}
@@ -133,6 +136,7 @@ exports[`Main should apply custom fontFamily to tab 1`] = `
133136
undefined,
134137
]
135138
}
139+
tabHeight={48}
136140
>
137141
<Text
138142
accessible={true}
@@ -187,6 +191,7 @@ exports[`Main should apply custom fontFamily to tab 1`] = `
187191
exports[`Main should render without errors 1`] = `
188192
<View
189193
barColor="#13897b"
194+
barHeight={48}
190195
onLayout={[Function]}
191196
style={
192197
Array [
@@ -205,6 +210,7 @@ exports[`Main should render without errors 1`] = `
205210
>
206211
<View>
207212
<View
213+
barHeight={48}
208214
style={
209215
Array [
210216
Object {
@@ -253,6 +259,7 @@ exports[`Main should render without errors 1`] = `
253259
undefined,
254260
]
255261
}
262+
tabHeight={48}
256263
>
257264
<Text
258265
accessible={true}
@@ -315,6 +322,7 @@ exports[`Main should render without errors 1`] = `
315322
undefined,
316323
]
317324
}
325+
tabHeight={48}
318326
>
319327
<Text
320328
accessible={true}

src/components/MaterialTabs.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import PropTypes from 'prop-types';
55
import { Animated, ScrollView, View, Text } from 'react-native';
66
import type { StyleObj } from '../lib/definitions';
77
import { Bar, TabTrack } from '../lib/styles';
8+
import values from '../lib/values';
89
import Tab from './Tab';
910
import Indicator from './Indicator';
1011

1112
type Props = {
1213
selectedIndex: number,
1314
barColor: string,
15+
barHeight: number,
1416
activeTextColor: string,
1517
indicatorColor: string,
1618
inactiveTextColor: string,
@@ -42,6 +44,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
4244
static defaultProps = {
4345
selectedIndex: 0,
4446
barColor: '#13897b',
47+
barHeight: values.barHeight,
4548
activeTextColor: '#fff',
4649
indicatorColor: '#fff',
4750
inactiveTextColor: 'rgba(255, 255, 255, 0.7)',
@@ -149,6 +152,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
149152
<Bar
150153
innerRef={ref => (this.bar = ref)}
151154
barColor={this.props.barColor}
155+
barHeight={this.props.barHeight}
152156
onLayout={event => this.getTabWidth(event.nativeEvent.layout.width)}
153157
>
154158
<ScrollView
@@ -157,7 +161,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
157161
showsHorizontalScrollIndicator={false}
158162
scrollEnabled={this.props.scrollable}
159163
>
160-
<TabTrack>
164+
<TabTrack barHeight={this.props.barHeight}>
161165
{this.props.items.map((item, idx) => (
162166
<Tab
163167
text={item}
@@ -167,6 +171,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
167171
active={idx === this.props.selectedIndex}
168172
activeTextColor={this.props.activeTextColor}
169173
textStyle={this.props.textStyle}
174+
tabHeight={this.props.barHeight}
170175
tabWidth={
171176
!this.props.scrollable
172177
? this.state.tabWidth

src/components/Tab/Tab.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { StyleObj } from '../../lib/definitions';
77
type TabProps = {
88
text: string,
99
tabWidth: number,
10+
tabHeight: number,
1011
stretch: boolean,
1112
activeTextColor: string,
1213
inActiveTextColor: string,
@@ -22,14 +23,15 @@ const Tab = ({
2223
text,
2324
inActiveTextColor,
2425
tabWidth,
26+
tabHeight,
2527
stretch,
2628
textStyle,
2729
}: TabProps) => {
2830
const color = active ? activeTextColor : inActiveTextColor;
2931

3032
return (
3133
<TabButton onPress={onPress} tabWidth={tabWidth} stretch={stretch}>
32-
<TabBody>
34+
<TabBody tabHeight={tabHeight}>
3335
<TabText color={color} style={textStyle}>
3436
{text.toUpperCase()}
3537
</TabText>

src/components/Tab/styles.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import styled from 'styled-components/native';
44
import { Platform } from 'react-native';
55
import Button from '../Touchable';
6-
import values from '../../lib/values';
6+
7+
type TabBodyProps = {
8+
tabHeight: number,
9+
};
710

811
export const TabBody = styled.View`
9-
height: ${values.barHeight};
12+
height: ${(props: TabBodyProps) => props.tabHeight};
1013
align-items: center;
1114
justify-content: center;
1215
padding-horizontal: 12px;

src/index.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ interface TabsProps {
2121
*/
2222
barColor?: string;
2323

24+
/**
25+
* Height of the tab bar
26+
*
27+
* Default is 48
28+
*/
29+
barHeight?: number;
30+
2431
/**
2532
* Color of the text for the selected tab
2633
*

src/lib/styles.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
// @flow
22

33
import styled from 'styled-components/native';
4-
import values from './values';
54

65
type BarProps = {
76
barColor: string,
7+
barHeight: number,
88
};
99

10+
type TabProps = {
11+
barHeight: number,
12+
}
13+
1014
const Bar = styled.View`
1115
background-color: ${(props: BarProps) => props.barColor};
12-
height: ${values.barHeight};
16+
height: ${(props: BarProps) => props.barHeight};
1317
`;
1418

1519
const TabTrack = styled.View`
1620
flex-direction: row;
17-
height: 46;
21+
height: ${(props: BarProps) => props.barHeight - 2};
1822
`;
1923

2024
export { Bar, TabTrack };

0 commit comments

Comments
 (0)