UNPKG

@uiw/react-native

Version:
29 lines 661 B
import React from 'react'; import { Text as BaseText } from 'react-native'; import { useTheme } from '@shopify/restyle'; import { isEmpty } from 'lodash'; const Text = props => { const { color = 'text', children, style, ...others } = props; const theme = useTheme(); const getColorScheme = () => { // app.ts 包裹了ThemeProvider传递了theme if (!isEmpty(theme.colors)) { return theme.colors; } return { [color]: '#ccc' }; }; return <BaseText style={[{ color: getColorScheme()[color] }, style]} {...others}> {children} </BaseText>; }; Text.displayName = 'Text'; export default Text;