@@ -24,6 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO
2424import React , { PropsWithChildren , ReactNode } from 'react' ;
2525import { NavigationContainer } from '@react-navigation/native' ;
2626import { createBottomTabNavigator } from '@react-navigation/bottom-tabs' ;
27+ import { createNativeStackNavigator } from '@react-navigation/native-stack' ;
2728import { ApolloClient , InMemoryCache , ApolloProvider } from '@apollo/client' ;
2829import { STOREFRONT_DOMAIN , STOREFRONT_ACCESS_TOKEN } from '@env' ;
2930import Icon from 'react-native-vector-icons/Entypo' ;
@@ -41,6 +42,8 @@ import {ThemeProvider, getNavigationTheme, useTheme} from './context/Theme';
4142import { Appearance , StatusBar } from 'react-native' ;
4243import { CartProvider , useCart } from './context/Cart' ;
4344import CartScreen from './screens/CartScreen' ;
45+ import ProductDetailsScreen from './screens/ProductDetailsScreen' ;
46+ import { ProductVariant , ShopifyProduct } from '../@types' ;
4447
4548const colorScheme = ColorScheme . web ;
4649
@@ -63,7 +66,16 @@ const config: Configuration = {
6366
6467Appearance . setColorScheme ( 'light' ) ;
6568
66- const Tab = createBottomTabNavigator ( ) ;
69+ export type RootStackParamList = {
70+ Catalog : undefined ;
71+ CatalogScreen : undefined ;
72+ ProductDetails : { product : ShopifyProduct ; variant ?: ProductVariant } ;
73+ Cart : { userId : string } ;
74+ Settings : undefined ;
75+ } ;
76+
77+ const Tab = createBottomTabNavigator < RootStackParamList > ( ) ;
78+ const Stack = createNativeStackNavigator < RootStackParamList > ( ) ;
6779
6880const client = new ApolloClient ( {
6981 uri : `https://${ STOREFRONT_DOMAIN } /api/2023-10/graphql.json` ,
@@ -104,6 +116,31 @@ function AppWithContext({children}: PropsWithChildren) {
104116 ) ;
105117}
106118
119+ function CatalogStack ( ) {
120+ return (
121+ < Stack . Navigator
122+ screenOptions = { {
123+ headerBackTitleVisible : true ,
124+ } } >
125+ < Stack . Screen
126+ name = "CatalogScreen"
127+ component = { CatalogScreen }
128+ options = { { headerShown : true , headerTitle : 'Catalog' } }
129+ />
130+ < Stack . Screen
131+ name = "ProductDetails"
132+ component = { ProductDetailsScreen }
133+ options = { ( { route} ) => ( {
134+ headerTitle : route . params . product . title ,
135+ headerShown : true ,
136+ headerBackVisible : true ,
137+ headerBackTitle : 'Back' ,
138+ } ) }
139+ />
140+ </ Stack . Navigator >
141+ ) ;
142+ }
143+
107144function AppWithNavigation ( ) {
108145 const { colorScheme, preference} = useTheme ( ) ;
109146 const { totalQuantity} = useCart ( ) ;
@@ -113,8 +150,9 @@ function AppWithNavigation() {
113150 < Tab . Navigator >
114151 < Tab . Screen
115152 name = "Catalog"
116- component = { CatalogScreen }
153+ component = { CatalogStack }
117154 options = { {
155+ headerShown : false ,
118156 tabBarIcon : createNavigationIcon ( 'shop' ) ,
119157 } }
120158 />
0 commit comments