esbenp / react-native-clean-form

Easy react-native forms using bootstrap-like syntax with redux-form+immutablejs integration. Styled using styled-components
http://esbenp.github.io/2017/01/06/react-native-redux-form-immutable-styled-components/
MIT License
478 stars 76 forks source link

Dynamic Font Sizes #2

Open indivisable opened 7 years ago

indivisable commented 7 years ago

What is best way to handle different fonts set by the OS? I understand this is more general topic related to RN itself but might be good to align dynamically based on height etc. For example if user has small fonts selected the inline labels look offset:

image

image

esbenp commented 7 years ago

Hmm.. That is a good question. My experience with mobile development is very limited. This was sort of my introduction project. Weird, the line-height should be equal to the height of the label and therefore the label should be vertically centered. That is the issue you are pointing out, right? That the label text is smaller than the placeholder text and seem to be higher up, yes?

indivisable commented 7 years ago

@esbenp Yes it should be aligned to center point, I'll be looking into the dynamic text sizing in next few days I'll let you know what I discover.

esbenp commented 7 years ago

Awesome! Let me know :-)

indivisable commented 7 years ago

After some research we have a few ways we could handle this:

Disable Font Scaling https://facebook.github.io/react-native/docs/text.html#allowfontscaling

Text.defaultProps.allowFontScaling=false

Or using Pixel Ratio: https://facebook.github.io/react-native/docs/pixelratio.html#getfontscale

Examples:

The latter method may only work on Android, as the getFontScale only works on Android, not sure why. Might have to write some Objective-C helper to return this setting for iOS:

http://stackoverflow.com/questions/10484211/ios-foundation-system-font-size

markusguenther commented 7 years ago

You can actually style the components with a own theme. So your are also able to define the font-size for each element. The scaling of the operating system is also there. But android and iOS handles this a bit different. Android has just one resize level and on iOS you have several scale levels.