-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: #46898 Replaces *many* `Text` component usages with `RNTesterText`: a thin wrapper around `Text` that applies color based on the color scheme chosen by the user. It makes text legible for dark mode across 41 different example files. This changes intentionally do not touch a few larger component sites that expand beyond RNTester, like `Animated` and `NewAppScreen` Changelog: [Internal] Differential Revision: D64053464
- Loading branch information
1 parent
0794fa9
commit a81789d
Showing
44 changed files
with
1,651 additions
and
1,570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
import type {TextProps} from 'react-native/Libraries/Text/TextProps'; | ||
|
||
import {RNTesterThemeContext} from './RNTesterTheme'; | ||
import React, {useContext, useMemo} from 'react'; | ||
import {Text} from 'react-native'; | ||
|
||
type Props = $ReadOnly<{ | ||
...TextProps, | ||
variant?: 'body' | 'label' | 'caption', | ||
}>; | ||
|
||
export default function RNTesterText(props: Props): React.Node { | ||
const {style, variant, ...rest} = props; | ||
const theme = useContext(RNTesterThemeContext); | ||
const color = useMemo(() => { | ||
switch (variant) { | ||
case 'body': | ||
return theme.LabelColor; | ||
case 'label': | ||
return theme.SecondaryLabelColor; | ||
case 'caption': | ||
return theme.TertiaryLabelColor; | ||
default: | ||
return theme.LabelColor; | ||
} | ||
}, [variant, theme]); | ||
return <Text {...rest} style={[{color}, style]} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.