From 89c8d5650ca8fe3ffe5072323cae29c6097da16e Mon Sep 17 00:00:00 2001 From: Timur Asayonok Date: Sun, 11 Feb 2018 16:34:03 +0100 Subject: [PATCH] Added custom numberOfLines. Default number is 1. --- SegmentedControlTab.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/SegmentedControlTab.js b/SegmentedControlTab.js index 569f5b3..0924374 100644 --- a/SegmentedControlTab.js +++ b/SegmentedControlTab.js @@ -24,7 +24,7 @@ const TabOption = ({ tabTextStyle, activeTabTextStyle, tabBadgeContainerStyle, activeTabBadgeContainerStyle, tabBadgeStyle, activeTabBadgeStyle, - onTabPress, + onTabPress, textNumberOfLines }) => { return ( {text} @@ -70,7 +70,7 @@ const SegmentedControlTab = ({ tabTextStyle, activeTabTextStyle, tabBadgeContainerStyle, activeTabBadgeContainerStyle, tabBadgeStyle, activeTabBadgeStyle, - onTabPress, + onTabPress, textNumberOfLines }) => { const firstTabStyle = [{ borderRightWidth: values.length == 2 ? 1 : 0, borderTopLeftRadius: borderRadius, borderBottomLeftRadius: borderRadius }] @@ -89,6 +89,7 @@ const SegmentedControlTab = ({ badge={badges && badges[index] ? badges[index] : false} isTabActive={multiple ? selectedIndices.includes(index) : selectedIndex === index} text={item} + textNumberOfLines={textNumberOfLines} onTabPress={(index) => handleTabPress(index, multiple, selectedIndex, onTabPress)} firstTabStyle={index === 0 ? [{ borderRightWidth: 0 }, firstTabStyle] : {}} lastTabStyle={index === values.length - 1 ? [{ borderLeftWidth: 0 }, lastTabStyle] : {}} @@ -123,7 +124,8 @@ SegmentedControlTab.propTypes = { activeTabBadgeContainerStyle: Text.propTypes.style, tabBadgeStyle: Text.propTypes.style, activeTabBadgeStyle: Text.propTypes.style, - borderRadius: PropTypes.number + borderRadius: PropTypes.number, + textNumberOfLines: PropTypes.number } SegmentedControlTab.defaultProps = { @@ -142,7 +144,8 @@ SegmentedControlTab.defaultProps = { activeTabBadgeContainerStyle: {}, tabBadgeStyle: {}, activeTabBadgeStyle: {}, - borderRadius: 5 + borderRadius: 5, + textNumberOfLines: 1 } const styles = StyleSheet.create({