xref: /MusicFree/src/pages/home/index.tsx (revision ab5f994a52bee1ac7c89f2ccf9b6ca60d362890a)
1bf6e62f2S猫头猫import React from 'react';
2f90698e4S猫头猫import {StyleSheet} from 'react-native';
3bf6e62f2S猫头猫
4bf6e62f2S猫头猫import NavBar from './components/navBar';
5bf6e62f2S猫头猫import MusicBar from '@/components/musicBar';
6bf6e62f2S猫头猫import {createDrawerNavigator} from '@react-navigation/drawer';
7bf6e62f2S猫头猫import HomeDrawer from './components/drawer';
81c06c799S猫头猫import {SafeAreaView} from 'react-native-safe-area-context';
919dc08ecS猫头猫import StatusBar from '@/components/base/statusBar';
10740e3947S猫头猫import HorizontalSafeAreaView from '@/components/base/horizontalSafeAreaView.tsx';
113b155a65S猫头猫import globalStyle from '@/constants/globalStyle';
129c72192fS猫头猫import Theme from '@/core/theme';
13f90698e4S猫头猫import HomeBody from './components/homeBody';
14*ab5f994aSmaotoumaoimport HomeBodyHorizontal from './components/homeBodyHorizontal';
15e6b512a7S猫头猫import useOrientation from '@/hooks/useOrientation';
16bf6e62f2S猫头猫
17bf6e62f2S猫头猫function Home() {
18e6b512a7S猫头猫    const orientation = useOrientation();
19e6b512a7S猫头猫
20bf6e62f2S猫头猫    return (
21c446f2b8S猫头猫        <SafeAreaView edges={['top', 'bottom']} style={styles.appWrapper}>
229c72192fS猫头猫            <HomeStatusBar />
23740e3947S猫头猫            <HorizontalSafeAreaView style={globalStyle.flex1}>
243b155a65S猫头猫                <>
254060c00aS猫头猫                    <NavBar />
26e6b512a7S猫头猫                    {orientation === 'vertical' ? (
27f90698e4S猫头猫                        <HomeBody />
28e6b512a7S猫头猫                    ) : (
29*ab5f994aSmaotoumao                        <HomeBodyHorizontal />
30e6b512a7S猫头猫                    )}
313b155a65S猫头猫                </>
32740e3947S猫头猫            </HorizontalSafeAreaView>
33c446f2b8S猫头猫            <MusicBar />
34c446f2b8S猫头猫        </SafeAreaView>
35c446f2b8S猫头猫    );
36c446f2b8S猫头猫}
37c446f2b8S猫头猫
389c72192fS猫头猫function HomeStatusBar() {
399c72192fS猫头猫    const theme = Theme.useTheme();
409c72192fS猫头猫
419c72192fS猫头猫    return (
429c72192fS猫头猫        <StatusBar
439c72192fS猫头猫            backgroundColor="transparent"
449c72192fS猫头猫            barStyle={theme.dark ? undefined : 'dark-content'}
459c72192fS猫头猫        />
469c72192fS猫头猫    );
479c72192fS猫头猫}
489c72192fS猫头猫
49f90698e4S猫头猫// function Body() {
50f90698e4S猫头猫//     const orientation = useOrientation();
51f90698e4S猫头猫//     return (
52f90698e4S猫头猫//         <ScrollView
53f90698e4S猫头猫//             style={[
54f90698e4S猫头猫//                 styles.appWrapper,
55*ab5f994aSmaotoumao//                 orientation === 'horizontal' ? styles.flexRow : null,
56f90698e4S猫头猫//             ]}>
57f90698e4S猫头猫//             <Operations orientation={orientation} />
58f90698e4S猫头猫//         </ScrollView>
59f90698e4S猫头猫//     );
60f90698e4S猫头猫// }
61bf6e62f2S猫头猫
62bf6e62f2S猫头猫const LeftDrawer = createDrawerNavigator();
63bf6e62f2S猫头猫export default function App() {
64bf6e62f2S猫头猫    return (
65bf6e62f2S猫头猫        <LeftDrawer.Navigator
66bf6e62f2S猫头猫            screenOptions={{
67bf6e62f2S猫头猫                headerShown: false,
68bf6e62f2S猫头猫                drawerStyle: {
69c446f2b8S猫头猫                    width: '80%',
70bf6e62f2S猫头猫                },
71bf6e62f2S猫头猫            }}
72bf6e62f2S猫头猫            initialRouteName="HOME-MAIN"
734060c00aS猫头猫            drawerContent={props => <HomeDrawer {...props} />}>
744060c00aS猫头猫            <LeftDrawer.Screen name="HOME-MAIN" component={Home} />
75bf6e62f2S猫头猫        </LeftDrawer.Navigator>
76bf6e62f2S猫头猫    );
77bf6e62f2S猫头猫}
78bf6e62f2S猫头猫
79bf6e62f2S猫头猫const styles = StyleSheet.create({
80bf6e62f2S猫头猫    appWrapper: {
81bf6e62f2S猫头猫        flexDirection: 'column',
82c446f2b8S猫头猫        flex: 1,
83bf6e62f2S猫头猫    },
84e0caea6eS猫头猫    flexRow: {
85e0caea6eS猫头猫        flexDirection: 'row',
86e0caea6eS猫头猫    },
87bf6e62f2S猫头猫});
88