Skip to content

Commit 364e2fd

Browse files
authored
v3.4.0
2 parents 9edb175 + d0e829b commit 364e2fd

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import MaterialTabs from 'react-native-material-tabs';
6363
| scrollable | false | boolean | Option between having fixed tabs or scrollable tabs |
6464
| textStyle | null | object(style) | Text style for tab titles |
6565
| onChange | none | Function | Handler that's emitted every time the user presses a tab. You can use this to change the selected index |
66+
| allowFontScaling | true | boolean | Specifies whether fonts should scale to respect Text Size accessibility settings |
6667

6768
## Example
6869

@@ -76,7 +77,7 @@ import MaterialTabs from 'react-native-material-tabs';
7677
*/
7778

7879
import React, { Component } from 'react';
79-
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
80+
import { AppRegistry, StyleSheet, Text, SafeAreaView } from 'react-native';
8081
import MaterialTabs from 'react-native-material-tabs';
8182

8283
export default class Example extends Component {
@@ -90,7 +91,7 @@ export default class Example extends Component {
9091

9192
render() {
9293
return (
93-
<View style={styles.container}>
94+
<SafeAreaView style={styles.container}>
9495
<MaterialTabs
9596
items={['One', 'Two', 'Three', 'Four', 'Five']}
9697
selectedIndex={this.state.selectedTab}
@@ -100,7 +101,7 @@ export default class Example extends Component {
100101
activeTextColor="white"
101102
textStyle={{ fontFamily: 'Papyrus' }}
102103
/>
103-
</View>
104+
</SafeAreaView>
104105
);
105106
}
106107
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-material-tabs",
3-
"version": "3.3.0",
3+
"version": "3.4.0",
44
"description": "Material Design implementation of Tabs",
55
"keywords": ["react", "react-native", "material-design", "tabs"],
66
"main": "./src/index.js",

src/components/MaterialTabs.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Tab from './Tab';
1010
import Indicator from './Indicator';
1111

1212
type Props = {
13+
allowFontScaling: boolean,
1314
selectedIndex: number,
1415
barColor: string,
1516
barHeight: number,
@@ -30,6 +31,7 @@ type State = {
3031

3132
export default class MaterialTabs extends React.Component<Props, State> {
3233
static propTypes = {
34+
allowFontScaling: PropTypes.bool,
3335
selectedIndex: PropTypes.number,
3436
barColor: PropTypes.string,
3537
activeTextColor: PropTypes.string,
@@ -42,6 +44,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
4244
};
4345

4446
static defaultProps = {
47+
allowFontScaling: true,
4548
selectedIndex: 0,
4649
barColor: '#13897b',
4750
barHeight: values.barHeight,
@@ -66,16 +69,13 @@ export default class MaterialTabs extends React.Component<Props, State> {
6669
);
6770
}
6871

69-
componentWillUpdate(nextProps: Props) {
70-
// Recalculate views if the number of items change
71-
if (nextProps.items.length !== this.props.items.length) {
72+
componentDidUpdate(prevProps: Props) {
73+
if (this.props.items.length !== prevProps.items.length) {
7274
this.bar.measure((_, b, width) => {
7375
this.getTabWidth(width);
7476
});
7577
}
76-
}
7778

78-
componentDidUpdate() {
7979
this.selectTab();
8080
}
8181

@@ -164,6 +164,7 @@ export default class MaterialTabs extends React.Component<Props, State> {
164164
<TabTrack barHeight={this.props.barHeight}>
165165
{this.props.items.map((item, idx) => (
166166
<Tab
167+
allowFontScaling={this.props.allowFontScaling}
167168
text={item}
168169
key={item}
169170
stretch={!this.props.scrollable}

src/components/Tab/Tab.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { TabText, TabBody, TabButton } from './styles';
55
import type { StyleObj } from '../../lib/definitions';
66

77
type TabProps = {
8+
allowFontScaling: boolean,
89
text: string,
910
tabWidth: number,
1011
tabHeight: number,
@@ -17,6 +18,7 @@ type TabProps = {
1718
};
1819

1920
const Tab = ({
21+
allowFontScaling,
2022
activeTextColor,
2123
active,
2224
onPress,
@@ -32,7 +34,11 @@ const Tab = ({
3234
return (
3335
<TabButton onPress={onPress} tabWidth={tabWidth} stretch={stretch}>
3436
<TabBody tabHeight={tabHeight}>
35-
<TabText color={color} style={textStyle}>
37+
<TabText
38+
color={color}
39+
style={textStyle}
40+
allowFontScaling={allowFontScaling}
41+
>
3642
{text.toUpperCase()}
3743
</TabText>
3844
</TabBody>

src/index.d.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// Type definitions for react-native-material-tabs
2-
// Project: https://github.com/iRoachie/react-native-material-tabs
3-
// Definitions by: Kyle Roach <https://github.com/iRoachie>
4-
// TypeScript Version: 3.1
5-
61
import * as React from 'react';
72
import { StyleProp, TextStyle } from 'react-native';
83

94
interface TabsProps {
5+
/**
6+
* Specifies whether fonts should scale to respect Text Size accessibility settings
7+
*
8+
* Default is true
9+
*/
10+
allowFontScaling?: boolean;
11+
1012
/**
1113
* The index of current tab selected. Indexes are mapped to the items prop
1214
*

0 commit comments

Comments
 (0)