From 0f4a405f281dbc611f017de7642d098ca48f49c8 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Tue, 20 Aug 2024 04:38:45 -0700 Subject: [PATCH] Add Text example with BG and borderWidth Summary: This diff adds an example in RNTester to verify that we can draw text on top of a colored background and non uniform border radius. As you can see from the test plan, the current code works well when: * There is only the background color * There is a background color and uniform cornerRadius * There are non uniform border radius but the background is transparent. The current code **does not** work when: * there is a background and non-uniform border radius * there is a background, uniform border radius and borderwidth The reason why this happens is because: * `RCTParagraphComponentView` draws the text in the View's main layer in the `drawRect` method * `RCTViewComponentView` has a method `invalidateLayer` that, when there are non-uniform border radii o there is a borderWidth, it creates an extra `CALayer` with an image as content and that layer is put on top of the base layer, covering the text. ## Changelog [Internal] - Add example to RNTester Reviewed By: cortinico Differential Revision: D61389317 fbshipit-source-id: 3e0a9e6c611190f90198a1b0b5855431b9f6ed12 --- .../js/examples/Text/TextExample.ios.js | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/packages/rn-tester/js/examples/Text/TextExample.ios.js b/packages/rn-tester/js/examples/Text/TextExample.ios.js index fb333e479b4..ff89506c6c3 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.ios.js +++ b/packages/rn-tester/js/examples/Text/TextExample.ios.js @@ -594,6 +594,69 @@ const examples = [ ); }, }, + { + title: 'Background Color and Border Width', + render: function (): React.Node { + return ( + <> + + Text with background color only + + + Text with background color and uniform borderRadii + + + Text with background color and non-uniform borders + + + Text with borderWidth + + + Text with background AND borderWidth + + + ); + }, + }, { title: 'Text metrics', render: function (): React.Node {