From 9ebe866e99cd941a17573a941c7519fded97021e Mon Sep 17 00:00:00 2001 From: Yang-Kichang Date: Sun, 7 May 2017 07:27:25 +0900 Subject: [PATCH] (modified)button props added "textSizeIOS" for setting button size in ios (ver2) --- Libraries/Components/Button.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index b6692afb230f59..8c1beb19d092f8 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -14,7 +14,6 @@ const ColorPropType = require('ColorPropType'); const Platform = require('Platform'); const React = require('React'); -const PropTypes = require('prop-types'); const StyleSheet = require('StyleSheet'); const Text = require('Text'); const TouchableNativeFeedback = require('TouchableNativeFeedback'); @@ -57,17 +56,18 @@ class Button extends React.Component { accessibilityLabel?: ?string, disabled?: ?boolean, testID?: ?string, + textSizeIos?:?string, }; static propTypes = { /** * Text to display inside the button */ - title: PropTypes.string.isRequired, + title: React.PropTypes.string.isRequired, /** * Text to display for blindness accessibility features */ - accessibilityLabel: PropTypes.string, + accessibilityLabel: React.PropTypes.string, /** * Color of the text (iOS), or background color of the button (Android) */ @@ -75,15 +75,19 @@ class Button extends React.Component { /** * If true, disable all interactions for this component. */ - disabled: PropTypes.bool, + disabled: React.PropTypes.bool, /** * Handler to be called when the user taps the button */ - onPress: PropTypes.func.isRequired, + onPress: React.PropTypes.func.isRequired, /** * Used to locate this view in end-to-end tests. */ - testID: PropTypes.string, + testID: React.PropTypes.string, + /** + * Size to change button's textSize (only in IOS) + */ + textSizeIos: React.PropTypes.string, }; render() { @@ -94,6 +98,7 @@ class Button extends React.Component { title, disabled, testID, + textSizeIos, } = this.props; const buttonStyles = [styles.button]; const textStyles = [styles.text]; @@ -103,6 +108,9 @@ class Button extends React.Component { } else if (color) { buttonStyles.push({backgroundColor: color}); } + if (textSizeIos&&Platform.OS==='ios') { + textStyles.push({fontSize:parseInt(textSizeIos)}); + } if (disabled) { buttonStyles.push(styles.buttonDisabled); textStyles.push(styles.textDisabled); @@ -125,7 +133,7 @@ class Button extends React.Component { disabled={disabled} onPress={onPress}> - {formattedTitle} + {formattedTitle} );