-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
35 lines (30 loc) · 1.01 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react'
import { TailwindProvider } from 'tailwind-rn'
import type { ColorSchemeName } from 'react-native'
import { ThemeContext } from '@/utils/theme'
import Starter from './src/screens/Starter'
import {
LocaleContext,
getCurrentLocale,
changeLocale as updateLocale,
} from './src/utils/i18n'
import utilities from './tailwind.json'
const App = () => {
const [theme, setTheme] = React.useState<ColorSchemeName>('light')
const [locale, setLocale] = React.useState<string>(getCurrentLocale())
const toggleTheme = () => setTheme(theme === 'light' ? 'dark' : 'light')
const changeLocale = (locale: string) => {
updateLocale(locale)
setLocale(locale)
}
return (
<LocaleContext.Provider value={{ locale, changeLocale }}>
<ThemeContext.Provider value={{ theme, toggleTheme }}>
<TailwindProvider utilities={utilities} colorScheme={theme}>
<Starter />
</TailwindProvider>
</ThemeContext.Provider>
</LocaleContext.Provider>
)
}
export default App