-
Notifications
You must be signed in to change notification settings - Fork 492
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
Exposing the maxContentSizeMultiplier prop for RN.Text and RN.TextInput. #78
Exposing the maxContentSizeMultiplier prop for RN.Text and RN.TextInput. #78
Conversation
…with minimumFontScale.
@rumit91, |
package.json
Outdated
@@ -20,7 +20,7 @@ | |||
"react-addons-perf": "^15.4.1", | |||
"react-addons-test-utils": "^15.4.1", | |||
"react-dom": "^15.4.1", | |||
"react-native": "^0.42.0", | |||
"react-native": "git+https://skype.visualstudio.com/DefaultCollection/TPS/_git/react-native#timale/fontScalingLimit", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't change the public reactxp to point to a private, internal react-native version. Just leave the version as-is. Internally, the Skype repo can refer to the private react-native branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep will remove for sure. Was just using this for testing.
src/android/Text.tsx
Outdated
@@ -40,6 +40,7 @@ export class Text extends CommonText { | |||
importantForAccessibility={ importantForAccessibility } | |||
numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | |||
allowFontScaling={ this.props.allowFontScaling } | |||
maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wouldn't we also expose a minFontSizeMultiplier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add a min, because the user changing the system font to the minimum didn't seem to cause any issues in RN apps, but do you think it would still be valuable for me to add?
src/android/Text.tsx
Outdated
@@ -52,6 +53,10 @@ export class Text extends CommonText { | |||
focus() { | |||
AccessibilityUtil.setAccessibilityFocus(this); | |||
} | |||
|
|||
static setDefaultMaxFontSizeMultiplier(maxFontSizeMultiplier: number): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be exposed as a static method on Text. It should be a method on the UserInterface namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to UserInterface.
src/android/Text.tsx
Outdated
@@ -40,6 +40,7 @@ export class Text extends CommonText { | |||
importantForAccessibility={ importantForAccessibility } | |||
numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | |||
allowFontScaling={ this.props.allowFontScaling } | |||
maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with UserInterface (and react native) terminology, this should be called maxContentSizeMultiplier, not minFontSizeMultiplier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the var name.
src/android/Text.tsx
Outdated
@@ -40,6 +40,7 @@ export class Text extends CommonText { | |||
importantForAccessibility={ importantForAccessibility } | |||
numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | |||
allowFontScaling={ this.props.allowFontScaling } | |||
maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to expose an override of the default max on a per-Text basis? This seems like it might be overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need this to be able to override the default in specific instances. For example, we may want the maxContentSizeMultiplier
to be much higher for text inside message bubbles vs the text in the navigational elements.
src/native-common/TextInput.tsx
Outdated
@@ -220,6 +221,10 @@ export class TextInput extends RX.TextInput<TextInputState> { | |||
setValue(value: string): void { | |||
this._onChangeText(value); | |||
} | |||
|
|||
static setDefaultMaxFontSizeMultiplier(maxFontSizeMultiplier: number): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a different default for Text and TextInput. As mentioned above, this should be collapsed to a single API - UserInterface.setDefaultMaxContentSizeMultiplier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Moved to UserInterface.
src/android/Text.tsx
Outdated
@@ -40,6 +40,7 @@ export class Text extends CommonText { | |||
importantForAccessibility={ importantForAccessibility } | |||
numberOfLines={ this.props.numberOfLines === 0 ? null : this.props.numberOfLines } | |||
allowFontScaling={ this.props.allowFontScaling } | |||
maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for Text, TextInput and UserInterface need to be updated as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reminding me. I added the docs.
…Added `maxContentSizeMultiplier` to Link.
…tly not available in most version of RN.
docs/docs/apis/userinterface.md
Outdated
|
||
// Triggered when the max content size multiplier changes while | ||
// the app is running. | ||
maxContentSizeMultiplierChangedEvent: SubscribableEvent< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this event. The max content size multiplier is under the control of the app, so it can track this change itself. The reason I added an event for contentSizeMultiplierChanged is that it's under control of the OS (and ultimately the user), so the app needs to be informed when it changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed from the code and the docs.
docs/docs/components/text.md
Outdated
// Should the scale multiplier be capped when allowFontScaling is set to true? | ||
// The default of 0 indicates that the compoent should obey the global setting | ||
// in UserInterface which by default is uncapped. | ||
// Note: Most versions of React Native don’t support this interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
docs/docs/components/textinput.md
Outdated
// Should the scale multiplier be capped when allowFontScaling is set to true? | ||
// The default of 0 indicates that the compoent should obey the global setting | ||
// in UserInterface which by default is uncapped. | ||
// Note: Most versions of React Native don’t support this interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
docs/docs/components/link.md
Outdated
// Should the scale multiplier be capped when allowFontScaling is set to true? | ||
// The default of 0 indicates that the compoent should obey the global setting | ||
// in UserInterface which by default is uncapped. | ||
// Note: Most versions of React Native don’t support this interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than saying "Most versions of React Native", please change to "Older versions...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -48,10 +49,6 @@ export class Text extends CommonText { | |||
</RN.Text> | |||
); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to delete this, or was it a merge error? Amay recently added this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted it because it caused merge conflicts. I believe Amay removed it from master recently with this commit: cff4b51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you're ready to merge this, let DDR or Brent know, and they can merge and republish.
…ut. (microsoft#78) * Exposed the maximumFontScale prop and updating docs
Whenever a user changes the system font size to its maximum allowable setting most React Native apps that allow font scaling become unusable. Ideally React Native apps would mimic the behavior of the iMessage (iOS) app where the font size used for non-body text (header, navigational elements, etc) is capped while the body text (text in the message bubbles) is allowed to grow. In this PR I expose the
maxContentSizeMultiplier
prop on<Text>
,<TextInput>
, and<Link>
. Developers can overwrite the default maxContentSizeMultiplier by calling the static methodUserInterface. setMaxContentSizeMultiplier()
or they can just choose to set themaxContentSizeMultiplier
on the desired elements.