diff --git a/src/components/home/HeroCarousel.tsx b/src/components/home/HeroCarousel.tsx index 0876d35..1239ae5 100644 --- a/src/components/home/HeroCarousel.tsx +++ b/src/components/home/HeroCarousel.tsx @@ -19,7 +19,7 @@ interface HeroCarouselProps { const { width } = Dimensions.get('window'); const CARD_WIDTH = Math.min(width * 0.8, 480); -const CARD_HEIGHT = Math.round(CARD_WIDTH * 9 / 16) + 290; // slight increase for text/actions +const CARD_HEIGHT = Math.round(CARD_WIDTH * 9 / 16) + 310; // increased for more vertical space const HeroCarousel: React.FC = ({ items, loading = false }) => { const navigation = useNavigation>(); @@ -80,9 +80,39 @@ const HeroCarousel: React.FC = ({ items, loading = false }) = if (clamped !== activeIndex) setActiveIndex(clamped); }; + const handleScroll = (event: any) => { + const offsetX = event?.nativeEvent?.contentOffset?.x ?? 0; + const interval = CARD_WIDTH + 16; + const idx = Math.round(offsetX / interval); + const clamped = Math.max(0, Math.min(idx, data.length - 1)); + if (clamped !== activeIndex) setActiveIndex(clamped); + }; + return ( + {data.length > 0 && ( + + {data[activeIndex + 1] && ( + + )} + {activeIndex > 0 && data[activeIndex - 1] && ( + + )} + + )} {data[activeIndex] && ( = ({ items, loading = false }) = contentFit="cover" blurRadius={36} cachePolicy="memory-disk" + transition={220} /> @@ -127,6 +158,7 @@ const HeroCarousel: React.FC = ({ items, loading = false }) = snapToInterval={CARD_WIDTH + 16} decelerationRate="fast" contentContainerStyle={{ paddingHorizontal: (width - CARD_WIDTH) / 2 }} + onScroll={handleScroll} onMomentumScrollEnd={handleMomentumEnd} renderItem={({ item }) => ( @@ -144,8 +176,8 @@ const HeroCarousel: React.FC = ({ items, loading = false }) = cachePolicy="memory-disk" /> diff --git a/src/screens/HomeScreen.tsx b/src/screens/HomeScreen.tsx index 8354a32..842cc1f 100644 --- a/src/screens/HomeScreen.tsx +++ b/src/screens/HomeScreen.tsx @@ -369,13 +369,14 @@ const HomeScreen = () => { StatusBar.setTranslucent(true); StatusBar.setBackgroundColor('transparent'); + // Ensure portrait when coming back to Home on all platforms + try { + ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP); + } catch {} + // For iOS specifically if (Platform.OS === 'ios') { StatusBar.setHidden(false); - // Ensure portrait when coming back to Home on iOS - try { - ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP); - } catch {} } }; @@ -607,8 +608,11 @@ const HomeScreen = () => { }, []); // Memoize individual section components to prevent re-renders - const memoizedFeaturedContent = useMemo(() => ( - settings.heroStyle === 'carousel' ? ( + const memoizedFeaturedContent = useMemo(() => { + const deviceWidth = Dimensions.get('window').width; + const isTablet = deviceWidth >= 768; + const heroStyleToUse = isTablet ? 'legacy' : settings.heroStyle; + return heroStyleToUse === 'carousel' ? ( { handleSaveToLibrary={handleSaveToLibrary} loading={featuredLoading} /> - ) - ), [settings.heroStyle, showHeroSection, featuredContentSource, featuredContent, allFeaturedContent, isSaved, handleSaveToLibrary]); + ); + }, [settings.heroStyle, showHeroSection, featuredContentSource, featuredContent, allFeaturedContent, isSaved, handleSaveToLibrary]); const memoizedThisWeekSection = useMemo(() => , []); const memoizedContinueWatchingSection = useMemo(() => , []); diff --git a/src/screens/HomeScreenSettings.tsx b/src/screens/HomeScreenSettings.tsx index 96f52da..5853c8c 100644 --- a/src/screens/HomeScreenSettings.tsx +++ b/src/screens/HomeScreenSettings.tsx @@ -10,7 +10,8 @@ import { StatusBar, Platform, useColorScheme, - Animated + Animated, + Dimensions } from 'react-native'; import { useSettings } from '../hooks/useSettings'; import { useNavigation } from '@react-navigation/native'; @@ -60,6 +61,8 @@ const SettingItem: React.FC = ({ isDarkMode, colors }) => { + const isTabletDevice = Platform.OS !== 'web' && (Dimensions.get('window').width >= 768); + return ( { )} - {settings.showHeroSection && ( + {settings.showHeroSection && !(Dimensions.get('window').width >= 768) && ( <> Hero Layout