Skip to content

Commit 441d470

Browse files
committed
chore: reorganize directory
1 parent f971453 commit 441d470

File tree

3 files changed

+107
-9
lines changed

3 files changed

+107
-9
lines changed

example/src/navigation/index.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { NavigationContainer } from '@react-navigation/native';
22
import { createNativeStackNavigator } from '@react-navigation/native-stack';
3-
import IndexScreen from '../pages/IndexScreen';
3+
import HomeScreen from '../pages/HomeScreen';
4+
import TrackListScreen from '../pages/TrackListScreen';
45
import PlayerScreen from '../pages/PlayerScreen';
56

67
export type RootStackParamList = {
7-
Index: undefined;
8+
Home: undefined;
9+
TrackList: undefined;
810
Player: undefined;
911
};
1012

@@ -13,18 +15,26 @@ const Stack = createNativeStackNavigator<RootStackParamList>();
1315
export default function Navigation() {
1416
return (
1517
<NavigationContainer>
16-
<Stack.Navigator>
18+
<Stack.Navigator initialRouteName="Home">
1719
<Stack.Screen
18-
name="Index"
19-
component={IndexScreen}
20+
name="Home"
21+
component={HomeScreen}
2022
options={{ headerShown: false }}
2123
/>
24+
<Stack.Screen
25+
name="TrackList"
26+
component={TrackListScreen}
27+
options={{
28+
title: 'Track List',
29+
headerBackTitle: 'Back',
30+
}}
31+
/>
2232
<Stack.Screen
2333
name="Player"
2434
component={PlayerScreen}
2535
options={{
26-
title: '正在播放',
27-
headerBackTitle: '返回',
36+
title: 'Player',
37+
headerBackTitle: 'Back',
2838
}}
2939
/>
3040
</Stack.Navigator>

example/src/pages/HomeScreen.tsx

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import {
2+
View,
3+
Text,
4+
StyleSheet,
5+
TouchableOpacity,
6+
SafeAreaView,
7+
} from 'react-native';
8+
import type { NativeStackScreenProps } from '@react-navigation/native-stack';
9+
import type { RootStackParamList } from '../navigation';
10+
11+
type Props = NativeStackScreenProps<RootStackParamList, 'Home'>;
12+
13+
export default function HomeScreen({ navigation }: Props) {
14+
return (
15+
<SafeAreaView style={styles.container}>
16+
<View style={styles.content}>
17+
<Text style={styles.title}>React Native Music Library</Text>
18+
<Text style={styles.subtitle}>Get your music library</Text>
19+
20+
<View style={styles.buttonContainer}>
21+
<TouchableOpacity
22+
style={styles.button}
23+
onPress={() => navigation.navigate('TrackList')}
24+
>
25+
<Text style={styles.buttonText}>Track List</Text>
26+
<Text style={styles.buttonSubtext}>
27+
Browse and manage your music
28+
</Text>
29+
</TouchableOpacity>
30+
</View>
31+
</View>
32+
</SafeAreaView>
33+
);
34+
}
35+
36+
const styles = StyleSheet.create({
37+
container: {
38+
flex: 1,
39+
backgroundColor: '#f5f5f5',
40+
},
41+
content: {
42+
flex: 1,
43+
justifyContent: 'center',
44+
alignItems: 'center',
45+
paddingHorizontal: 20,
46+
},
47+
title: {
48+
fontSize: 24,
49+
fontWeight: 'bold',
50+
color: '#333',
51+
marginBottom: 8,
52+
},
53+
subtitle: {
54+
fontSize: 16,
55+
color: '#666',
56+
marginBottom: 60,
57+
textAlign: 'center',
58+
},
59+
buttonContainer: {
60+
width: '100%',
61+
gap: 20,
62+
},
63+
button: {
64+
backgroundColor: '#007AFF',
65+
paddingVertical: 20,
66+
paddingHorizontal: 30,
67+
borderRadius: 12,
68+
alignItems: 'center',
69+
shadowColor: '#000',
70+
shadowOffset: {
71+
width: 0,
72+
height: 2,
73+
},
74+
shadowOpacity: 0.1,
75+
shadowRadius: 4,
76+
elevation: 3,
77+
},
78+
buttonText: {
79+
fontSize: 20,
80+
fontWeight: '600',
81+
color: '#fff',
82+
marginBottom: 4,
83+
},
84+
buttonSubtext: {
85+
fontSize: 14,
86+
color: 'rgba(255, 255, 255, 0.8)',
87+
},
88+
});

example/src/pages/IndexScreen.tsx renamed to example/src/pages/TrackListScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import { SafeAreaView } from 'react-native-safe-area-context';
2222
import { usePlayer } from '../contexts/PlayerContext';
2323
import { AudioPro, type AudioProTrack } from 'react-native-audio-pro';
2424

25-
type Props = NativeStackScreenProps<RootStackParamList, 'Index'>;
25+
type Props = NativeStackScreenProps<RootStackParamList, 'TrackList'>;
2626

27-
export default function IndexScreen({ navigation }: Props) {
27+
export default function TrackListScreen({ navigation }: Props) {
2828
const [tracks, setTracks] = useState<Track[]>([]);
2929
const [loading, setLoading] = useState(false);
3030
const { permissionStatus, requestPermissions } = usePermission();

0 commit comments

Comments
 (0)