Skip to content

Commit

Permalink
(modified)button props added "textSizeIOS" for setting button size in…
Browse files Browse the repository at this point in the history
… ios (ver2)
  • Loading branch information
jason9693 authored May 6, 2017
1 parent 1dd7bc1 commit 9ebe866
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -57,33 +56,38 @@ 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)
*/
color: ColorPropType,
/**
* 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() {
Expand All @@ -94,6 +98,7 @@ class Button extends React.Component {
title,
disabled,
testID,
textSizeIos,
} = this.props;
const buttonStyles = [styles.button];
const textStyles = [styles.text];
Expand All @@ -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);
Expand All @@ -125,7 +133,7 @@ class Button extends React.Component {
disabled={disabled}
onPress={onPress}>
<View style={buttonStyles}>
<Text style={textStyles} disabled={disabled}>{formattedTitle}</Text>
<Text style={textStyles}>{formattedTitle}</Text>
</View>
</Touchable>
);
Expand Down

0 comments on commit 9ebe866

Please sign in to comment.