Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native accessibility limit fontSize scaling

do you know how to natively limit the fontSize multiplier that comes with accessibility on iOS. I saw this gist : https://gist.github.com/Jpoliachik/ed5cb38b480bc544427ce0db529786bf
But it seems outdated and I'm not good enough in Obj-C to fix it.

like image 909
ArzhRo Avatar asked Dec 06 '22 11:12

ArzhRo


1 Answers

Solution for React Native =< 0.58

iOS uses AccessibilityManager fro that (which is not available for Android) https://github.com/facebook/react-native/blob/1151c096dab17e5d9a6ac05b61aacecd4305f3db/IntegrationTests/AccessibilityManagerTest.js

Android requires a native (Java) solution, how to prevent system font-size changing effects to android application?

For React Native >= 0.59

Text and TextInput component have a maxFontSizeMultiplier prop. https://facebook.github.io/react-native/docs/next/text#maxfontsizemultiplier

With it, the app will be able to have a cross-platform solution to set font scale capping from JS

In your App.js:

Text.defaultProps = {};
Text.defaultProps.maxFontSizeMultiplier = 1.3;

TextInput.defaultProps = {};
TextInput.defaultProps.maxFontSizeMultiplier = 1.3;
like image 93
Estevão Lucas Avatar answered Dec 28 '22 06:12

Estevão Lucas