From 09e1067b69506d9307f7d1a2cb299b46717af457 Mon Sep 17 00:00:00 2001 From: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Fri, 6 Feb 2026 09:15:27 +0530 Subject: [PATCH] enh --- .../flash-delivery/product-detail/_layout.tsx | 33 +++++++++++++++++ .../(tabs)/home/product-detail/_layout.tsx | 27 ++++++++++++-- .../order-again/product-detail/_layout.tsx | 33 +++++++++++++++++ .../store-detail/product-detail/_layout.tsx | 37 +++++++++++++++---- apps/user-ui/components/ProductDetail.tsx | 8 +++- 5 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 apps/user-ui/app/(drawer)/(tabs)/flash-delivery/product-detail/_layout.tsx create mode 100644 apps/user-ui/app/(drawer)/(tabs)/order-again/product-detail/_layout.tsx diff --git a/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/product-detail/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/product-detail/_layout.tsx new file mode 100644 index 0000000..1791fa3 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/flash-delivery/product-detail/_layout.tsx @@ -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 ( + <> + + + + + + ); +} diff --git a/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/_layout.tsx index 871c3ae..c9a32e9 100644 --- a/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/_layout.tsx +++ b/apps/user-ui/app/(drawer)/(tabs)/home/product-detail/_layout.tsx @@ -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 ( <> + + > + + ); -} \ No newline at end of file +} diff --git a/apps/user-ui/app/(drawer)/(tabs)/order-again/product-detail/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/order-again/product-detail/_layout.tsx new file mode 100644 index 0000000..1791fa3 --- /dev/null +++ b/apps/user-ui/app/(drawer)/(tabs)/order-again/product-detail/_layout.tsx @@ -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 ( + <> + + + + + + ); +} diff --git a/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/_layout.tsx b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/_layout.tsx index 7d1194a..1791fa3 100644 --- a/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/_layout.tsx +++ b/apps/user-ui/app/(drawer)/(tabs)/stores/store-detail/product-detail/_layout.tsx @@ -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 ( - + <> + + + + + ); -} \ No newline at end of file +} diff --git a/apps/user-ui/components/ProductDetail.tsx b/apps/user-ui/components/ProductDetail.tsx index 5d9e343..cb08edf 100644 --- a/apps/user-ui/components/ProductDetail.tsx +++ b/apps/user-ui/components/ProductDetail.tsx @@ -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 = ({ 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 ( @@ -200,7 +207,6 @@ const ProductDetail: React.FC = ({ productId, isFlashDeliver ); } - return ( {/* */}