add stacks for home/search

so they can access album/artist/etc screen
This commit is contained in:
austinried
2021-07-09 20:39:14 +09:00
parent d245d4b786
commit cd9ae9633c
7 changed files with 113 additions and 83 deletions
+5 -70
View File
@@ -1,44 +1,12 @@
import React from 'react'
import { StatusBar, StyleSheet, View } from 'react-native'
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'
import AlbumsTab from '@app/screens/LibraryAlbums'
import ArtistsTab from '@app/screens/LibraryArtists'
import PlaylistsTab from '@app/screens/LibraryPlaylists'
import { createNativeStackNavigator, NativeStackNavigationProp } from 'react-native-screens/native-stack'
import AlbumView from '@app/screens/AlbumView'
import { RouteProp } from '@react-navigation/native'
import font from '@app/styles/font'
import colors from '@app/styles/colors'
import ArtistView from '@app/screens/ArtistView'
import dimensions from '@app/styles/dimensions'
type LibraryStackParamList = {
LibraryTopTabs: undefined
AlbumView: { id: string; title: string }
ArtistView: { id: string; title: string }
}
type AlbumScreenNavigationProp = NativeStackNavigationProp<LibraryStackParamList, 'AlbumView'>
type AlbumScreenRouteProp = RouteProp<LibraryStackParamList, 'AlbumView'>
type AlbumScreenProps = {
route: AlbumScreenRouteProp
navigation: AlbumScreenNavigationProp
}
const AlbumScreen: React.FC<AlbumScreenProps> = ({ route }) => (
<AlbumView id={route.params.id} title={route.params.title} />
)
type ArtistScreenNavigationProp = NativeStackNavigationProp<LibraryStackParamList, 'ArtistView'>
type ArtistScreenRouteProp = RouteProp<LibraryStackParamList, 'ArtistView'>
type ArtistScreenProps = {
route: ArtistScreenRouteProp
navigation: ArtistScreenNavigationProp
}
const ArtistScreen: React.FC<ArtistScreenProps> = ({ route }) => (
<ArtistView id={route.params.id} title={route.params.title} />
)
import font from '@app/styles/font'
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'
import React from 'react'
import { StatusBar, StyleSheet } from 'react-native'
const Tab = createMaterialTopTabNavigator()
@@ -55,40 +23,7 @@ const LibraryTopTabNavigator = () => (
</Tab.Navigator>
)
const Stack = createNativeStackNavigator<LibraryStackParamList>()
const LibraryStackNavigator = () => {
const itemScreenOptions = {
title: '',
headerStyle: styles.stackheaderStyle,
headerHideShadow: true,
headerTintColor: 'white',
headerTitleStyle: styles.stackheaderTitleStyle,
}
return (
<View style={styles.stackContainer}>
<Stack.Navigator>
<Stack.Screen name="LibraryTopTabs" component={LibraryTopTabNavigator} options={{ headerShown: false }} />
<Stack.Screen name="AlbumView" component={AlbumScreen} options={itemScreenOptions} />
<Stack.Screen name="ArtistView" component={ArtistScreen} options={itemScreenOptions} />
</Stack.Navigator>
</View>
)
}
const styles = StyleSheet.create({
stackContainer: {
flex: 1,
},
stackheaderStyle: {
backgroundColor: colors.gradient.high,
},
stackheaderTitleStyle: {
fontSize: 18,
fontFamily: font.semiBold,
color: colors.text.primary,
},
tabBar: {
height: dimensions.header,
marginTop: StatusBar.currentHeight,
@@ -109,4 +44,4 @@ const styles = StyleSheet.create({
},
})
export default LibraryStackNavigator
export default LibraryTopTabNavigator