3
3
* https://docs.expo.io/guides/color-schemes/
4
4
*/
5
5
6
- import { Text as DefaultText , View as DefaultView } from ' react-native' ;
6
+ import { Text as DefaultText , View as DefaultView } from " react-native" ;
7
7
8
- import Colors from ' @/constants/Colors' ;
9
- import { useColorScheme } from './ useColorScheme' ;
8
+ import Colors from " @/constants/Colors" ;
9
+ import { useColorScheme } from "../hooks/ useColorScheme" ;
10
10
11
11
type ThemeProps = {
12
12
lightColor ?: string ;
13
13
darkColor ?: string ;
14
14
} ;
15
15
16
- export type TextProps = ThemeProps & DefaultText [ ' props' ] ;
17
- export type ViewProps = ThemeProps & DefaultView [ ' props' ] ;
16
+ export type TextProps = ThemeProps & DefaultText [ " props" ] ;
17
+ export type ViewProps = ThemeProps & DefaultView [ " props" ] ;
18
18
19
19
export function useThemeColor (
20
20
props : { light ?: string ; dark ?: string } ,
21
21
colorName : keyof typeof Colors . light & keyof typeof Colors . dark
22
22
) {
23
- const theme = useColorScheme ( ) ?? ' light' ;
23
+ const theme = useColorScheme ( ) ?? " light" ;
24
24
const colorFromProps = props [ theme ] ;
25
25
26
26
if ( colorFromProps ) {
@@ -32,14 +32,17 @@ export function useThemeColor(
32
32
33
33
export function Text ( props : TextProps ) {
34
34
const { style, lightColor, darkColor, ...otherProps } = props ;
35
- const color = useThemeColor ( { light : lightColor , dark : darkColor } , ' text' ) ;
35
+ const color = useThemeColor ( { light : lightColor , dark : darkColor } , " text" ) ;
36
36
37
37
return < DefaultText style = { [ { color } , style ] } { ...otherProps } /> ;
38
38
}
39
39
40
40
export function View ( props : ViewProps ) {
41
41
const { style, lightColor, darkColor, ...otherProps } = props ;
42
- const backgroundColor = useThemeColor ( { light : lightColor , dark : darkColor } , 'background' ) ;
42
+ const backgroundColor = useThemeColor (
43
+ { light : lightColor , dark : darkColor } ,
44
+ "background"
45
+ ) ;
43
46
44
47
return < DefaultView style = { [ { backgroundColor } , style ] } { ...otherProps } /> ;
45
48
}
0 commit comments