From d6bccf32c7246036aab232997acb8d9da89ebdd9 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Mon, 2 Apr 2018 11:39:39 -0400 Subject: [PATCH 1/5] Remove typescript header --- src/index.d.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 9dc7d8c..07e21a0 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,8 +1,3 @@ -// Type definitions for react-native-material-tabs -// Project: https://github.com/iRoachie/react-native-material-tabs -// Definitions by: Kyle Roach -// TypeScript Version: 3.1 - import * as React from 'react'; import { StyleProp, TextStyle } from 'react-native'; From a2a1e0e69bacecd90bed71ee9ef881919f8b0845 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Mon, 2 Apr 2018 11:47:37 -0400 Subject: [PATCH 2/5] feat(text): Add allowFontScaling prop --- README.md | 1 + src/components/MaterialTabs.js | 4 ++++ src/components/Tab/Tab.js | 8 +++++++- src/index.d.ts | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 87c5855..f25cc59 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ import MaterialTabs from 'react-native-material-tabs'; | scrollable | false | boolean | Option between having fixed tabs or scrollable tabs | | textStyle | null | object(style) | Text style for tab titles | | onChange | none | Function | Handler that's emitted every time the user presses a tab. You can use this to change the selected index | +| allowFontScaling | true | boolean | Specifies whether fonts should scale to respect Text Size accessibility settings | ## Example diff --git a/src/components/MaterialTabs.js b/src/components/MaterialTabs.js index 5d71629..d94d831 100644 --- a/src/components/MaterialTabs.js +++ b/src/components/MaterialTabs.js @@ -10,6 +10,7 @@ import Tab from './Tab'; import Indicator from './Indicator'; type Props = { + allowFontScaling: boolean, selectedIndex: number, barColor: string, barHeight: number, @@ -30,6 +31,7 @@ type State = { export default class MaterialTabs extends React.Component { static propTypes = { + allowFontScaling: PropTypes.bool, selectedIndex: PropTypes.number, barColor: PropTypes.string, activeTextColor: PropTypes.string, @@ -42,6 +44,7 @@ export default class MaterialTabs extends React.Component { }; static defaultProps = { + allowFontScaling: true, selectedIndex: 0, barColor: '#13897b', barHeight: values.barHeight, @@ -164,6 +167,7 @@ export default class MaterialTabs extends React.Component { {this.props.items.map((item, idx) => ( - + {text.toUpperCase()} diff --git a/src/index.d.ts b/src/index.d.ts index 07e21a0..2d83d56 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -2,6 +2,13 @@ import * as React from 'react'; import { StyleProp, TextStyle } from 'react-native'; interface TabsProps { + /** + * Specifies whether fonts should scale to respect Text Size accessibility settings + * + * Default is true + */ + allowFontScaling?: boolean; + /** * The index of current tab selected. Indexes are mapped to the items prop * From f69f9059a146775c1713ddf1125d4d1546562355 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Mon, 2 Apr 2018 12:11:53 -0400 Subject: [PATCH 3/5] docs(readme): Use SafeAreaView in example --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f25cc59..e326b14 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ import MaterialTabs from 'react-native-material-tabs'; */ import React, { Component } from 'react'; -import { AppRegistry, StyleSheet, Text, View } from 'react-native'; +import { AppRegistry, StyleSheet, Text, SafeAreaView } from 'react-native'; import MaterialTabs from 'react-native-material-tabs'; export default class Example extends Component { @@ -91,7 +91,7 @@ export default class Example extends Component { render() { return ( - + - + ); } } From 30250516515f00f76650c389a0aa75423b0b94ac Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Mon, 2 Apr 2018 12:15:09 -0400 Subject: [PATCH 4/5] refactor: Remove componentWillUpdate(deprecated) --- src/components/MaterialTabs.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/MaterialTabs.js b/src/components/MaterialTabs.js index d94d831..6f540c3 100644 --- a/src/components/MaterialTabs.js +++ b/src/components/MaterialTabs.js @@ -69,16 +69,13 @@ export default class MaterialTabs extends React.Component { ); } - componentWillUpdate(nextProps: Props) { - // Recalculate views if the number of items change - if (nextProps.items.length !== this.props.items.length) { + componentDidUpdate(prevProps: Props) { + if (this.props.items.length !== prevProps.items.length) { this.bar.measure((_, b, width) => { this.getTabWidth(width); }); } - } - componentDidUpdate() { this.selectTab(); } From d0e829b5e7ad3aa277b0815006ae6f9b60133f5b Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Mon, 2 Apr 2018 12:29:27 -0400 Subject: [PATCH 5/5] chore(pacakge): Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d418b47..d2c902a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-material-tabs", - "version": "3.3.0", + "version": "3.4.0", "description": "Material Design implementation of Tabs", "keywords": ["react", "react-native", "material-design", "tabs"], "main": "./src/index.js",