react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[RCTUITextView] Remove some magic constants

Open Saadnajmi opened this issue 2 years ago • 2 comments

Summary:

RCTUITextView has two instances where it references some magic constants for font size and color. We inherited these in React Native macOS, and now I want to remove that diff & implement these properly :D.

Looking at commit history, these constants were found by UI inspecting a UITextView several years ago. We don't need to do this.. Apple provides API's for accessing these constants through the system. This gives us slightly better support for things like Large Text support (where 17 needs to be scaled) and Dark Mode (where the old placeholderFontColor is just wrong). Granted, these constants are overwritten almost immediately, I still thought it worth using the proper OS APIs.

The other nice thing about this API is they have very nice macOS equivalents, making the diffs nicer :).

Changelog:

Pick one each for the category and type tags:

[IOS] [FIXED] - Remove some magic constants from RCTUITextView

Test Plan:

Verified that the default UIFont is still 17 after this change.

Saadnajmi avatar Jun 14 '23 10:06 Saadnajmi

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,755,252 +2
android hermes armeabi-v7a 8,067,828 +3
android hermes x86 9,247,855 +4
android hermes x86_64 9,096,987 +3
android jsc arm64-v8a 9,316,460 +2
android jsc armeabi-v7a 8,506,362 +5
android jsc x86 9,379,948 +4
android jsc x86_64 9,633,188 +3

Base commit: af4a0336e95ee3f9a43b96acfb09595c46e22fa4 Branch: main

analysis-bot avatar Jun 14 '23 10:06 analysis-bot

@dmytrorykun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jun 15 '23 17:06 facebook-github-bot

@dmytrorykun merged this pull request in facebook/react-native@a4a8b4d8eb7ce9c50afc6061362d67777f60b2df.

facebook-github-bot avatar Jun 20 '23 16:06 facebook-github-bot