-
Notifications
You must be signed in to change notification settings - Fork 0
/
Routes.js
157 lines (145 loc) · 5.61 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
import React from 'react';
import { TextInput, TouchableOpacity } from 'react-native';
import { connect } from 'react-redux';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { StatusBar } from 'react-native';
import { withTheme, ThemeProvider } from 'styled-components/native';
import { blackTheme, whiteTheme } from './src/config/theme';
import { ThemeFlex, PrimaryText } from './src/components';
// Screens
import PlaylistTabs from './src/views/playlist/playlist-tabs.screen';
import Playlist from './src/views/playlist/playlist.screen';
import BackgroundPlayer from './src/views/player/background-player.screen';
import ModalPlayerContainer from './src/views/player/modal-player-container.screen';
import MiniPlayer from './src/views/player/mini-player.screen';
import Setting from './src/views/setting/setting.screen';
import CreatePlaylist from './src/views/myplaylist/create-playlist.screen';
import ReOrder from './src/views/myplaylist/reorder.screen';
import ModalLiteContainer from './src/views/player/modal-lite-container.screen';
import ImportPlaylist from './src/views/myplaylist/import-playlist.screen';
import About from './src/views/setting/about.screen';
import ImportLocal from './src/views/setting/import-local.screen';
import ExportLocal from './src/views/setting/export-local.screen';
import NavHeader from './src/views/playlist/nav-header.screen'
const Stack = createNativeStackNavigator();
function MainStack({ theme }) {
return (
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={PlaylistTabs}
options={({ navigation, route }) => ({
headerTitle: () => (
<NavHeader theme={theme} navigation={navigation} />
),
headerStyle: {
backgroundColor: theme.windowColor,
},
})} />
<Stack.Screen name="Details" component={Playlist} options={({ navigation, route }) => ({
title: '',
headerTintColor: theme.primaryColor,
headerStyle: { backgroundColor: theme.windowColor },
})} />
<Stack.Screen name="Setting" component={Setting} options={({ navigation, route }) => ({
title: '更多',
headerTintColor: theme.primaryColor,
headerStyle: { backgroundColor: theme.windowColor },
})} />
<Stack.Screen name="CreatePlaylist" component={CreatePlaylist} options={({ navigation, route }) => {
const {
params = {
onFinish: () => { },
},
} = route;
return {
title: '新建歌单',
headerTintColor: theme.primaryColor,
headerStyle: { backgroundColor: theme.windowColor },
headerRight: (props) => (
<TouchableOpacity
onPress={() => params.onFinish()}
style={{ padding: 10 }}
>
<PrimaryText style={{ fontSize: 18 }}>完成</PrimaryText>
</TouchableOpacity>
),
};
}} />
<Stack.Screen name="ImportPlaylist" component={ImportPlaylist} options={({ navigation, route }) => {
const {
params = {
onFinish: () => { },
},
} = route;
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="ReOrder" component={ReOrder} options={({ navigation, route }) => ({
title: '编辑歌单',
headerTintColor: theme.primaryColor,
headerStyle: { backgroundColor: theme.windowColor },
})} />
<Stack.Screen name="About" component={About} options={({ navigation, route }) => ({
title: '关于',
headerTintColor: theme.primaryColor,
headerStyle: { backgroundColor: theme.windowColor },
})} />
<Stack.Screen name="ImportLocal" component={ImportLocal} options={({ navigation, route }) => ({
title: '恢复',
headerTintColor: theme.primaryColor,
headerStyle: { backgroundColor: theme.windowColor },
})} />
<Stack.Screen name="ExportLocal" component={ExportLocal} options={({ navigation, route }) => ({
title: '备份',
headerTintColor: theme.primaryColor,
headerStyle: { backgroundColor: theme.windowColor },
})} />
</Stack.Navigator>
);
}
function AppContainer(data) {
return (
<NavigationContainer>
<MainStack theme={data.theme} navigation={data.navigation} />
</NavigationContainer>
);
}
const ThemedAppContainer = withTheme(AppContainer);
const ThemedStatusBar = withTheme(({ theme }) => (
<StatusBar backgroundColor={theme.windowColor} barStyle={theme.barStyle} />
));
function App(props) {
const { settingState } = props;
const theme = settingState.theme === 'black' ? blackTheme : whiteTheme;
return (
<ThemeProvider theme={theme}>
<ThemeFlex>
<ThemedAppContainer />
<ThemedStatusBar />
<BackgroundPlayer />
<MiniPlayer />
<ModalPlayerContainer />
<ModalLiteContainer />
</ThemeFlex>
</ThemeProvider>
)
}
const mapStateToProps = ({ settingState, modalState, playerState, searchState, myPlaylistState }) => ({
settingState,
modalState,
playerState,
searchState,
myPlaylistState
});
export default connect(mapStateToProps)(App);