Compare commits

..

2 commits

Author SHA1 Message Date
shafi54
09e1067b69 enh 2026-02-06 09:15:27 +05:30
shafi54
a713e7a8c1 enh 2026-02-06 02:16:01 +05:30
8 changed files with 173 additions and 25 deletions

View file

@ -0,0 +1,33 @@
import { Stack, useNavigation } from 'expo-router';
import { useEffect } from 'react';
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
function DynamicHeaderTitle() {
const navigation = useNavigation();
const title = useStoreHeaderStore((state) => state.title);
useEffect(() => {
if (title) {
navigation.setOptions({ title });
}
}, [title, navigation]);
return null;
}
export default function ProductDetailLayout() {
const title = useStoreHeaderStore((state) => state.title);
return (
<>
<DynamicHeaderTitle />
<Stack
screenOptions={{
headerShown: true,
}}
>
<Stack.Screen name="[id]" options={{ title: title || 'Product Details' }} />
</Stack>
</>
);
}

View file

@ -1,20 +1,39 @@
import FloatingCartBar from "@/components/floating-cart-bar";
import { tw } from "common-ui";
import { Stack } from "expo-router";
import { Stack, useNavigation } from 'expo-router';
import { View } from "react-native";
import { useEffect } from 'react';
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
function DynamicHeaderTitle() {
const navigation = useNavigation();
const title = useStoreHeaderStore((state) => state.title);
useEffect(() => {
if (title) {
navigation.setOptions({ title });
}
}, [title, navigation]);
return null;
}
export default function ProductDetailLayout() {
const title = useStoreHeaderStore((state) => state.title);
return (
<>
<DynamicHeaderTitle />
<Stack
screenOptions={{
headerShown: true,
title: "Product Details",
}}
/>
>
<Stack.Screen name="[id]" options={{ title: title || 'Product Details' }} />
</Stack>
<View style={tw`absolute bottom-2 left-4 right-4`}>
<FloatingCartBar />
</View>
</>
);
}
}

View file

@ -0,0 +1,33 @@
import { Stack, useNavigation } from 'expo-router';
import { useEffect } from 'react';
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
function DynamicHeaderTitle() {
const navigation = useNavigation();
const title = useStoreHeaderStore((state) => state.title);
useEffect(() => {
if (title) {
navigation.setOptions({ title });
}
}, [title, navigation]);
return null;
}
export default function ProductDetailLayout() {
const title = useStoreHeaderStore((state) => state.title);
return (
<>
<DynamicHeaderTitle />
<Stack
screenOptions={{
headerShown: true,
}}
>
<Stack.Screen name="[id]" options={{ title: title || 'Product Details' }} />
</Stack>
</>
);
}

View file

@ -15,6 +15,7 @@ import FontAwesome5 from "@expo/vector-icons/FontAwesome5";
import { trpc } from "@/src/trpc-client";
import ProductCard from "@/components/ProductCard";
import FloatingCartBar from "@/components/floating-cart-bar";
import { useStoreHeaderStore } from "@/src/store/storeHeaderStore";
const { width: screenWidth } = Dimensions.get("window");
const itemWidth = (screenWidth - 48) / 2;
@ -79,7 +80,12 @@ export default function StoreDetail() {
return selectedTag?.productIds?.includes(product.id) ?? false;
}) || []
: storeData?.products || [];
// Set the store header title
const setStoreHeaderTitle = useStoreHeaderStore((state) => state.setTitle);
if (storeData?.store?.name) {
setStoreHeaderTitle(storeData.store.name);
}
useManualRefresh(() => {
refetch();

View file

@ -1,15 +1,34 @@
import { Stack } from 'expo-router';
import { Stack, useNavigation } from 'expo-router';
import { useEffect } from 'react';
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
function DynamicHeaderTitle() {
const navigation = useNavigation();
const title = useStoreHeaderStore((state) => state.title);
useEffect(() => {
if (title) {
navigation.setOptions({ title });
}
}, [title, navigation]);
return null;
}
export default function StoreDetailLayout() {
const title = useStoreHeaderStore((state) => state.title);
return (
<Stack
screenOptions={{
headerShown: true,
title: "Store Details",
}}
>
<Stack.Screen name="[id]" />
<Stack.Screen options={{headerShown: false}} name="product-detail" />
</Stack>
<>
<DynamicHeaderTitle />
<Stack
screenOptions={{
headerShown: true,
}}
>
<Stack.Screen name="[id]" options={{ title: title || 'Store Details' }} />
<Stack.Screen options={{headerShown: false}} name="product-detail" />
</Stack>
</>
);
}
}

View file

@ -1,12 +1,33 @@
import { Stack } from 'expo-router';
import { Stack, useNavigation } from 'expo-router';
import { useEffect } from 'react';
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
function DynamicHeaderTitle() {
const navigation = useNavigation();
const title = useStoreHeaderStore((state) => state.title);
useEffect(() => {
if (title) {
navigation.setOptions({ title });
}
}, [title, navigation]);
return null;
}
export default function ProductDetailLayout() {
const title = useStoreHeaderStore((state) => state.title);
return (
<Stack
screenOptions={{
headerShown: true,
title: "Product Details",
}}
/>
<>
<DynamicHeaderTitle />
<Stack
screenOptions={{
headerShown: true,
}}
>
<Stack.Screen name="[id]" options={{ title: title || 'Product Details' }} />
</Stack>
</>
);
}
}

View file

@ -13,6 +13,7 @@ import { useAddToCart, useGetCart, useUpdateCartItem, useRemoveFromCart } from '
import { useProductSlotIdentifier } from '@/hooks/useProductSlotIdentifier';
import { useFlashNavigationStore } from '@/components/stores/flashNavigationStore';
import FloatingCartBar from './floating-cart-bar';
import { useStoreHeaderStore } from '@/src/store/storeHeaderStore';
const { width: screenWidth } = Dimensions.get("window");
const carouselWidth = screenWidth;
@ -182,6 +183,12 @@ const ProductDetail: React.FC<ProductDetailProps> = ({ productId, isFlashDeliver
}
}, [productDetail?.id]);
// Set the store header title with product name
const setStoreHeaderTitle = useStoreHeaderStore((state) => state.setTitle);
if (productDetail?.name) {
setStoreHeaderTitle(productDetail.name);
}
if (isLoading) {
return (
<View style={tw`flex-1 justify-center items-center bg-gray-50`}>
@ -200,7 +207,6 @@ const ProductDetail: React.FC<ProductDetailProps> = ({ productId, isFlashDeliver
);
}
return (
<View style={tw`flex-1 bg-gray-50`}>
{/* <CustomHeader /> */}

View file

@ -0,0 +1,11 @@
import { create } from 'zustand';
interface StoreHeaderState {
title: string;
setTitle: (title: string) => void;
}
export const useStoreHeaderStore = create<StoreHeaderState>((set) => ({
title: '',
setTitle: (title) => set({ title }),
}));