forked from 82253452/listen1_mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Routes.js
165 lines (158 loc) · 5.28 KB
/
Routes.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import React from 'react';
import {StatusBar} from 'react-native';
import {ThemeProvider, withTheme} from 'styled-components';
import {blackTheme, whiteTheme} from './src/config/theme';
import {PrimaryText, ThemeFlex} from './src/components';
/* screens */
import PlaylistTabs from './src/views/playlist/playlist-tabs.screen';
import Playlist from './src/views/playlist/playlist.screen';
import Player from './src/views/player/modal-player.screen';
import Setting from './src/views/setting/setting.screen';
import CreatePlaylist from './src/views/myplaylist/create-playlist.screen';
import ImportPlaylist from './src/views/myplaylist/import-playlist.screen';
import BackgroundPlayer from './src/views/player/background-player.screen';
import NavHeader from './src/views/playlist/nav-header.screen';
import {TouchableOpacity} from 'react-native-gesture-handler';
import SettingContainer from './src/state/setting.state';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import Test from './src/views/player/test.screen';
const Stack = createStackNavigator();
const ThemeAppContainer = withTheme(({theme}) => {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={() => ({
headerStyle: {elevation: 0},
cardStyle: {backgroundColor: theme.windowColor},
})}>
<Stack.Screen
name="Home"
component={PlaylistTabs}
options={({navigation, screenProps}) => ({
headerTitle: () => (
<NavHeader theme={theme} navigation={navigation} />
),
headerStyle: {
backgroundColor: theme.windowColor,
elevation: 0,
},
})}
/>
<Stack.Screen
name="Details"
component={Playlist}
options={({navigation, screenProps}) => ({screenProps}) => ({
headerTintColor: theme.primaryColor,
headerStyle: {backgroundColor: theme.windowColor},
})}
/>
<Stack.Screen
name="Player"
component={Player}
options={({navigation, screenProps}) => () => ({
headerTintColor: theme.primaryColor,
headerStyle: {backgroundColor: theme.windowColor},
})}
/>
<Stack.Screen
name="Setting"
component={Setting}
options={({screenProps}) => {
return {
title: '更多',
headerTintColor: theme.primaryColor,
headerStyle: {backgroundColor: theme.windowColor},
};
}}
/>
<Stack.Screen
name="CreatePlaylist"
component={CreatePlaylist}
options={({navigation, screenProps}) => {
const {
params = {
onFinish: () => {},
},
} = navigation.state;
return {
title: '新建歌单',
headerTintColor: theme.primaryColor,
headerStyle: {backgroundColor: theme.windowColor},
headerRight: (
<TouchableOpacity
onPress={() => params.onFinish()}
style={{padding: 10}}>
<PrimaryText style={{fontSize: 18}}>完成</PrimaryText>
</TouchableOpacity>
),
};
}}
/>
<Stack.Screen
name="ImportPlaylist"
component={ImportPlaylist}
options={({navigation, screenProps}) => {
const {
params = {
onFinish: () => {},
},
} = navigation.state;
return {
title: '导入歌单',
headerTintColor: theme.primaryColor,
headerStyle: {backgroundColor: theme.windowColor},
headerRight: (
<TouchableOpacity
onPress={() => params.onFinish()}
style={{padding: 10}}>
<PrimaryText style={{fontSize: 18}}>打开</PrimaryText>
</TouchableOpacity>
),
};
}}
/>
<Stack.Screen
name="About"
component={PlaylistTabs}
options={({screenProps}) => {
return {
title: '关于',
headerTintColor: theme.primaryColor,
headerStyle: {backgroundColor: theme.windowColor},
};
}}
/>
<Stack.Screen
name="Test"
component={Test}
options={({screenProps}) => {
return {
title: 'Test',
headerTintColor: theme.primaryColor,
headerStyle: {backgroundColor: theme.windowColor},
};
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
});
const ThemeStatusBar = withTheme(({theme}) => {
return (
<StatusBar backgroundColor={theme.windowColor} barStyle={theme.barStyle} />
);
});
export default function App() {
const {settingState} = SettingContainer.useContainer();
return (
<ThemeProvider
theme={settingState.theme === 'black' ? blackTheme : whiteTheme}>
<ThemeFlex>
<ThemeAppContainer />
<ThemeStatusBar />
<BackgroundPlayer />
</ThemeFlex>
</ThemeProvider>
);
}