diff --git a/src/screens/ShowRatingsScreen.tsx b/src/screens/ShowRatingsScreen.tsx index 4f4560d..390ed0f 100644 --- a/src/screens/ShowRatingsScreen.tsx +++ b/src/screens/ShowRatingsScreen.tsx @@ -12,7 +12,7 @@ import { } from 'react-native'; import { Image } from 'expo-image'; import { BlurView } from 'expo-blur'; -import { colors } from '../styles'; +import { useTheme } from '../contexts/ThemeContext'; import { TMDBService, TMDBShow as Show, TMDBSeason, TMDBEpisode } from '../services/tmdbService'; import { RouteProp } from '@react-navigation/native'; import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; @@ -63,11 +63,12 @@ const getRatingColor = (rating: number): string => { }; // Memoized components -const RatingCell = memo(({ episode, ratingSource, getTVMazeRating, isCurrentSeason }: { +const RatingCell = memo(({ episode, ratingSource, getTVMazeRating, isCurrentSeason, theme }: { episode: TMDBEpisode; ratingSource: RatingSource; getTVMazeRating: (seasonNumber: number, episodeNumber: number) => number | null; isCurrentSeason: (episode: TMDBEpisode) => boolean; + theme: any; }) => { const getRatingForSource = useCallback((episode: TMDBEpisode): number | null => { switch (ratingSource) { @@ -101,14 +102,14 @@ const RatingCell = memo(({ episode, ratingSource, getTVMazeRating, isCurrentSeas if (!rating) { if (!episode.air_date || new Date(episode.air_date) > new Date()) { return ( - - + + ); } return ( - - + + ); } @@ -128,7 +129,7 @@ const RatingCell = memo(({ episode, ratingSource, getTVMazeRating, isCurrentSeas )} @@ -136,33 +137,43 @@ const RatingCell = memo(({ episode, ratingSource, getTVMazeRating, isCurrentSeas ); }); -const RatingSourceToggle = memo(({ ratingSource, setRatingSource }: { +const RatingSourceToggle = memo(({ ratingSource, setRatingSource, theme }: { ratingSource: RatingSource; setRatingSource: (source: RatingSource) => void; + theme: any; }) => ( - Rating Source: + Rating Source: - {['imdb', 'tmdb', 'tvmaze'].map((source) => ( - setRatingSource(source as RatingSource)} - > - {source.toUpperCase()} - - ))} + {['imdb', 'tmdb', 'tvmaze'].map((source) => { + const isActive = ratingSource === source; + return ( + setRatingSource(source as RatingSource)} + > + + {source.toUpperCase()} + + + ); + })} )); -const ShowInfo = memo(({ show }: { show: Show | null }) => ( +const ShowInfo = memo(({ show, theme }: { show: Show | null, theme: any }) => ( ( transition={200} /> - {show?.name} - + {show?.name} + {show?.first_air_date ? `${new Date(show.first_air_date).getFullYear()} - ${show.last_air_date ? new Date(show.last_air_date).getFullYear() : 'Present'}` : ''} - - + + {show?.number_of_seasons} Seasons • {show?.number_of_episodes} Episodes @@ -186,6 +197,8 @@ const ShowInfo = memo(({ show }: { show: Show | null }) => ( )); const ShowRatingsScreen = ({ route }: Props) => { + const { currentTheme } = useTheme(); + const { colors } = currentTheme; const { showId } = route.params; const [show, setShow] = useState(null); const [seasons, setSeasons] = useState([]); @@ -345,7 +358,7 @@ const ShowRatingsScreen = ({ route }: Props) => { - Loading show data... + Loading show data... @@ -370,7 +383,7 @@ const ShowRatingsScreen = ({ route }: Props) => { - Loading content... + Loading content... }> { entering={FadeIn.duration(300)} style={styles.showInfoContainer} > - + - + { style={styles.section} > {/* Legend */} - - Rating Scale + + Rating Scale {[ { color: '#186A3B', text: 'Awesome (9.0+)' }, @@ -412,18 +429,18 @@ const ShowRatingsScreen = ({ route }: Props) => { ].map((item, index) => ( - {item.text} + {item.text} ))} - + - Rating differs significantly from IMDb + Rating differs significantly from IMDb - Current season (ratings may change) + Current season (ratings may change) @@ -434,17 +451,17 @@ const ShowRatingsScreen = ({ route }: Props) => { style={styles.section} > {/* Ratings Grid */} - Episode Ratings - + Episode Ratings + {/* Fixed Episode Column */} - + - Episode + Episode {Array.from({ length: Math.max(...seasons.map(s => s.episodes.length)) }).map((_, episodeIndex) => ( - E{episodeIndex + 1} + E{episodeIndex + 1} ))} @@ -459,14 +476,14 @@ const ShowRatingsScreen = ({ route }: Props) => { > {/* Seasons Header */} - + {seasons.map((season) => ( - S{season.season_number} + S{season.season_number} ))} {loadingSeasons && ( @@ -474,7 +491,7 @@ const ShowRatingsScreen = ({ route }: Props) => { {loadingProgress > 0 && ( - + {Math.round(loadingProgress)}% )} @@ -498,6 +515,7 @@ const ShowRatingsScreen = ({ route }: Props) => { ratingSource={ratingSource} getTVMazeRating={getTVMazeRating} isCurrentSeason={isCurrentSeason} + theme={currentTheme} /> } @@ -539,7 +557,6 @@ const styles = StyleSheet.create({ gap: 12, }, loadingText: { - color: colors.lightGray, fontSize: 14, fontWeight: '500', }, @@ -551,7 +568,6 @@ const styles = StyleSheet.create({ }, showInfo: { flexDirection: 'row', - backgroundColor: Platform.OS === 'ios' ? 'transparent' : colors.darkBackground, borderRadius: 8, padding: 12, shadowColor: '#000', @@ -573,13 +589,11 @@ const styles = StyleSheet.create({ showTitle: { fontSize: 18, fontWeight: '800', - color: colors.white, marginBottom: 4, letterSpacing: 0.5, }, showYear: { fontSize: 13, - color: colors.lightGray, marginBottom: 4, }, episodeCountContainer: { @@ -590,7 +604,6 @@ const styles = StyleSheet.create({ }, episodeCount: { fontSize: 13, - color: colors.lightGray, }, ratingSourceContainer: { marginBottom: 12, @@ -598,7 +611,6 @@ const styles = StyleSheet.create({ sectionTitle: { fontSize: 15, fontWeight: '700', - color: colors.white, marginBottom: 8, letterSpacing: 0.5, }, @@ -611,25 +623,20 @@ const styles = StyleSheet.create({ paddingVertical: 6, borderRadius: 6, borderWidth: 1, - borderColor: colors.lightGray, flex: 1, alignItems: 'center', }, sourceButtonActive: { - backgroundColor: colors.primary, - borderColor: colors.primary, + fontWeight: '700', }, sourceButtonText: { - color: colors.lightGray, fontSize: 13, fontWeight: '600', }, sourceButtonTextActive: { - color: colors.white, fontWeight: '700', }, legend: { - backgroundColor: Platform.OS === 'ios' ? 'transparent' : colors.darkBackground, borderRadius: 8, padding: 12, shadowColor: '#000', @@ -657,14 +664,12 @@ const styles = StyleSheet.create({ marginRight: 6, }, legendText: { - color: colors.lightGray, fontSize: 12, }, warningLegends: { marginTop: 8, gap: 4, borderTopWidth: 1, - borderTopColor: colors.black + '40', paddingTop: 8, }, warningLegend: { @@ -673,12 +678,10 @@ const styles = StyleSheet.create({ gap: 6, }, warningText: { - color: colors.lightGray, fontSize: 12, flex: 1, }, ratingsGrid: { - backgroundColor: Platform.OS === 'ios' ? 'transparent' : colors.darkBackground, borderRadius: 8, padding: 12, shadowColor: '#000', @@ -693,7 +696,6 @@ const styles = StyleSheet.create({ fixedColumn: { width: 40, borderRightWidth: 1, - borderRightColor: colors.black + '40', paddingRight: 6, }, seasonsScrollView: { @@ -703,7 +705,6 @@ const styles = StyleSheet.create({ flexDirection: 'row', marginBottom: 8, borderBottomWidth: 1, - borderBottomColor: colors.black + '40', paddingBottom: 6, paddingLeft: 6, }, @@ -728,13 +729,11 @@ const styles = StyleSheet.create({ alignItems: 'center', }, headerText: { - color: colors.white, fontWeight: '700', fontSize: 13, letterSpacing: 0.5, }, episodeText: { - color: colors.lightGray, fontSize: 13, fontWeight: '500', }, @@ -746,7 +745,7 @@ const styles = StyleSheet.create({ alignItems: 'center', }, ratingText: { - color: colors.white, + color: 'white', fontSize: 12, fontWeight: '700', }, @@ -759,7 +758,7 @@ const styles = StyleSheet.create({ position: 'absolute', top: -4, right: -4, - backgroundColor: colors.black, + backgroundColor: 'black', borderRadius: 8, padding: 1, }, @@ -774,7 +773,6 @@ const styles = StyleSheet.create({ gap: 4, }, loadingProgressText: { - color: colors.primary, fontSize: 10, fontWeight: '600', },