-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathApp.tsx
62 lines (58 loc) · 1.66 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React, { useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import ConfigProvider, {
useConfig,
} from '@nutui/nutui-react-native/configprovider';
import Home from './src/Home';
import { DemoList } from './demoList';
import Theme from './components/Theme';
const Stack = createNativeStackNavigator();
export default function App() {
const config = useConfig();
const [theme, setTheme] = useState(config.theme);
const changeTheme = (theme: any) => {
setTheme(theme);
};
const componentRoutes: any = {};
DemoList.forEach((item) => {
componentRoutes[item.title] = {
path: item.title.toLocaleLowerCase(),
};
});
const linking = {
prefixes: ['https://nutui.jd.com', 'nutui://'],
config: {
screens: {
Home: '/',
...componentRoutes,
},
},
};
return (
<ConfigProvider theme={theme}>
<NavigationContainer linking={linking}>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen
name="Home"
component={Home}
options={{
headerShown: false,
headerTitle: '',
}}
/>
{DemoList.map((item) => (
<Stack.Screen
key={item.title}
name={item.title}
component={item.demo}
options={{ title: `${item.title} ${item.description}` }}
/>
))}
</Stack.Navigator>
<StatusBar style="auto" />
</NavigationContainer>
</ConfigProvider>
);
}