Skip to content

Commit

Permalink
Navigation handled
Browse files Browse the repository at this point in the history
  • Loading branch information
thejaved committed Jul 7, 2024
1 parent de373f7 commit cf7319c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 9 deletions.
22 changes: 18 additions & 4 deletions app/navigation/OwnBottomTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,25 @@ const OwnBottomTabs: React.FC<OwnBottomTabsProps> = ({navigation}) => {
return (
<View style={styles.container}>
<View style={styles.content}>
{selectedTab === 'home' && <HomeScreen navigation={navigation} />}
{selectedTab === 'wishlist' && <WishlistScreen />}
{selectedTab === 'home' && (
<HomeScreen navigation={navigation} setSelectedTab={setSelectedTab} />
)}
{selectedTab === 'wishlist' && (
<WishlistScreen
navigation={navigation}
setSelectedTab={setSelectedTab}
/>
)}
{selectedTab === 'scan' && <Text>Scan Screen</Text>}
{selectedTab === 'cart' && <CartScreen />}
{selectedTab === 'profile' && <ProfileScreen />}
{selectedTab === 'cart' && (
<CartScreen navigation={navigation} setSelectedTab={setSelectedTab} />
)}
{selectedTab === 'profile' && (
<ProfileScreen
navigation={navigation}
setSelectedTab={setSelectedTab}
/>
)}
</View>

{/* Bottom Tab Bar */}
Expand Down
14 changes: 12 additions & 2 deletions app/screens/CartScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ import {
import fonts from '../assets/fonts';
import colors from '../styles/colors';

const CartScreen: React.FC = () => {
interface CartScreenProps {
navigation: any;
setSelectedTab: (tab: string) => void;
}

const CartScreen: React.FC<CartScreenProps> = ({
navigation,
setSelectedTab,
}) => {
const dispatch = useDispatch();
const cartItems = useSelector((state: RootState) => state.cart.items);

Expand Down Expand Up @@ -90,7 +98,9 @@ const CartScreen: React.FC = () => {
<Text style={styles.noDataSubText}>
Looks like you haven't added anything to your cart yet.
</Text>
<TouchableOpacity style={styles.shopButton}>
<TouchableOpacity
onPress={() => setSelectedTab('home')}
style={styles.shopButton}>
<Text style={styles.shopButtonText}>Start Shopping</Text>
</TouchableOpacity>
</View>
Expand Down
6 changes: 5 additions & 1 deletion app/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ import {fetchProducts} from '../store/actions/productActions';

interface HomeScreenProps {
navigation: any;
setSelectedTab: (tab: string) => void;
}

const HomeScreen: React.FC<HomeScreenProps> = ({navigation}) => {
const HomeScreen: React.FC<HomeScreenProps> = ({
navigation,
setSelectedTab,
}) => {
const dispatch: AppDispatch = useDispatch();
const products = useSelector((state: RootState) => state.product.products);

Expand Down
10 changes: 9 additions & 1 deletion app/screens/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import React from 'react';
import {StyleSheet} from 'react-native';
import {Header, ScreenContainer} from '../components/common';

const ProfileScreen = () => {
interface ProfileScreenProps {
navigation: any;
setSelectedTab: (tab: string) => void;
}

const ProfileScreen: React.FC<ProfileScreenProps> = ({
navigation,
setSelectedTab,
}) => {
return (
<ScreenContainer>
<Header title="Profile" />
Expand Down
10 changes: 9 additions & 1 deletion app/screens/WishlistScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import React from 'react';
import {StyleSheet} from 'react-native';
import {Header, ScreenContainer} from '../components/common';

const WishlistScreen = () => {
interface WishlistScreenProps {
navigation: any;
setSelectedTab: (tab: string) => void;
}

const WishlistScreen: React.FC<WishlistScreenProps> = ({
navigation,
setSelectedTab,
}) => {
return (
<ScreenContainer>
<Header title="Wishlist" />
Expand Down

0 comments on commit cf7319c

Please sign in to comment.