From 854545e825afe4b2742dcb47405d7e1802389d14 Mon Sep 17 00:00:00 2001 From: tapframe Date: Sun, 4 May 2025 01:21:08 +0530 Subject: [PATCH] Refactor SeriesContent component to integrate theme context for improved UI consistency This update modifies the SeriesContent component to utilize the new ThemeContext, allowing for dynamic theming throughout the component. Styles have been adjusted to reflect the current theme colors, enhancing visual consistency and user experience. Key changes include updates to loading indicators, text colors, and background styles, ensuring a cohesive interface that adapts to different themes. --- src/components/metadata/SeriesContent.tsx | 68 ++++++++++------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/components/metadata/SeriesContent.tsx b/src/components/metadata/SeriesContent.tsx index c41cb890..3ad9b8e3 100644 --- a/src/components/metadata/SeriesContent.tsx +++ b/src/components/metadata/SeriesContent.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState, useRef } from 'react'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity, ActivityIndicator, Dimensions, useWindowDimensions, useColorScheme } from 'react-native'; import { Image } from 'expo-image'; import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; -import { colors } from '../../styles/colors'; +import { useTheme } from '../../contexts/ThemeContext'; import { Episode } from '../../types/metadata'; import { tmdbService } from '../../services/tmdbService'; import { storageService } from '../../services/storageService'; @@ -33,6 +33,7 @@ export const SeriesContent: React.FC = ({ groupedEpisodes = {}, metadata }) => { + const { currentTheme } = useTheme(); const { width } = useWindowDimensions(); const isTablet = width > 768; const isDarkMode = useColorScheme() === 'dark'; @@ -95,8 +96,8 @@ export const SeriesContent: React.FC = ({ if (loadingSeasons) { return ( - - Loading episodes... + + Loading episodes... ); } @@ -104,8 +105,8 @@ export const SeriesContent: React.FC = ({ if (episodes.length === 0) { return ( - - No episodes available + + No episodes available ); } @@ -119,7 +120,7 @@ export const SeriesContent: React.FC = ({ return ( - Seasons + Seasons = ({ key={season} style={[ styles.seasonButton, - selectedSeason === season && styles.selectedSeasonButton + selectedSeason === season && [styles.selectedSeasonButton, { borderColor: currentTheme.colors.primary }] ]} onPress={() => onSeasonChange(season)} > @@ -153,13 +154,13 @@ export const SeriesContent: React.FC = ({ contentFit="cover" /> {selectedSeason === season && ( - + )} Season {season} @@ -215,7 +216,11 @@ export const SeriesContent: React.FC = ({ return ( onSelectEpisode(episode)} activeOpacity={0.7} > @@ -233,21 +238,21 @@ export const SeriesContent: React.FC = ({ )} {progressPercent >= 95 && ( - - + + )} - + {episode.name} @@ -258,27 +263,27 @@ export const SeriesContent: React.FC = ({ style={styles.tmdbLogo} contentFit="contain" /> - + {episode.vote_average.toFixed(1)} )} {episode.runtime && ( - - + + {formatRuntime(episode.runtime)} )} {episode.air_date && ( - + {formatDate(episode.air_date)} )} - + {episode.overview || 'No description available'} @@ -286,6 +291,8 @@ export const SeriesContent: React.FC = ({ ); }; + const currentSeasonEpisodes = groupedEpisodes[selectedSeason] || []; + return ( = ({ - + {episodes.length} {episodes.length === 1 ? 'Episode' : 'Episodes'} @@ -310,7 +317,7 @@ export const SeriesContent: React.FC = ({ > {isTablet ? ( - {episodes.map((episode, index) => ( + {currentSeasonEpisodes.map((episode, index) => ( = ({ ))} ) : ( - episodes.map((episode, index) => ( + currentSeasonEpisodes.map((episode, index) => (