added toggle to control this week sections

This commit is contained in:
tapframe 2026-01-05 13:39:02 +05:30
parent 4dd1fca0a7
commit ab7f008bbb
3 changed files with 47 additions and 30 deletions

View file

@ -37,6 +37,7 @@ export interface AppSettings {
useExternalPlayer: boolean; useExternalPlayer: boolean;
preferredPlayer: 'internal' | 'vlc' | 'infuse' | 'outplayer' | 'vidhub' | 'infuse_livecontainer' | 'external'; preferredPlayer: 'internal' | 'vlc' | 'infuse' | 'outplayer' | 'vidhub' | 'infuse_livecontainer' | 'external';
showHeroSection: boolean; showHeroSection: boolean;
showThisWeekSection: boolean; // Toggle "This Week" section
featuredContentSource: 'tmdb' | 'catalogs'; featuredContentSource: 'tmdb' | 'catalogs';
heroStyle: 'legacy' | 'carousel' | 'appletv'; heroStyle: 'legacy' | 'carousel' | 'appletv';
selectedHeroCatalogs: string[]; // Array of catalog IDs to display in hero section selectedHeroCatalogs: string[]; // Array of catalog IDs to display in hero section
@ -123,6 +124,7 @@ export const DEFAULT_SETTINGS: AppSettings = {
useExternalPlayer: false, useExternalPlayer: false,
preferredPlayer: 'internal', preferredPlayer: 'internal',
showHeroSection: true, showHeroSection: true,
showThisWeekSection: true, // Enabled by default
featuredContentSource: 'catalogs', featuredContentSource: 'catalogs',
heroStyle: 'appletv', heroStyle: 'appletv',
selectedHeroCatalogs: [], // Empty array means all catalogs are selected selectedHeroCatalogs: [], // Empty array means all catalogs are selected

View file

@ -667,7 +667,9 @@ const HomeScreen = () => {
} }
// Normal flow when addons are present (featured moved to ListHeaderComponent) // Normal flow when addons are present (featured moved to ListHeaderComponent)
data.push({ type: 'thisWeek', key: 'thisWeek' }); if (settings.showThisWeekSection) {
data.push({ type: 'thisWeek', key: 'thisWeek' });
}
// Only show a limited number of catalogs initially for performance // Only show a limited number of catalogs initially for performance
const catalogsToShow = catalogs.slice(0, visibleCatalogCount); const catalogsToShow = catalogs.slice(0, visibleCatalogCount);
@ -687,7 +689,7 @@ const HomeScreen = () => {
} }
return data; return data;
}, [hasAddons, catalogs, visibleCatalogCount]); }, [hasAddons, catalogs, visibleCatalogCount, settings.showThisWeekSection]);
const handleLoadMoreCatalogs = useCallback(() => { const handleLoadMoreCatalogs = useCallback(() => {
setVisibleCatalogCount(prev => Math.min(prev + 3, catalogs.length)); setVisibleCatalogCount(prev => Math.min(prev + 3, catalogs.length));

View file

@ -64,11 +64,11 @@ const SettingItem: React.FC<SettingItemProps> = ({
const isTabletDevice = Platform.OS !== 'web' && (Dimensions.get('window').width >= 768); const isTabletDevice = Platform.OS !== 'web' && (Dimensions.get('window').width >= 768);
return ( return (
<TouchableOpacity <TouchableOpacity
activeOpacity={onPress ? 0.7 : 1} activeOpacity={onPress ? 0.7 : 1}
onPress={onPress} onPress={onPress}
style={[ style={[
styles.settingItem, styles.settingItem,
!isLast && styles.settingItemBorder, !isLast && styles.settingItemBorder,
{ borderBottomColor: isDarkMode ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.05)' } { borderBottomColor: isDarkMode ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.05)' }
]} ]}
@ -127,8 +127,8 @@ const HomeScreenSettings: React.FC = () => {
if (Platform.OS === 'ios') { if (Platform.OS === 'ios') {
StatusBar.setHidden(false); StatusBar.setHidden(false);
} }
} catch {} } catch { }
return () => {}; return () => { };
}, [isDarkMode, colors.darkBackground]) }, [isDarkMode, colors.darkBackground])
); );
@ -169,7 +169,7 @@ const HomeScreenSettings: React.FC = () => {
if (isTabletDevice && settings.heroStyle !== 'carousel') { if (isTabletDevice && settings.heroStyle !== 'carousel') {
updateSetting('heroStyle', 'carousel' as any); updateSetting('heroStyle', 'carousel' as any);
} }
} catch {} } catch { }
}, [isTabletDevice, settings.heroStyle, updateSetting]); }, [isTabletDevice, settings.heroStyle, updateSetting]);
const CustomSwitch = ({ value, onValueChange }: { value: boolean, onValueChange: (value: boolean) => void }) => ( const CustomSwitch = ({ value, onValueChange }: { value: boolean, onValueChange: (value: boolean) => void }) => (
@ -184,20 +184,20 @@ const HomeScreenSettings: React.FC = () => {
// Radio button component for content source selection // Radio button component for content source selection
const RadioOption = ({ selected, onPress, label }: { selected: boolean, onPress: () => void, label: string }) => ( const RadioOption = ({ selected, onPress, label }: { selected: boolean, onPress: () => void, label: string }) => (
<TouchableOpacity <TouchableOpacity
style={styles.radioOption} style={styles.radioOption}
onPress={onPress} onPress={onPress}
activeOpacity={0.7} activeOpacity={0.7}
> >
<View style={styles.radioContainer}> <View style={styles.radioContainer}>
<View style={[ <View style={[
styles.radio, styles.radio,
{ borderColor: isDarkMode ? colors.mediumEmphasis : colors.textMutedDark } { borderColor: isDarkMode ? colors.mediumEmphasis : colors.textMutedDark }
]}> ]}>
{selected && <View style={[styles.radioInner, { backgroundColor: colors.primary }]} />} {selected && <View style={[styles.radioInner, { backgroundColor: colors.primary }]} />}
</View> </View>
<Text style={[ <Text style={[
styles.radioLabel, styles.radioLabel,
{ color: isDarkMode ? colors.highEmphasis : colors.textDark } { color: isDarkMode ? colors.highEmphasis : colors.textDark }
]}> ]}>
{label} {label}
@ -254,9 +254,9 @@ const HomeScreenSettings: React.FC = () => {
}, [settings.selectedHeroCatalogs]); }, [settings.selectedHeroCatalogs]);
const ChevronRight = () => ( const ChevronRight = () => (
<MaterialIcons <MaterialIcons
name="chevron-right" name="chevron-right"
size={24} size={24}
color={isDarkMode ? 'rgba(255,255,255,0.3)' : 'rgba(0,0,0,0.3)'} color={isDarkMode ? 'rgba(255,255,255,0.3)' : 'rgba(0,0,0,0.3)'}
/> />
); );
@ -269,30 +269,30 @@ const HomeScreenSettings: React.FC = () => {
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} /> <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<View style={styles.header}> <View style={styles.header}>
<TouchableOpacity onPress={handleBack} style={styles.backButton}> <TouchableOpacity onPress={handleBack} style={styles.backButton}>
<MaterialIcons <MaterialIcons
name="arrow-back" name="arrow-back"
size={24} size={24}
color={isDarkMode ? colors.highEmphasis : colors.textDark} color={isDarkMode ? colors.highEmphasis : colors.textDark}
/> />
<Text style={[styles.backText, { color: isDarkMode ? colors.highEmphasis : colors.textDark }]}> <Text style={[styles.backText, { color: isDarkMode ? colors.highEmphasis : colors.textDark }]}>
Settings Settings
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
<View style={styles.headerActions}> <View style={styles.headerActions}>
{/* Empty for now, but ready for future actions */} {/* Empty for now, but ready for future actions */}
</View> </View>
</View> </View>
<Text style={[styles.headerTitle, { color: isDarkMode ? colors.highEmphasis : colors.textDark }]}> <Text style={[styles.headerTitle, { color: isDarkMode ? colors.highEmphasis : colors.textDark }]}>
Home Screen Settings Home Screen Settings
</Text> </Text>
{/* Saved indicator */} {/* Saved indicator */}
<Animated.View <Animated.View
style={[ style={[
styles.savedIndicator, styles.savedIndicator,
{ {
opacity: fadeAnim, opacity: fadeAnim,
backgroundColor: isDarkMode ? 'rgba(0, 180, 150, 0.9)' : 'rgba(0, 180, 150, 0.9)' backgroundColor: isDarkMode ? 'rgba(0, 180, 150, 0.9)' : 'rgba(0, 180, 150, 0.9)'
} }
@ -303,7 +303,7 @@ const HomeScreenSettings: React.FC = () => {
<Text style={styles.savedIndicatorText}>Changes Applied</Text> <Text style={styles.savedIndicatorText}>Changes Applied</Text>
</Animated.View> </Animated.View>
<ScrollView <ScrollView
style={styles.scrollView} style={styles.scrollView}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
contentContainerStyle={styles.scrollContent} contentContainerStyle={styles.scrollContent}
@ -317,9 +317,22 @@ const HomeScreenSettings: React.FC = () => {
isDarkMode={isDarkMode} isDarkMode={isDarkMode}
colors={colors} colors={colors}
renderControl={() => ( renderControl={() => (
<CustomSwitch <CustomSwitch
value={settings.showHeroSection} value={settings.showHeroSection}
onValueChange={(value) => handleUpdateSetting('showHeroSection', value)} onValueChange={(value) => handleUpdateSetting('showHeroSection', value)}
/>
)}
/>
<SettingItem
title="Show This Week Section"
description="New episodes from current week"
icon="date-range"
isDarkMode={isDarkMode}
colors={colors}
renderControl={() => (
<CustomSwitch
value={settings.showThisWeekSection}
onValueChange={(value) => handleUpdateSetting('showThisWeekSection', value)}
/> />
)} )}
/> />
@ -344,7 +357,7 @@ const HomeScreenSettings: React.FC = () => {
<Text style={[styles.segmentTitle, { color: isDarkMode ? colors.mediumEmphasis : colors.textMutedDark }]}>Hero Layout</Text> <Text style={[styles.segmentTitle, { color: isDarkMode ? colors.mediumEmphasis : colors.textMutedDark }]}>Hero Layout</Text>
<SegmentedControl <SegmentedControl
options={[ options={[
{ label: 'Legacy', value: 'legacy' }, { label: 'Legacy', value: 'legacy' },
{ label: 'Carousel', value: 'carousel' }, { label: 'Carousel', value: 'carousel' },
{ label: 'Apple TV', value: 'appletv' } { label: 'Apple TV', value: 'appletv' }
]} ]}
@ -377,7 +390,7 @@ const HomeScreenSettings: React.FC = () => {
isDarkMode={isDarkMode} isDarkMode={isDarkMode}
colors={colors} colors={colors}
renderControl={() => ( renderControl={() => (
<CustomSwitch <CustomSwitch
value={settings.enableHomeHeroBackground} value={settings.enableHomeHeroBackground}
onValueChange={(value) => handleUpdateSetting('enableHomeHeroBackground', value)} onValueChange={(value) => handleUpdateSetting('enableHomeHeroBackground', value)}
/> />
@ -393,7 +406,7 @@ const HomeScreenSettings: React.FC = () => {
<Text style={[styles.cardHeader, { color: isDarkMode ? colors.mediumEmphasis : colors.textMutedDark }]}>Posters</Text> <Text style={[styles.cardHeader, { color: isDarkMode ? colors.mediumEmphasis : colors.textMutedDark }]}>Posters</Text>
<View style={styles.settingsRowInline}> <View style={styles.settingsRowInline}>
<Text style={[styles.rowLabel, { color: isDarkMode ? colors.highEmphasis : colors.textDark }]}>Show Titles</Text> <Text style={[styles.rowLabel, { color: isDarkMode ? colors.highEmphasis : colors.textDark }]}>Show Titles</Text>
<CustomSwitch <CustomSwitch
value={settings.showPosterTitles} value={settings.showPosterTitles}
onValueChange={(value) => handleUpdateSetting('showPosterTitles', value)} onValueChange={(value) => handleUpdateSetting('showPosterTitles', value)}
/> />