diff --git a/src/components/metadata/MoreLikeThisSection.tsx b/src/components/metadata/MoreLikeThisSection.tsx index 64d97b9..13ae71c 100644 --- a/src/components/metadata/MoreLikeThisSection.tsx +++ b/src/components/metadata/MoreLikeThisSection.tsx @@ -20,32 +20,13 @@ import CustomAlert from '../../components/CustomAlert'; const { width } = Dimensions.get('window'); -// Dynamic poster calculation based on screen width for More Like This section -const calculatePosterLayout = (screenWidth: number) => { - const MIN_POSTER_WIDTH = 100; // Slightly smaller for more items in this section - const MAX_POSTER_WIDTH = 130; // Maximum poster width - const HORIZONTAL_PADDING = 48; // Total horizontal padding/margins - - // Calculate how many posters can fit (aim for slightly more items than main sections) - const availableWidth = screenWidth - HORIZONTAL_PADDING; - const maxColumns = Math.floor(availableWidth / MIN_POSTER_WIDTH); - - // Limit to reasonable number of columns (3-7 for this section) - const numColumns = Math.min(Math.max(maxColumns, 3), 7); - - // Calculate actual poster width - const posterWidth = Math.min(availableWidth / numColumns, MAX_POSTER_WIDTH); - - return { - numColumns, - posterWidth, - spacing: 12 // Space between posters - }; -}; - -const posterLayout = calculatePosterLayout(width); -const POSTER_WIDTH = posterLayout.posterWidth; -const POSTER_HEIGHT = POSTER_WIDTH * 1.5; +// Breakpoints for responsive sizing +const BREAKPOINTS = { + phone: 0, + tablet: 768, + largeTablet: 1024, + tv: 1440, +} as const; interface MoreLikeThisSectionProps { recommendations: StreamingContent[]; @@ -59,6 +40,48 @@ export const MoreLikeThisSection: React.FC = ({ const { currentTheme } = useTheme(); const navigation = useNavigation>(); + // Determine device type + const deviceWidth = Dimensions.get('window').width; + const getDeviceType = React.useCallback(() => { + if (deviceWidth >= BREAKPOINTS.tv) return 'tv'; + if (deviceWidth >= BREAKPOINTS.largeTablet) return 'largeTablet'; + if (deviceWidth >= BREAKPOINTS.tablet) return 'tablet'; + return 'phone'; + }, [deviceWidth]); + const deviceType = getDeviceType(); + const isTablet = deviceType === 'tablet'; + const isLargeTablet = deviceType === 'largeTablet'; + const isTV = deviceType === 'tv'; + + // Responsive spacing & sizes + const horizontalPadding = React.useMemo(() => { + switch (deviceType) { + case 'tv': return 32; + case 'largeTablet': return 28; + case 'tablet': return 24; + default: return 16; + } + }, [deviceType]); + + const itemSpacing = React.useMemo(() => { + switch (deviceType) { + case 'tv': return 14; + case 'largeTablet': return 12; + case 'tablet': return 12; + default: return 12; + } + }, [deviceType]); + + const posterWidth = React.useMemo(() => { + switch (deviceType) { + case 'tv': return 180; + case 'largeTablet': return 160; + case 'tablet': return 140; + default: return 120; + } + }, [deviceType]); + const posterHeight = React.useMemo(() => posterWidth * 1.5, [posterWidth]); + const [alertVisible, setAlertVisible] = React.useState(false); const [alertTitle, setAlertTitle] = React.useState(''); const [alertMessage, setAlertMessage] = React.useState(''); @@ -94,15 +117,15 @@ export const MoreLikeThisSection: React.FC = ({ const renderItem = ({ item }: { item: StreamingContent }) => ( handleItemPress(item)} > - + {item.name} @@ -121,15 +144,15 @@ export const MoreLikeThisSection: React.FC = ({ } return ( - - More Like This + + More Like This item.id} horizontal showsHorizontalScrollIndicator={false} - contentContainerStyle={styles.listContentContainer} + contentContainerStyle={[styles.listContentContainer, { paddingHorizontal: horizontalPadding, paddingRight: horizontalPadding + itemSpacing }]} />