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
This commit is contained in:
Riccardo Cipolleschi authored and Facebook GitHub Bot committed 2024-08-20 04:38:45 -07:00
1 parent 457f8f08fc
commit 0f4a405f28
1 file changed
+63
@@ -594,6 +594,69 @@ const examples = [
);
},
},
{
title: 'Background Color and Border Width',
render: function (): React.Node {
return (
<>
<Text
style={{
backgroundColor: '#F000F0',
padding: 10,
}}>
Text with background color only
</Text>
<Text
style={{
backgroundColor: '#F000F0',
borderRadius: 10,
padding: 10,
marginBottom: 10,
marginTop: 10,
}}>
Text with background color and uniform borderRadii
</Text>
<Text
style={{
backgroundColor: '#F000F0',
borderTopRightRadius: 10,
borderTopLeftRadius: 20,
borderBottomRightRadius: 20,
borderBottomLeftRadius: 10,
padding: 10,
marginTop: 10,
marginBottom: 10,
}}>
Text with background color and non-uniform borders
</Text>
<Text
style={{
borderWidth: 1,
borderColor: 'red',
borderTopRightRadius: 10,
borderTopLeftRadius: 20,
borderBottomRightRadius: 20,
borderBottomLeftRadius: 10,
padding: 10,
marginTop: 10,
marginBottom: 10,
}}>
Text with borderWidth
</Text>
<Text
style={{
backgroundColor: '#00AA00',
borderWidth: 2,
borderColor: 'blue',
borderRadius: 10,
padding: 10,
}}>
Text with background AND borderWidth
</Text>
</>
);
},
},
{
title: 'Text metrics',
render: function (): React.Node {