Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android,Ios]supporting button text resize #16351

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.

## Motivation (required)
I want to use 'react-native' more comfortable.

What existing problem does the pull request solve?
---------------------------------------------------------------------
->in this version, 'button' component couldn't change text size in 'ios'. so, I added button's props
"textSize",be able to change button's text size.
-------------------------------------------------------------

.
=======
Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html
Expand All @@ -13,6 +28,13 @@ Happy contributing!

(Write your motivation here.)

If you have added code that should be tested, add tests.
-----------------------------------------------------------------
Ans:
# **->testing video is here. text size is 10,20 and 30.
[IMG_1944.MOV.zip](https://github.com/facebook/react-native/files/981039/IMG_1944.MOV.zip)**
--------------------------------------------------------------------
=======
## Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
Expand Down
15 changes: 8 additions & 7 deletions Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Button extends React.Component<{
accessibilityLabel?: ?string,
disabled?: ?boolean,
testID?: ?string,
hasTVPreferredFocus?: ?boolean,
fontSize?: ?string,
}> {
static propTypes = {
/**
Expand Down Expand Up @@ -86,11 +86,9 @@ class Button extends React.Component<{
*/
testID: PropTypes.string,
/**
* *(Apple TV only)* TV preferred focus (see documentation for the View component).
*
* @platform ios
* Used to change button's fontSize
*/
hasTVPreferredFocus: PropTypes.bool,
fontSize: PropTypes.number,
};

render() {
Expand All @@ -99,9 +97,9 @@ class Button extends React.Component<{
color,
onPress,
title,
hasTVPreferredFocus,
disabled,
testID,
fontSize,
} = this.props;
const buttonStyles = [styles.button];
const textStyles = [styles.text];
Expand All @@ -112,6 +110,9 @@ class Button extends React.Component<{
buttonStyles.push({backgroundColor: color});
}
}
if (fontSize) {
textStyles.push({fontSize: fontSize});
}
const accessibilityTraits = ['button'];
if (disabled) {
buttonStyles.push(styles.buttonDisabled);
Expand All @@ -129,7 +130,6 @@ class Button extends React.Component<{
accessibilityComponentType="button"
accessibilityLabel={accessibilityLabel}
accessibilityTraits={accessibilityTraits}
hasTVPreferredFocus={hasTVPreferredFocus}
testID={testID}
disabled={disabled}
onPress={onPress}>
Expand Down Expand Up @@ -164,6 +164,7 @@ const styles = StyleSheet.create({
textAlign: 'center',
padding: 8,
fontWeight: '500',
fontSize: 18,
},
}),
buttonDisabled: Platform.select({
Expand Down