Merge pull request #292 from AdityasahuX07/patch-14

Video player Ui changes
This commit is contained in:
Nayif 2025-12-25 12:46:25 +05:30 committed by GitHub
commit d2987ce0cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 734 additions and 1374 deletions

View file

@ -1,13 +1,14 @@
import React from 'react';
import { View, Text, TouchableOpacity, ScrollView, StyleSheet, Platform, useWindowDimensions } from 'react-native';
import { View, Text, TouchableOpacity, ScrollView, useWindowDimensions, StyleSheet, Platform } from 'react-native';
import { MaterialIcons } from '@expo/vector-icons';
import Animated, {
FadeIn,
FadeOut,
SlideInRight,
SlideOutRight,
SlideInDown,
SlideOutDown,
} from 'react-native-reanimated';
import { getTrackDisplayName } from '../utils/playerUtils';
import { getTrackDisplayName, DEBUG_MODE } from '../utils/playerUtils';
import { logger } from '../../../utils/logger';
interface AudioTrackModalProps {
showAudioModal: boolean;
@ -24,42 +25,54 @@ export const AudioTrackModal: React.FC<AudioTrackModalProps> = ({
selectedAudioTrack,
selectAudioTrack,
}) => {
const { width } = useWindowDimensions();
const MENU_WIDTH = Math.min(width * 0.85, 400);
const { width, height } = useWindowDimensions();
// Size constants matching SubtitleModal aesthetics
const menuWidth = Math.min(width * 0.9, 420);
const menuMaxHeight = height * 0.9;
const handleClose = () => setShowAudioModal(false);
if (!showAudioModal) return null;
return (
<View style={[StyleSheet.absoluteFill, { zIndex: 9999 }]}>
<TouchableOpacity style={StyleSheet.absoluteFill} activeOpacity={1} onPress={handleClose}>
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(150)} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }} />
<View style={StyleSheet.absoluteFill} zIndex={9999}>
{/* Backdrop matching SubtitleModal */}
<TouchableOpacity
style={StyleSheet.absoluteFill}
activeOpacity={1}
onPress={handleClose}
>
<Animated.View
entering={FadeIn.duration(200)}
exiting={FadeOut.duration(150)}
style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.4)' }}
/>
</TouchableOpacity>
{/* Center Alignment Container */}
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }} pointerEvents="box-none">
<Animated.View
entering={SlideInRight.duration(300)}
exiting={SlideOutRight.duration(250)}
entering={SlideInDown.duration(300)}
exiting={SlideOutDown.duration(250)}
style={{
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
width: MENU_WIDTH,
backgroundColor: '#0f0f0f',
borderLeftWidth: 1,
width: menuWidth,
maxHeight: menuMaxHeight,
backgroundColor: 'rgba(15, 15, 15, 0.98)', // Matches SubtitleModal
borderRadius: 24,
borderWidth: 1,
borderColor: 'rgba(255,255,255,0.1)',
overflow: 'hidden'
}}
>
<View style={{ paddingTop: Platform.OS === 'ios' ? 60 : 15, paddingHorizontal: 20 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 }}>
<Text style={{ color: 'white', fontSize: 22, fontWeight: '700' }}>Audio Tracks</Text>
</View>
{/* Header with shared aesthetics */}
<View style={{ flexDirection: 'row', alignItems: 'center', padding: 20, position: 'relative' }}>
<Text style={{ color: 'white', fontSize: 18, fontWeight: '700' }}>Audio Tracks</Text>
</View>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ padding: 15, paddingBottom: 40 }}
contentContainerStyle={{ paddingHorizontal: 20, paddingBottom: 20 }}
>
<View style={{ gap: 8 }}>
{ksAudioTracks.map((track) => {
@ -73,12 +86,9 @@ export const AudioTrackModal: React.FC<AudioTrackModalProps> = ({
setTimeout(handleClose, 200);
}}
style={{
paddingHorizontal: 16,
paddingVertical: 12,
padding: 10,
borderRadius: 12,
backgroundColor: isSelected ? 'white' : 'rgba(255,255,255,0.06)',
borderWidth: 1,
borderColor: isSelected ? 'white' : 'rgba(255,255,255,0.1)',
backgroundColor: isSelected ? 'white' : 'rgba(255,255,255,0.05)', // Matches SubtitleModal item colors
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center'
@ -87,7 +97,7 @@ export const AudioTrackModal: React.FC<AudioTrackModalProps> = ({
<View style={{ flex: 1 }}>
<Text style={{
color: isSelected ? 'black' : 'white',
fontWeight: isSelected ? '700' : '500',
fontWeight: isSelected ? '700' : '400',
fontSize: 15
}}>
{getTrackDisplayName(track)}
@ -108,6 +118,7 @@ export const AudioTrackModal: React.FC<AudioTrackModalProps> = ({
</ScrollView>
</Animated.View>
</View>
</View>
);
};

View file

@ -31,34 +31,22 @@ const QualityBadge = ({ quality }: { quality: string | null }) => {
color = '#F59E0B';
label = '4K';
} else if (qualityNum >= 1080) {
color = '#EF4444';
label = 'FHD';
color = '#3B82F6';
label = '1080p';
} else if (qualityNum >= 720) {
color = '#10B981';
label = 'HD';
label = '720p';
}
return (
<View
style={{
backgroundColor: `${color}20`,
borderColor: `${color}60`,
borderWidth: 1,
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: 8,
flexDirection: 'row',
alignItems: 'center',
}}
>
<Text style={{
color: color,
fontSize: 12,
fontWeight: '700',
letterSpacing: 0.5,
<View style={{
backgroundColor: color,
paddingHorizontal: 6,
paddingVertical: 2,
borderRadius: 4,
marginLeft: 8,
}}>
{label}
</Text>
<Text style={{ color: 'white', fontSize: 10, fontWeight: 'bold' }}>{label}</Text>
</View>
);
};
@ -114,7 +102,6 @@ export const EpisodeStreamsModal: React.FC<EpisodeStreamsModalProps> = ({
respondedProviders.add(addonId);
if (error) {
logger.warn(`[EpisodeStreamsModal] Error from ${addonName || addonId}:`, error);
setHasErrors(prev => [...prev, `${addonName || addonId}: ${error.message || 'Unknown error'}`]);
} else if (streams && streams.length > 0) {
setAvailableStreams(prev => ({
@ -124,29 +111,20 @@ export const EpisodeStreamsModal: React.FC<EpisodeStreamsModalProps> = ({
addonName: addonName || addonId
}
}));
logger.log(`[EpisodeStreamsModal] Added ${streams.length} streams from ${addonName || addonId}`);
} else {
logger.log(`[EpisodeStreamsModal] No streams from ${addonName || addonId}`);
}
if (completedProviders >= expectedProviders.size) {
logger.log(`[EpisodeStreamsModal] All providers completed. Total providers responded: ${respondedProviders.size}`);
setIsLoading(false);
}
});
// Fallback timeout
setTimeout(() => {
if (respondedProviders.size === 0) {
logger.warn(`[EpisodeStreamsModal] Timeout: No providers responded`);
setHasErrors(prev => [...prev, 'Timeout: No providers responded']);
setIsLoading(false);
}
}, 8000);
} catch (error) {
logger.error('[EpisodeStreamsModal] Error fetching streams:', error);
setHasErrors(prev => [...prev, `Failed to fetch streams: ${error}`]);
setIsLoading(false);
}
};
@ -162,9 +140,18 @@ export const EpisodeStreamsModal: React.FC<EpisodeStreamsModalProps> = ({
const sortedProviders = Object.entries(availableStreams);
return (
<View style={[StyleSheet.absoluteFill, { zIndex: 9999 }]}>
<TouchableOpacity style={StyleSheet.absoluteFill} activeOpacity={1} onPress={onClose}>
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(150)} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }} />
<View style={StyleSheet.absoluteFill} zIndex={10000}>
{/* Backdrop */}
<TouchableOpacity
style={StyleSheet.absoluteFill}
activeOpacity={1}
onPress={onClose}
>
<Animated.View
entering={FadeIn.duration(200)}
exiting={FadeOut.duration(150)}
style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }}
/>
</TouchableOpacity>
<Animated.View
@ -181,15 +168,20 @@ export const EpisodeStreamsModal: React.FC<EpisodeStreamsModalProps> = ({
borderColor: 'rgba(255,255,255,0.1)',
}}
>
<View style={{ paddingTop: Platform.OS === 'ios' ? 60 : 15, paddingHorizontal: 20 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 }}>
<View style={{ flex: 1 }}>
<Text style={{ color: 'white', fontSize: 22, fontWeight: '700' }} numberOfLines={1}>
{episode?.name || 'Select Stream'}
{/* Header */}
<View style={{
paddingTop: Platform.OS === 'ios' ? 60 : 20,
paddingHorizontal: 20,
paddingBottom: 20,
}}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start' }}>
<View style={{ flex: 1, marginRight: 10 }}>
<Text style={{ color: 'white', fontSize: 20, fontWeight: '700' }} numberOfLines={1}>
{episode?.name || 'Sources'}
</Text>
{episode && (
<Text style={{ color: 'rgba(255,255,255,0.6)', fontSize: 13, marginTop: 4 }}>
S{episode.season_number}E{episode.episode_number}
<Text style={{ color: 'rgba(255,255,255,0.5)', fontSize: 13, marginTop: 4 }}>
S{episode.season_number} E{episode.episode_number}
</Text>
)}
</View>
@ -198,39 +190,27 @@ export const EpisodeStreamsModal: React.FC<EpisodeStreamsModalProps> = ({
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ padding: 15, paddingBottom: 40 }}
contentContainerStyle={{ paddingHorizontal: 15, paddingBottom: 40 }}
>
{isLoading && (
<View style={{
backgroundColor: 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: 20,
alignItems: 'center',
}}>
<ActivityIndicator size="large" color="#3B82F6" />
<Text style={{
color: 'rgba(255, 255, 255, 0.6)',
fontSize: 14,
marginTop: 12,
textAlign: 'center',
}}>
Finding available streams...
</Text>
{isLoading && sortedProviders.length === 0 && (
<View style={{ padding: 40, alignItems: 'center' }}>
<ActivityIndicator color="white" />
<Text style={{ color: 'white', marginTop: 15, opacity: 0.6 }}>Finding sources...</Text>
</View>
)}
{!isLoading && sortedProviders.length > 0 && (
sortedProviders.map(([providerId, providerData]) => (
<View key={providerId} style={{ marginBottom: 30 }}>
{sortedProviders.map(([providerId, providerData]) => (
<View key={providerId} style={{ marginBottom: 20 }}>
<Text style={{
color: 'rgba(255, 255, 255, 0.7)',
fontSize: 14,
fontWeight: '600',
marginBottom: 15,
color: 'rgba(255, 255, 255, 0.4)',
fontSize: 12,
fontWeight: '700',
marginBottom: 10,
marginLeft: 5,
textTransform: 'uppercase',
letterSpacing: 0.5,
letterSpacing: 1,
}}>
{providerData.addonName} ({providerData.streams.length})
{providerData.addonName}
</Text>
<View style={{ gap: 8 }}>
@ -241,68 +221,31 @@ export const EpisodeStreamsModal: React.FC<EpisodeStreamsModalProps> = ({
<TouchableOpacity
key={`${providerId}-${index}`}
style={{
backgroundColor: 'rgba(255,255,255,0.06)',
padding: 8,
borderRadius: 12,
padding: 12,
backgroundColor: 'rgba(255,255,255,0.05)',
borderWidth: 1,
borderColor: 'rgba(255,255,255,0.1)',
borderColor: 'rgba(255,255,255,0.05)'
}}
onPress={() => {
onSelectStream(stream);
onClose();
}}
onPress={() => onSelectStream(stream)}
activeOpacity={0.7}
>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
<View style={{ flex: 1 }}>
<View style={{
flexDirection: 'row',
alignItems: 'center',
marginBottom: 8,
gap: 8,
}}>
<Text style={{
color: 'white',
fontSize: 15,
fontWeight: '500',
flex: 1,
}}>
{stream.title || stream.name || `Stream ${index + 1}`}
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 4 }}>
<Text style={{ color: 'white', fontWeight: '700', fontSize: 14, flex: 1 }} numberOfLines={1}>
{stream.name || 'Unknown Source'}
</Text>
{quality && <QualityBadge quality={quality} />}
<QualityBadge quality={quality} />
</View>
{(stream.size || stream.lang) && (
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
{stream.size && (
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<MaterialIcons name="storage" size={14} color="rgba(255,255,255,0.5)" />
<Text style={{
color: 'rgba(255,255,255,0.5)',
fontSize: 12,
fontWeight: '600',
marginLeft: 4,
}}>
{(stream.size / (1024 * 1024 * 1024)).toFixed(1)} GB
{stream.title && (
<Text style={{ color: 'rgba(255,255,255,0.5)', fontSize: 11 }} numberOfLines={2}>
{stream.title}
</Text>
</View>
)}
{stream.lang && (
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<MaterialIcons name="language" size={14} color="rgba(59,130,246,0.8)" />
<Text style={{
color: 'rgba(59,130,246,0.8)',
fontSize: 12,
fontWeight: '600',
marginLeft: 4,
}}>
{stream.lang.toUpperCase()}
</Text>
</View>
)}
</View>
)}
</View>
<View style={{ marginLeft: 12, alignItems: 'center' }}>
<MaterialIcons name="play-arrow" size={20} color="rgba(255,255,255,0.4)" />
</View>
</View>
</TouchableOpacity>
@ -310,63 +253,18 @@ export const EpisodeStreamsModal: React.FC<EpisodeStreamsModalProps> = ({
})}
</View>
</View>
))
)}
{!isLoading && sortedProviders.length === 0 && hasErrors.length === 0 && (
<View style={{
backgroundColor: 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: 20,
alignItems: 'center',
}}>
<MaterialIcons name="error-outline" size={48} color="rgba(255,255,255,0.3)" />
<Text style={{
color: 'rgba(255, 255, 255, 0.6)',
fontSize: 16,
marginTop: 16,
textAlign: 'center',
}}>
No sources available
</Text>
<Text style={{
color: 'rgba(255, 255, 255, 0.4)',
fontSize: 14,
marginTop: 8,
textAlign: 'center',
}}>
Try searching for different content
</Text>
</View>
)}
{!isLoading && hasErrors.length > 0 && (
<View style={{
backgroundColor: 'rgba(239, 68, 68, 0.1)',
borderRadius: 16,
padding: 16,
marginBottom: 20,
}}>
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 8 }}>
<MaterialIcons name="error" size={20} color="#EF4444" />
<Text style={{
color: '#EF4444',
fontSize: 14,
fontWeight: '600',
marginLeft: 8,
}}>
Errors occurred
</Text>
</View>
{hasErrors.map((error, index) => (
<Text key={index} style={{
color: '#EF4444',
fontSize: 12,
marginTop: 4,
}}>
{error}
</Text>
))}
{!isLoading && sortedProviders.length === 0 && (
<View style={{ padding: 40, alignItems: 'center', opacity: 0.5 }}>
<MaterialIcons name="cloud-off" size={48} color="white" />
<Text style={{ color: 'white', marginTop: 16, textAlign: 'center', fontWeight: '600' }}>No sources found</Text>
</View>
)}
{hasErrors.length > 0 && (
<View style={{ backgroundColor: 'rgba(239, 68, 68, 0.1)', borderRadius: 12, padding: 12, marginTop: 10 }}>
<Text style={{ color: '#EF4444', fontSize: 11 }}>Sources might be limited due to provider errors.</Text>
</View>
)}
</ScrollView>

View file

@ -43,7 +43,7 @@ export const EpisodesModal: React.FC<EpisodesModalProps> = ({
text: '#FFFFFF',
textMuted: 'rgba(255,255,255,0.6)',
mediumEmphasis: 'rgba(255,255,255,0.7)',
primary: '#3B82F6',
primary: 'rgba(255,255,255,0.9)',
white: '#FFFFFF',
elevation2: 'rgba(255,255,255,0.05)'
}
@ -55,21 +55,11 @@ export const EpisodesModal: React.FC<EpisodesModalProps> = ({
if (showEpisodesModal && metadata?.id) {
setIsLoadingProgress(true);
try {
const allProgress = await storageService.getAllWatchProgress();
const progress: { [key: string]: any } = {};
// Filter progress for current show's episodes
Object.entries(allProgress).forEach(([key, value]) => {
if (key.includes(metadata.id!)) {
progress[key] = value;
}
});
setEpisodeProgress(progress);
const progress = await storageService.getShowProgress(metadata.id);
setEpisodeProgress(progress || {});
// Trakt sync logic preserved
const traktService = TraktService.getInstance();
if (await traktService.isAuthenticated()) {
if (await TraktService.isAuthenticated()) {
// Optional: background sync logic
}
} catch (err) {
@ -94,7 +84,7 @@ export const EpisodesModal: React.FC<EpisodesModalProps> = ({
const currentSeasonEpisodes = groupedEpisodes[selectedSeason] || [];
return (
<View style={[StyleSheet.absoluteFill, { zIndex: 9999 }]}>
<View style={StyleSheet.absoluteFill} zIndex={9999}>
<TouchableOpacity style={StyleSheet.absoluteFill} activeOpacity={1} onPress={() => setShowEpisodesModal(false)}>
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(150)} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }} />
</TouchableOpacity>
@ -113,13 +103,18 @@ export const EpisodesModal: React.FC<EpisodesModalProps> = ({
borderColor: 'rgba(255,255,255,0.1)',
}}
>
<View style={{ paddingTop: Platform.OS === 'ios' ? 60 : 15, paddingHorizontal: 20 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 }}>
<View style={{ paddingTop: Platform.OS === 'ios' ? 60 : 20, paddingHorizontal: 20 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 10 }}>
<Text style={{ color: 'white', fontSize: 22, fontWeight: '700' }}>Episodes</Text>
</View>
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={{ paddingBottom: 15, gap: 8 }}>
{seasons.map((season) => (
{[...seasons]
.sort((a, b) => {
if (a === 0) return 1;
if (b === 0) return -1;
return a - b;
}).map((season) => (
<TouchableOpacity
key={season}
onPress={() => setSelectedSeason(season)}
@ -136,14 +131,14 @@ export const EpisodesModal: React.FC<EpisodesModalProps> = ({
color: selectedSeason === season ? 'black' : 'white',
fontWeight: selectedSeason === season ? '700' : '500'
}}>
Season {season}
{season === 0 ? 'Specials' : `Season ${season}`}
</Text>
</TouchableOpacity>
))}
</ScrollView>
</View>
<ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={{ padding: 15, paddingBottom: 40 }}>
<ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={{ padding: 18, paddingBottom: 40 }}>
{isLoadingProgress ? (
<ActivityIndicator color="white" style={{ marginTop: 20 }} />
) : (

View file

@ -22,41 +22,29 @@ const QualityBadge = ({ quality }: { quality: string | null }) => {
if (!quality) return null;
const qualityNum = parseInt(quality);
let color = '#8B5CF6'; // Default purple
let color = '#8B5CF6';
let label = `${quality}p`;
if (qualityNum >= 2160) {
color = '#F59E0B'; // Gold for 4K
color = '#F59E0B';
label = '4K';
} else if (qualityNum >= 1080) {
color = '#EF4444'; // Red for 1080p
label = 'FHD';
color = '#3B82F6';
label = '1080p';
} else if (qualityNum >= 720) {
color = '#10B981'; // Green for 720p
label = 'HD';
color = '#10B981';
label = '720p';
}
return (
<View
style={{
backgroundColor: `${color}20`,
borderColor: `${color}60`,
borderWidth: 1,
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: 8,
flexDirection: 'row',
alignItems: 'center',
}}
>
<Text style={{
color: color,
fontSize: 12,
fontWeight: '700',
letterSpacing: 0.5,
<View style={{
backgroundColor: color,
paddingHorizontal: 6,
paddingVertical: 2,
borderRadius: 4,
marginLeft: 8,
}}>
{label}
</Text>
<Text style={{ color: 'white', fontSize: 10, fontWeight: 'bold' }}>{label}</Text>
</View>
);
};
@ -97,9 +85,18 @@ export const SourcesModal: React.FC<SourcesModalProps> = ({
};
return (
<View style={[StyleSheet.absoluteFill, { zIndex: 9999 }]}>
<TouchableOpacity style={StyleSheet.absoluteFill} activeOpacity={1} onPress={handleClose}>
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(150)} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }} />
<View style={StyleSheet.absoluteFill} zIndex={10000}>
{/* Backdrop */}
<TouchableOpacity
style={StyleSheet.absoluteFill}
activeOpacity={1}
onPress={handleClose}
>
<Animated.View
entering={FadeIn.duration(200)}
exiting={FadeOut.duration(150)}
style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }}
/>
</TouchableOpacity>
<Animated.View
@ -116,32 +113,35 @@ export const SourcesModal: React.FC<SourcesModalProps> = ({
borderColor: 'rgba(255,255,255,0.1)',
}}
>
<View style={{ paddingTop: Platform.OS === 'ios' ? 60 : 15, paddingHorizontal: 20 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 }}>
<Text style={{ color: 'white', fontSize: 22, fontWeight: '700' }}>Change Source</Text>
</View>
{/* Header */}
<View style={{
paddingTop: Platform.OS === 'ios' ? 60 : 20,
paddingHorizontal: 20,
paddingBottom: 20,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center'
}}>
<Text style={{ color: 'white', fontSize: 20, fontWeight: '700' }}>
Change Source
</Text>
</View>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ padding: 15, paddingBottom: 40 }}
contentContainerStyle={{ paddingHorizontal: 15, paddingBottom: 40 }}
>
{isChangingSource && (
<View style={{
backgroundColor: 'rgba(34, 197, 94, 0.1)',
borderRadius: 16,
padding: 16,
marginBottom: 20,
borderRadius: 12,
padding: 10,
marginBottom: 15,
flexDirection: 'row',
alignItems: 'center',
}}>
<ActivityIndicator size="small" color="#22C55E" />
<Text style={{
color: '#22C55E',
fontSize: 14,
fontWeight: '600',
marginLeft: 12,
}}>
<Text style={{ color: '#22C55E', fontSize: 14, fontWeight: '600', marginLeft: 10 }}>
Switching source...
</Text>
</View>
@ -149,14 +149,15 @@ export const SourcesModal: React.FC<SourcesModalProps> = ({
{sortedProviders.length > 0 ? (
sortedProviders.map(([providerId, providerData]) => (
<View key={providerId} style={{ marginBottom: 30 }}>
<View key={providerId} style={{ marginBottom: 20 }}>
<Text style={{
color: 'rgba(255, 255, 255, 0.7)',
fontSize: 14,
fontWeight: '600',
marginBottom: 15,
color: 'rgba(255, 255, 255, 0.4)',
fontSize: 12,
fontWeight: '700',
marginBottom: 10,
marginLeft: 5,
textTransform: 'uppercase',
letterSpacing: 0.5,
letterSpacing: 1,
}}>
{providerData.addonName} ({providerData.streams.length})
</Text>
@ -170,12 +171,12 @@ export const SourcesModal: React.FC<SourcesModalProps> = ({
<TouchableOpacity
key={`${providerId}-${index}`}
style={{
backgroundColor: isSelected ? 'white' : 'rgba(255,255,255,0.06)',
padding: 8,
borderRadius: 12,
padding: 12,
backgroundColor: isSelected ? 'white' : 'rgba(255,255,255,0.05)',
borderWidth: 1,
borderColor: isSelected ? 'white' : 'rgba(255,255,255,0.1)',
opacity: (isChangingSource && !isSelected) ? 0.6 : 1,
borderColor: isSelected ? 'white' : 'rgba(255,255,255,0.05)',
opacity: (isChangingSource && !isSelected) ? 0.5 : 1,
}}
onPress={() => handleStreamSelect(stream)}
activeOpacity={0.7}
@ -183,60 +184,46 @@ export const SourcesModal: React.FC<SourcesModalProps> = ({
>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<View style={{ flex: 1 }}>
<View style={{
flexDirection: 'row',
alignItems: 'center',
marginBottom: 8,
gap: 8,
}}>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<Text style={{
color: isSelected ? 'black' : 'white',
fontSize: 15,
fontWeight: isSelected ? '700' : '500',
fontSize: 14,
flex: 1,
}}>
}} numberOfLines={1}>
{stream.title || stream.name || `Stream ${index + 1}`}
</Text>
{quality && <QualityBadge quality={quality} />}
<QualityBadge quality={quality} />
</View>
{(stream.size || stream.lang) && (
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
{stream.size && (
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<MaterialIcons name="storage" size={14} color={isSelected ? 'rgba(0,0,0,0.6)' : 'rgba(255,255,255,0.5)'} />
<Text style={{
color: isSelected ? 'rgba(0,0,0,0.6)' : 'rgba(255,255,255,0.5)',
fontSize: 12,
fontWeight: '600',
marginLeft: 4,
color: isSelected ? 'rgba(0,0,0,0.5)' : 'rgba(255,255,255,0.5)',
fontSize: 11,
}}>
{(stream.size / (1024 * 1024 * 1024)).toFixed(1)} GB
</Text>
</View>
)}
{stream.lang && (
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<MaterialIcons name="language" size={14} color={isSelected ? 'rgba(0,0,0,0.6)' : 'rgba(59,130,246,0.8)'} />
<Text style={{
color: isSelected ? 'rgba(0,0,0,0.6)' : 'rgba(59,130,246,0.8)',
fontSize: 12,
color: isSelected ? 'rgba(59, 130, 246, 1)' : 'rgba(59, 130, 246, 0.8)',
fontSize: 11,
fontWeight: '600',
marginLeft: 4,
}}>
{stream.lang.toUpperCase()}
</Text>
</View>
)}
</View>
)}
</View>
<View style={{ marginLeft: 12, alignItems: 'center' }}>
<View style={{ marginLeft: 12 }}>
{isSelected ? (
<MaterialIcons name="check" size={18} color="black" />
<MaterialIcons name="check" size={20} color="black" />
) : (
<MaterialIcons name="play-arrow" size={20} color="rgba(255,255,255,0.4)" />
<MaterialIcons name="play-arrow" size={20} color="rgba(255,255,255,0.3)" />
)}
</View>
</View>
@ -247,28 +234,10 @@ export const SourcesModal: React.FC<SourcesModalProps> = ({
</View>
))
) : (
<View style={{
backgroundColor: 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: 20,
alignItems: 'center',
}}>
<MaterialIcons name="error-outline" size={48} color="rgba(255,255,255,0.3)" />
<Text style={{
color: 'rgba(255, 255, 255, 0.6)',
fontSize: 16,
marginTop: 16,
textAlign: 'center',
}}>
No sources available
</Text>
<Text style={{
color: 'rgba(255, 255, 255, 0.4)',
fontSize: 14,
marginTop: 8,
textAlign: 'center',
}}>
Try searching for different content
<View style={{ padding: 40, alignItems: 'center', opacity: 0.5 }}>
<MaterialIcons name="cloud-off" size={48} color="white" />
<Text style={{ color: 'white', marginTop: 16, textAlign: 'center', fontWeight: '600' }}>
No sources found
</Text>
</View>
)}

View file

@ -1,11 +1,13 @@
import React from 'react';
import { View, Text, TouchableOpacity, Platform, useWindowDimensions, ScrollView, StyleSheet } from 'react-native';
import { View, Text, TouchableOpacity, useWindowDimensions, StyleSheet } from 'react-native';
import { MaterialIcons } from '@expo/vector-icons';
import Animated, {
FadeIn,
FadeOut,
SlideInRight,
SlideOutRight,
SlideInDown,
SlideOutDown,
useAnimatedStyle,
withTiming,
} from 'react-native-reanimated';
interface SpeedModalProps {
@ -19,7 +21,31 @@ interface SpeedModalProps {
setHoldToSpeedValue: (speed: number) => void;
}
export const SpeedModal: React.FC<SpeedModalProps> = ({
const MorphingButton = ({ label, isSelected, onPress, isSmall = false }: any) => {
const animatedStyle = useAnimatedStyle(() => {
return {
// Linear transition from 40 (Pill) to 10 (Rectangle)
borderRadius: withTiming(isSelected ? 10 : 40, { duration: 250 }),
backgroundColor: withTiming(isSelected ? (isSmall ? 'rgba(255,255,255,0.2)' : 'white') : 'rgba(255,255,255,0.06)', { duration: 50 }),
};
});
return (
<TouchableOpacity onPress={onPress} activeOpacity={0.8} style={{ flex: isSmall ? 0 : 1 }}>
<Animated.View style={[{ paddingVertical: isSmall ? 6 : 8, paddingHorizontal: isSmall ? 14 : 0, alignItems: 'center', justifyContent: 'center' }, animatedStyle]}>
<Text style={{
color: isSelected && !isSmall ? 'black' : 'white',
fontWeight: isSelected ? '700' : '400',
fontSize: isSmall ? 11 : 13
}}>
{label}
</Text>
</Animated.View>
</TouchableOpacity>
);
};
const SpeedModal: React.FC<SpeedModalProps> = ({
showSpeedModal,
setShowSpeedModal,
currentSpeed,
@ -30,219 +56,84 @@ export const SpeedModal: React.FC<SpeedModalProps> = ({
setHoldToSpeedValue,
}) => {
const { width } = useWindowDimensions();
const MENU_WIDTH = Math.min(width * 0.85, 400);
const speedPresets = [0.5, 1.0, 1.5, 2.0, 2.5];
const holdSpeedOptions = [1.5, 2.0];
const handleClose = () => {
setShowSpeedModal(false);
};
const handleSpeedSelect = (speed: number) => {
setPlaybackSpeed(speed);
};
const handleHoldSpeedSelect = (speed: number) => {
setHoldToSpeedValue(speed);
};
const speedPresets = [0.5, 1.0, 1.25, 1.5, 2.0, 2.5];
const holdSpeedOptions = [1.0, 2.0, 3.0];
if (!showSpeedModal) return null;
return (
<View style={[StyleSheet.absoluteFill, { zIndex: 9999 }]}>
<TouchableOpacity style={StyleSheet.absoluteFill} activeOpacity={1} onPress={handleClose}>
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(150)} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }} />
<View style={StyleSheet.absoluteFill} zIndex={9999}>
<TouchableOpacity
style={StyleSheet.absoluteFill}
activeOpacity={1}
onPress={() => setShowSpeedModal(false)}
>
<Animated.View entering={FadeIn} exiting={FadeOut} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.2)' }} />
</TouchableOpacity>
<View pointerEvents="box-none" style={{ ...StyleSheet.absoluteFillObject, justifyContent: 'center', alignItems: 'center', paddingBottom: 20 }}>
<Animated.View
entering={SlideInRight.duration(300)}
exiting={SlideOutRight.duration(250)}
entering={SlideInDown.duration(300)}
exiting={SlideOutDown.duration(250)}
style={{
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
width: MENU_WIDTH,
backgroundColor: '#0f0f0f',
borderLeftWidth: 1,
borderColor: 'rgba(255,255,255,0.1)',
width: Math.min(width * 0.9, 420),
backgroundColor: 'rgba(15, 15, 15, 0.95)',
borderRadius: 24,
padding: 20,
borderWidth: 1,
borderColor: 'rgba(255,255,255,0.1)'
}}
>
<View style={{ paddingTop: Platform.OS === 'ios' ? 60 : 15, paddingHorizontal: 20 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 }}>
<Text style={{ color: 'white', fontSize: 22, fontWeight: '700' }}>Playback Speed</Text>
</View>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginBottom: 20, alignItems: 'center' }}>
<Text style={{ color: 'white', fontSize: 16, fontWeight: '600'}}>Playback Speed</Text>
</View>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ padding: 15, paddingBottom: 40 }}
>
{/* Current Speed Display */}
<View style={{
backgroundColor: 'rgba(59, 130, 246, 0.15)',
borderRadius: 12,
padding: 12,
marginBottom: 20,
borderWidth: 1,
borderColor: 'rgba(59, 130, 246, 0.3)',
}}>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
<MaterialIcons name="play-arrow" size={20} color="#3B82F6" />
<Text style={{
color: '#3B82F6',
fontSize: 18,
fontWeight: '700',
marginLeft: 6
}}>
Current: {currentSpeed}x
</Text>
</View>
</View>
{/* Speed Presets */}
<View style={{ marginBottom: 20 }}>
<Text style={{
color: 'rgba(255, 255, 255, 0.7)',
fontSize: 14,
fontWeight: '600',
marginBottom: 12,
textTransform: 'uppercase',
letterSpacing: 0.5,
}}>
Speed Presets
</Text>
<View style={{ gap: 8 }}>
{speedPresets.map((speed) => {
const isSelected = currentSpeed === speed;
return (
<TouchableOpacity
{/* Speed Selection Row */}
<View style={{ flexDirection: 'row', gap: 6, marginBottom: 20 }}>
{speedPresets.map((speed) => (
<MorphingButton
key={speed}
onPress={() => handleSpeedSelect(speed)}
style={{
paddingHorizontal: 16,
paddingVertical: 12,
borderRadius: 12,
backgroundColor: isSelected ? 'white' : 'rgba(255,255,255,0.06)',
borderWidth: 1,
borderColor: isSelected ? 'white' : 'rgba(255,255,255,0.1)',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
}}
activeOpacity={0.7}
>
<Text style={{
color: isSelected ? 'black' : 'white',
fontWeight: isSelected ? '700' : '500',
fontSize: 15
}}>
{speed}x
</Text>
{isSelected && <MaterialIcons name="check" size={18} color="black" />}
</TouchableOpacity>
);
})}
</View>
label={`${speed}x`}
isSelected={currentSpeed === speed}
onPress={() => setPlaybackSpeed(speed)}
/>
))}
</View>
{/* Hold-to-Speed Settings */}
<View style={{ backgroundColor: 'rgba(255,255,255,0.06)', borderRadius: 12, padding: 16, borderWidth: 1, borderColor: 'rgba(255,255,255,0.1)' }}>
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 16 }}>
<MaterialIcons name="touch-app" size={18} color="rgba(255,255,255,0.7)" />
<Text style={{ color: 'rgba(255,255,255,0.7)', fontSize: 14, marginLeft: 6, fontWeight: '600', textTransform: 'uppercase', letterSpacing: 0.5 }}>
Hold-to-Speed
</Text>
</View>
<View style={{ height: 1, backgroundColor: 'rgba(255,255,255,0.1)', marginBottom: 14 }} />
{/* Enable Toggle */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 16 }}>
<Text style={{ color: 'white', fontWeight: '600', fontSize: 15 }}>Enable Hold Speed</Text>
{/* On Hold Section */}
<View>
<TouchableOpacity
style={{
width: 54,
height: 30,
backgroundColor: holdToSpeedEnabled ? '#22C55E' : 'rgba(255,255,255,0.25)',
borderRadius: 15,
justifyContent: 'center',
alignItems: holdToSpeedEnabled ? 'flex-end' : 'flex-start',
paddingHorizontal: 3
}}
onPress={() => setHoldToSpeedEnabled(!holdToSpeedEnabled)}
style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: holdToSpeedEnabled ? 15 : 0 }}
>
<View style={{ width: 24, height: 24, backgroundColor: 'white', borderRadius: 12 }} />
</TouchableOpacity>
</View>
{/* Hold Speed Selector */}
{holdToSpeedEnabled && (
<View style={{ marginBottom: 16 }}>
<Text style={{ color: 'white', fontWeight: '600', marginBottom: 10, fontSize: 15 }}>Hold Speed</Text>
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={{ gap: 8 }}>
{holdSpeedOptions.map((speed) => {
const isSelected = holdToSpeedValue === speed;
return (
<TouchableOpacity
key={speed}
onPress={() => handleHoldSpeedSelect(speed)}
style={{
paddingHorizontal: 16,
paddingVertical: 8,
borderRadius: 20,
backgroundColor: isSelected ? 'white' : 'rgba(255,255,255,0.06)',
borderWidth: 1,
borderColor: isSelected ? 'white' : 'rgba(255,255,255,0.1)',
}}
activeOpacity={0.7}
>
<Text style={{
color: isSelected ? 'black' : 'white',
fontWeight: isSelected ? '700' : '500',
fontSize: 14
}}>
{speed}x
</Text>
</TouchableOpacity>
);
})}
</ScrollView>
</View>
)}
{/* Info Text */}
<Text style={{ color: 'rgba(255,255,255,0.7)', fontSize: 14 }}>On Hold</Text>
<View style={{
backgroundColor: 'rgba(34, 197, 94, 0.1)',
borderRadius: 10,
padding: 12,
borderWidth: 1,
borderColor: 'rgba(34, 197, 94, 0.3)',
width: 34, height: 18, borderRadius: 10,
backgroundColor: holdToSpeedEnabled ? 'white' : 'rgba(255,255,255,0.2)',
padding: 2, alignItems: holdToSpeedEnabled ? 'flex-end' : 'flex-start'
}}>
<View style={{ flexDirection: 'row', alignItems: 'flex-start', gap: 8 }}>
<MaterialIcons name="info" size={16} color="#22C55E" />
<View style={{ flex: 1 }}>
<Text style={{
color: '#22C55E',
fontSize: 13,
fontWeight: '600',
marginBottom: 4,
}}>
Hold left/right sides
</Text>
<Text style={{
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 12,
lineHeight: 16,
}}>
Hold and press the left or right side of the video player to temporarily boost playback speed.
</Text>
<View style={{ width: 14, height: 14, borderRadius: 7, backgroundColor: holdToSpeedEnabled ? 'black' : 'white' }} />
</View>
</View>
</View>
</View>
</ScrollView>
</TouchableOpacity>
{holdToSpeedEnabled && (
<Animated.View entering={FadeIn} style={{ flexDirection: 'row', gap: 8 }}>
{holdSpeedOptions.map((speed) => (
<MorphingButton
key={speed}
isSmall
label={`${speed}x`}
isSelected={holdToSpeedValue === speed}
onPress={() => setHoldToSpeedValue(speed)}
/>
))}
</Animated.View>
)}
</View>
</Animated.View>
</View>
</View>
);
};

View file

@ -1,16 +1,16 @@
import React from 'react';
import { View, Text, TouchableOpacity, ScrollView, ActivityIndicator, Platform, useWindowDimensions } from 'react-native';
import { View, Text, TouchableOpacity, ScrollView, Platform, useWindowDimensions, StyleSheet } from 'react-native';
import { MaterialIcons } from '@expo/vector-icons';
import Animated, {
FadeIn,
FadeOut,
SlideInRight,
SlideOutRight,
SlideInDown,
SlideOutDown,
useAnimatedStyle,
withTiming,
} from 'react-native-reanimated';
import { StyleSheet } from 'react-native';
import { WyzieSubtitle, SubtitleCue } from '../utils/playerTypes';
import { getTrackDisplayName, formatLanguage } from '../utils/playerUtils';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
interface SubtitleModalsProps {
showSubtitleModal: boolean;
@ -24,7 +24,6 @@ interface SubtitleModalsProps {
ksTextTracks: Array<{id: number, name: string, language?: string}>;
selectedTextTrack: number;
useCustomSubtitles: boolean;
// When true, KSPlayer is active (iOS MKV path). Use to gate iOS-only limitations.
isKsPlayerActive?: boolean;
subtitleSize: number;
subtitleBackground: boolean;
@ -35,7 +34,6 @@ interface SubtitleModalsProps {
increaseSubtitleSize: () => void;
decreaseSubtitleSize: () => void;
toggleSubtitleBackground: () => void;
// Customization props
subtitleTextColor: string;
setSubtitleTextColor: (c: string) => void;
subtitleBgOpacity: number;
@ -60,475 +58,137 @@ interface SubtitleModalsProps {
setSubtitleOffsetSec: (n: number) => void;
}
// Dynamic sizing handled inside component with useWindowDimensions
const MorphingTab = ({ label, isSelected, onPress }: any) => {
const animatedStyle = useAnimatedStyle(() => ({
borderRadius: withTiming(isSelected ? 10 : 40, { duration: 250 }),
backgroundColor: withTiming(isSelected ? 'white' : 'rgba(255,255,255,0.06)', { duration: 250 }),
}));
return (
<TouchableOpacity onPress={onPress} activeOpacity={0.8} style={{ flex: 1 }}>
<Animated.View style={[{ paddingVertical: 8, alignItems: 'center', justifyContent: 'center' }, animatedStyle]}>
<Text style={{ color: isSelected ? 'black' : 'white', fontWeight: isSelected ? '700' : '400', fontSize: 13 }}>
{label}
</Text>
</Animated.View>
</TouchableOpacity>
);
};
export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
showSubtitleModal,
setShowSubtitleModal,
showSubtitleLanguageModal,
setShowSubtitleLanguageModal,
isLoadingSubtitleList,
isLoadingSubtitles,
customSubtitles,
availableSubtitles,
ksTextTracks,
selectedTextTrack,
useCustomSubtitles,
isKsPlayerActive,
subtitleSize,
subtitleBackground,
fetchAvailableSubtitles,
loadWyzieSubtitle,
selectTextTrack,
disableCustomSubtitles,
increaseSubtitleSize,
decreaseSubtitleSize,
toggleSubtitleBackground,
subtitleTextColor,
setSubtitleTextColor,
subtitleBgOpacity,
setSubtitleBgOpacity,
subtitleTextShadow,
setSubtitleTextShadow,
subtitleOutline,
setSubtitleOutline,
subtitleOutlineColor,
setSubtitleOutlineColor,
subtitleOutlineWidth,
setSubtitleOutlineWidth,
subtitleAlign,
setSubtitleAlign,
subtitleBottomOffset,
setSubtitleBottomOffset,
subtitleLetterSpacing,
setSubtitleLetterSpacing,
subtitleLineHeightMultiplier,
setSubtitleLineHeightMultiplier,
subtitleOffsetSec,
setSubtitleOffsetSec,
showSubtitleModal, setShowSubtitleModal, isLoadingSubtitleList, isLoadingSubtitles,
availableSubtitles, ksTextTracks, selectedTextTrack, useCustomSubtitles,
subtitleSize, subtitleBackground, fetchAvailableSubtitles,
loadWyzieSubtitle, selectTextTrack, increaseSubtitleSize,
decreaseSubtitleSize, toggleSubtitleBackground, subtitleTextColor, setSubtitleTextColor,
subtitleBgOpacity, setSubtitleBgOpacity, subtitleTextShadow, setSubtitleTextShadow,
subtitleOutline, setSubtitleOutline, subtitleOutlineColor, setSubtitleOutlineColor,
subtitleOutlineWidth, setSubtitleOutlineWidth, subtitleAlign, setSubtitleAlign,
subtitleBottomOffset, setSubtitleBottomOffset, subtitleLetterSpacing, setSubtitleLetterSpacing,
subtitleLineHeightMultiplier, setSubtitleLineHeightMultiplier, subtitleOffsetSec, setSubtitleOffsetSec,
}) => {
const insets = useSafeAreaInsets();
const { width, height } = useWindowDimensions();
const isIos = Platform.OS === 'ios';
const isLandscape = width > height;
// Track which specific addon subtitle is currently loaded
const [selectedOnlineSubtitleId, setSelectedOnlineSubtitleId] = React.useState<string | null>(null);
// Track which addon subtitle is currently loading to show spinner per-item
const [loadingSubtitleId, setLoadingSubtitleId] = React.useState<string | null>(null);
// Active tab for better organization
const [activeTab, setActiveTab] = React.useState<'built-in' | 'addon' | 'appearance'>(useCustomSubtitles ? 'addon' : 'built-in');
// Responsive tuning
const [activeTab, setActiveTab] = React.useState<'built-in' | 'addon' | 'appearance'>('built-in');
const isCompact = width < 360 || height < 640;
const sectionPad = isCompact ? 12 : 16;
const chipPadH = isCompact ? 8 : 12;
const chipPadV = isCompact ? 6 : 8;
const controlBtn = { size: isCompact ? 28 : 32, radius: isCompact ? 14 : 16 };
const previewHeight = isCompact ? 90 : (isIos && isLandscape ? 100 : 120);
const menuWidth = Math.min(
width * (isIos ? (isLandscape ? 0.6 : 0.8) : 0.85),
isIos ? 420 : 400
);
const menuWidth = Math.min(width * 0.9, 420);
const menuMaxHeight = height * 0.95;
React.useEffect(() => {
if (showSubtitleModal && !isLoadingSubtitleList && availableSubtitles.length === 0) {
fetchAvailableSubtitles();
}
if (showSubtitleModal && !isLoadingSubtitleList && availableSubtitles.length === 0) fetchAvailableSubtitles();
}, [showSubtitleModal]);
// Reset selected addon subtitle when switching to built-in tracks
React.useEffect(() => {
if (!useCustomSubtitles) {
setSelectedOnlineSubtitleId(null);
}
}, [useCustomSubtitles]);
const handleClose = () => setShowSubtitleModal(false);
// Clear loading state when subtitles have finished loading
React.useEffect(() => {
if (!isLoadingSubtitles) {
setLoadingSubtitleId(null);
}
}, [isLoadingSubtitles]);
// Keep tab in sync with current usage
React.useEffect(() => {
setActiveTab(useCustomSubtitles ? 'addon' : 'built-in');
}, [useCustomSubtitles]);
const handleClose = () => {
setShowSubtitleModal(false);
};
const handleLoadWyzieSubtitle = (subtitle: WyzieSubtitle) => {
setSelectedOnlineSubtitleId(subtitle.id);
setLoadingSubtitleId(subtitle.id);
loadWyzieSubtitle(subtitle);
};
const getFileNameFromUrl = (url?: string): string | null => {
if (!url || typeof url !== 'string') return null;
try {
// Prefer URL parsing to safely strip query/hash
const u = new URL(url);
const raw = u.pathname.split('/').pop() || '';
const decoded = decodeURIComponent(raw);
return decoded || null;
} catch {
// Fallback for non-standard URLs
const path = url.split('?')[0].split('#')[0];
const raw = path.split('/').pop() || '';
try { return decodeURIComponent(raw) || null; } catch { return raw || null; }
}
};
// Main subtitle menu
const renderSubtitleMenu = () => {
if (!showSubtitleModal) return null;
return (
<View style={[StyleSheet.absoluteFill, { zIndex: 9999 }]}>
<View style={StyleSheet.absoluteFill} zIndex={9999}>
{/* Backdrop */}
<TouchableOpacity style={StyleSheet.absoluteFill} activeOpacity={1} onPress={handleClose}>
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(150)} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }} />
<Animated.View entering={FadeIn} exiting={FadeOut} style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.5)' }} />
</TouchableOpacity>
{/* Centered Modal Container */}
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }} pointerEvents="box-none">
<Animated.View
entering={SlideInRight.duration(300)}
exiting={SlideOutRight.duration(250)}
entering={SlideInDown.duration(300)}
exiting={SlideOutDown.duration(250)}
style={{
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
width: menuWidth,
maxHeight: menuMaxHeight,
backgroundColor: '#0f0f0f',
borderLeftWidth: 1,
borderRadius: 24,
borderWidth: 1,
borderColor: 'rgba(255,255,255,0.1)',
overflow: 'hidden'
}}
>
<View style={{ paddingTop: Platform.OS === 'ios' ? 60 : 15, paddingHorizontal: 20 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 15 }}>
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
<Text style={{ color: 'white', fontSize: 22, fontWeight: '700' }}>Subtitles</Text>
<View style={{ paddingHorizontal: 10, paddingVertical: 4, borderRadius: 12, backgroundColor: useCustomSubtitles ? 'rgba(34,197,94,0.2)' : 'rgba(59,130,246,0.2)' }}>
<Text style={{ color: useCustomSubtitles ? '#22C55E' : '#3B82F6', fontSize: 11, fontWeight: '700' }}>
{useCustomSubtitles ? 'Addon in use' : 'Builtin in use'}
</Text>
</View>
</View>
</View>
{/* Header */}
<View style={{ flexDirection: 'row', alignItems: 'center', padding: 20, position: 'relative' }}>
<Text style={{ color: 'white', fontSize: 18, fontWeight: '700' }}>Subtitles</Text>
</View>
{/* Segmented Tabs */}
<View style={{ flexDirection: 'row', gap: 8, paddingHorizontal: 20, paddingTop: 10, paddingBottom: 6 }}>
{([
{ key: 'built-in', label: 'Builtin' },
{ key: 'addon', label: 'Addons' },
{ key: 'appearance', label: 'Appearance' },
] as const).map(tab => (
<TouchableOpacity
key={tab.key}
onPress={() => setActiveTab(tab.key)}
style={{
paddingHorizontal: chipPadH,
paddingVertical: chipPadV,
borderRadius: 16,
backgroundColor: activeTab === tab.key ? 'rgba(255,255,255,0.15)' : 'rgba(255,255,255,0.06)',
borderWidth: 1,
borderColor: activeTab === tab.key ? 'rgba(255,255,255,0.3)' : 'rgba(255,255,255,0.1)'
}}
>
<Text style={{ color: '#fff', fontWeight: '600', fontSize: isCompact ? 12 : 13 }}>{tab.label}</Text>
</TouchableOpacity>
))}
{/* Tab Bar */}
<View style={{ flexDirection: 'row', gap: 15, paddingHorizontal: 70, marginBottom: 20 }}>
<MorphingTab label="Built-in" isSelected={activeTab === 'built-in'} onPress={() => setActiveTab('built-in')} />
<MorphingTab label="Addons" isSelected={activeTab === 'addon'} onPress={() => setActiveTab('addon')} />
<MorphingTab label="Style" isSelected={activeTab === 'appearance'} onPress={() => setActiveTab('appearance')} />
</View>
<ScrollView
style={{ flex: 1 }}
contentContainerStyle={{ padding: 20, paddingBottom: (isCompact ? 24 : 40) + (isIos ? insets.bottom : 0) }}
showsVerticalScrollIndicator={false}
>
<ScrollView showsVerticalScrollIndicator={false}>
<View style={{ paddingHorizontal: 20, paddingBottom: 20 }}>
{activeTab === 'built-in' && (
<View style={{ marginBottom: 30 }}>
<Text style={{
color: 'rgba(255, 255, 255, 0.7)',
fontSize: 14,
fontWeight: '600',
marginBottom: 15,
textTransform: 'uppercase',
letterSpacing: 0.5,
}}>
Built-in Subtitles
</Text>
{/* Built-in subtitles now enabled for KSPlayer */}
{isKsPlayerActive && (
<View style={{
backgroundColor: 'rgba(34, 197, 94, 0.1)',
borderRadius: 12,
padding: sectionPad,
marginBottom: 15,
borderWidth: 1,
borderColor: 'rgba(34, 197, 94, 0.3)',
}}>
<View style={{ flexDirection: 'row', alignItems: 'flex-start', gap: 8 }}>
<MaterialIcons name="check-circle" size={18} color="#22C55E" />
<View style={{ flex: 1 }}>
<Text style={{
color: '#22C55E',
fontSize: isCompact ? 12 : 13,
fontWeight: '600',
marginBottom: 4,
}}>
Built-in subtitles enabled for KSPlayer
</Text>
<Text style={{
color: 'rgba(255, 255, 255, 0.8)',
fontSize: isCompact ? 11 : 12,
lineHeight: isCompact ? 16 : 18,
}}>
KSPlayer built-in subtitle rendering is now available. You can select from embedded subtitle tracks below.
</Text>
</View>
</View>
</View>
)}
{/* Disable Subtitles Button */}
<TouchableOpacity
style={{
backgroundColor: selectedTextTrack === -1 ? 'rgba(239, 68, 68, 0.15)' : 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: sectionPad,
borderWidth: 1,
borderColor: selectedTextTrack === -1 ? 'rgba(239, 68, 68, 0.3)' : 'rgba(255, 255, 255, 0.1)',
marginBottom: 8,
}}
onPress={() => {
selectTextTrack(-1);
setSelectedOnlineSubtitleId(null);
}}
activeOpacity={0.7}
>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{
color: selectedTextTrack === -1 ? '#EF4444' : '#FFFFFF',
fontSize: isCompact ? 14 : 15,
fontWeight: '500',
flex: 1,
}}>
Disable All Subtitles
</Text>
{selectedTextTrack === -1 && (
<MaterialIcons name="check" size={20} color="#EF4444" />
)}
</View>
</TouchableOpacity>
{/* Always show built-in subtitles */}
{ksTextTracks.length > 0 && (
<View style={{ gap: 8 }}>
{ksTextTracks.map((track) => {
const isSelected = selectedTextTrack === track.id && !useCustomSubtitles;
return (
<TouchableOpacity
onPress={() => { selectTextTrack(-1); setSelectedOnlineSubtitleId(null); }}
style={{ padding: 10, borderRadius: 12, backgroundColor: selectedTextTrack === -1 ? 'white' : 'rgba(242, 184, 181)' }}
>
<Text style={{ color: selectedTextTrack === -1 ? 'black' : 'rgba(96, 20, 16)', fontWeight: '600' }}>None</Text>
</TouchableOpacity>
{ksTextTracks.map((track) => (
<TouchableOpacity
key={track.id}
style={{
backgroundColor: isSelected ? 'rgba(59, 130, 246, 0.15)' : 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: sectionPad,
borderWidth: 1,
borderColor: isSelected ? 'rgba(59, 130, 246, 0.3)' : 'rgba(255, 255, 255, 0.1)',
}}
onPress={() => {
selectTextTrack(track.id);
setSelectedOnlineSubtitleId(null);
}}
activeOpacity={0.7}
onPress={() => { selectTextTrack(track.id); setSelectedOnlineSubtitleId(null); }}
style={{ padding: 10, borderRadius: 12, backgroundColor: selectedTextTrack === track.id ? 'white' : 'rgba(255,255,255,0.05)', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}
>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{
color: '#FFFFFF',
fontSize: isCompact ? 14 : 15,
fontWeight: '500',
flex: 1,
}}>
{getTrackDisplayName(track)}
</Text>
{isSelected && (
<MaterialIcons name="check" size={20} color="#3B82F6" />
)}
</View>
<Text style={{ color: selectedTextTrack === track.id ? 'black' : 'white' }}>{getTrackDisplayName(track)}</Text>
{selectedTextTrack === track.id && <MaterialIcons name="check" size={18} color="black" />}
</TouchableOpacity>
);
})}
</View>
)}
))}
</View>
)}
{activeTab === 'addon' && (
<View style={{ marginBottom: 30 }}>
<View style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: 15,
}}>
<Text style={{
color: 'rgba(255, 255, 255, 0.7)',
fontSize: isCompact ? 13 : 14,
fontWeight: '600',
textTransform: 'uppercase',
letterSpacing: 0.5,
}}>
Addon Subtitles
</Text>
<View style={{ flexDirection: 'row', gap: 8 }}>
{useCustomSubtitles && (
<TouchableOpacity
style={{
backgroundColor: 'rgba(239, 68, 68, 0.15)',
borderRadius: 12,
paddingHorizontal: chipPadH,
paddingVertical: chipPadV - 2,
flexDirection: 'row',
alignItems: 'center',
}}
onPress={() => {
disableCustomSubtitles();
setSelectedOnlineSubtitleId(null);
}}
activeOpacity={0.7}
>
<MaterialIcons name="close" size={16} color="#EF4444" />
<Text style={{
color: '#EF4444',
fontSize: isCompact ? 11 : 12,
fontWeight: '600',
marginLeft: 6,
}}>
Disable
</Text>
</TouchableOpacity>
)}
<TouchableOpacity
style={{
backgroundColor: 'rgba(34, 197, 94, 0.15)',
borderRadius: 12,
paddingHorizontal: chipPadH,
paddingVertical: chipPadV - 2,
flexDirection: 'row',
alignItems: 'center',
}}
onPress={() => fetchAvailableSubtitles()}
disabled={isLoadingSubtitleList}
>
{isLoadingSubtitleList ? (
<ActivityIndicator size="small" color="#22C55E" />
) : (
<MaterialIcons name="refresh" size={16} color="#22C55E" />
)}
<Text style={{
color: '#22C55E',
fontSize: isCompact ? 11 : 12,
fontWeight: '600',
marginLeft: 6,
}}>
{isLoadingSubtitleList ? 'Searching' : 'Refresh'}
</Text>
</TouchableOpacity>
</View>
</View>
{(availableSubtitles.length === 0) && !isLoadingSubtitleList ? (
<TouchableOpacity
style={{
backgroundColor: 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: isCompact ? 14 : 20,
alignItems: 'center',
borderWidth: 1,
borderColor: 'rgba(255, 255, 255, 0.1)',
borderStyle: 'dashed',
}}
onPress={() => fetchAvailableSubtitles()}
activeOpacity={0.7}
>
<MaterialIcons name="cloud-download" size={24} color="rgba(255,255,255,0.4)" />
<Text style={{
color: 'rgba(255, 255, 255, 0.6)',
fontSize: isCompact ? 13 : 14,
marginTop: 8,
textAlign: 'center',
}}>
Tap to fetch from addons
</Text>
</TouchableOpacity>
) : isLoadingSubtitleList ? (
<View style={{
backgroundColor: 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: isCompact ? 14 : 20,
alignItems: 'center',
}}>
<ActivityIndicator size="large" color="#22C55E" />
<Text style={{
color: 'rgba(255, 255, 255, 0.6)',
fontSize: isCompact ? 13 : 14,
marginTop: 12,
}}>
Searching...
</Text>
</View>
) : (
<View style={{ gap: 8 }}>
{availableSubtitles.map((sub) => {
const isSelected = useCustomSubtitles && selectedOnlineSubtitleId === sub.id;
return (
{availableSubtitles.length === 0 ? (
<TouchableOpacity onPress={fetchAvailableSubtitles} style={{ padding: 40, alignItems: 'center', opacity: 0.5 }}>
<MaterialIcons name="cloud-download" size={32} color="white" />
<Text style={{ color: 'white', marginTop: 10 }}>Search Online Subtitles</Text>
</TouchableOpacity>
) : (
availableSubtitles.map((sub) => (
<TouchableOpacity
key={sub.id}
style={{
backgroundColor: isSelected ? 'rgba(34, 197, 94, 0.15)' : 'rgba(255, 255, 255, 0.05)',
borderRadius: 16,
padding: sectionPad,
borderWidth: 1,
borderColor: isSelected ? 'rgba(34, 197, 94, 0.3)' : 'rgba(255, 255, 255, 0.1)',
}}
onPress={() => {
handleLoadWyzieSubtitle(sub);
}}
activeOpacity={0.7}
disabled={isLoadingSubtitles}
onPress={() => { setSelectedOnlineSubtitleId(sub.id); loadWyzieSubtitle(sub); }}
style={{ padding: 5,paddingLeft: 8, paddingRight: 10, borderRadius: 12, backgroundColor: selectedOnlineSubtitleId === sub.id ? 'white' : 'rgba(255,255,255,0.05)', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', textAlignVertical: 'center' }}
>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<View style={{ flex: 1 }}>
<Text style={{ color: '#FFFFFF', fontSize: 15, fontWeight: '500' }}>
{sub.display}
</Text>
{(() => {
const filename = getFileNameFromUrl(sub.url);
if (!filename) return null;
return (
<Text style={{ color: 'rgba(255,255,255,0.75)', fontSize: 12, marginTop: 2 }} numberOfLines={1}>
{filename}
</Text>
);
})()}
<Text style={{ color: 'rgba(255, 255, 255, 0.6)', fontSize: 13, marginTop: 2 }}>
{formatLanguage(sub.language)}{sub.source ? ` · ${sub.source}` : ''}
</Text>
</View>
{(isLoadingSubtitles && loadingSubtitleId === sub.id) ? (
<ActivityIndicator size="small" color="#22C55E" />
) : isSelected ? (
<MaterialIcons name="check" size={20} color="#22C55E" />
) : (
<MaterialIcons name="download" size={20} color="rgba(255,255,255,0.4)" />
)}
<View>
<Text style={{ marginLeft: 5, color: selectedOnlineSubtitleId === sub.id ? 'black' : 'white', fontWeight: '600' }}>{sub.display}</Text>
<Text style={{ marginLeft: 5, color: selectedOnlineSubtitleId === sub.id ? 'rgba(0,0,0,0.5)' : 'rgba(255,255,255,0.5)', fontSize: 11, paddingBottom: 3 }}>{formatLanguage(sub.language)}</Text>
</View>
{selectedOnlineSubtitleId === sub.id && <MaterialIcons name="check" size={18} color="black" />}
</TouchableOpacity>
);
})}
</View>
))
)}
</View>
)}
@ -555,9 +215,7 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
letterSpacing: subtitleLetterSpacing,
lineHeight: subtitleSize * subtitleLineHeightMultiplier,
textAlign: subtitleAlign,
textShadowColor: subtitleOutline
? subtitleOutlineColor
: (subtitleTextShadow ? 'rgba(0,0,0,0.9)' : undefined),
textShadowColor: subtitleOutline ? subtitleOutlineColor : (subtitleTextShadow ? 'rgba(0,0,0,0.9)' : undefined),
textShadowOffset: (subtitleOutline || subtitleTextShadow) ? { width: 2, height: 2 } : undefined,
textShadowRadius: subtitleOutline ? Math.max(1, subtitleOutlineWidth) : (subtitleTextShadow ? 4 : undefined),
}}>
@ -577,15 +235,9 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
<View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 8 }}>
<TouchableOpacity
onPress={() => {
setSubtitleTextColor('#FFFFFF');
setSubtitleBgOpacity(0.7);
setSubtitleTextShadow(true);
setSubtitleOutline(true);
setSubtitleOutlineColor('#000000');
setSubtitleOutlineWidth(4);
setSubtitleAlign('center');
setSubtitleBottomOffset(10);
setSubtitleLetterSpacing(0);
setSubtitleTextColor('#FFFFFF'); setSubtitleBgOpacity(0.7); setSubtitleTextShadow(true);
setSubtitleOutline(true); setSubtitleOutlineColor('#000000'); setSubtitleOutlineWidth(4);
setSubtitleAlign('center'); setSubtitleBottomOffset(10); setSubtitleLetterSpacing(0);
setSubtitleLineHeightMultiplier(1.2);
}}
style={{ paddingHorizontal: chipPadH, paddingVertical: chipPadV, borderRadius: 20, backgroundColor: 'rgba(255,255,255,0.08)', borderWidth: 1, borderColor: 'rgba(255,255,255,0.15)' }}
@ -594,12 +246,7 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
setSubtitleTextColor('#FFD700');
setSubtitleOutline(true);
setSubtitleOutlineColor('#000000');
setSubtitleOutlineWidth(4);
setSubtitleBgOpacity(0.3);
setSubtitleTextShadow(false);
setSubtitleTextColor('#FFD700'); setSubtitleOutline(true); setSubtitleOutlineColor('#000000'); setSubtitleOutlineWidth(4); setSubtitleBgOpacity(0.3); setSubtitleTextShadow(false);
}}
style={{ paddingHorizontal: chipPadH, paddingVertical: chipPadV, borderRadius: 20, backgroundColor: 'rgba(255,215,0,0.12)', borderWidth: 1, borderColor: 'rgba(255,215,0,0.35)' }}
>
@ -607,13 +254,7 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
setSubtitleTextColor('#FFFFFF');
setSubtitleOutline(true);
setSubtitleOutlineColor('#000000');
setSubtitleOutlineWidth(3);
setSubtitleBgOpacity(0.0);
setSubtitleTextShadow(false);
setSubtitleLetterSpacing(0.5);
setSubtitleTextColor('#FFFFFF'); setSubtitleOutline(true); setSubtitleOutlineColor('#000000'); setSubtitleOutlineWidth(3); setSubtitleBgOpacity(0.0); setSubtitleTextShadow(false); setSubtitleLetterSpacing(0.5);
}}
style={{ paddingHorizontal: chipPadH, paddingVertical: chipPadV, borderRadius: 20, backgroundColor: 'rgba(34,197,94,0.12)', borderWidth: 1, borderColor: 'rgba(34,197,94,0.35)' }}
>
@ -621,12 +262,7 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
setSubtitleTextColor('#FFFFFF');
setSubtitleBgOpacity(0.6);
setSubtitleTextShadow(true);
setSubtitleOutline(true);
setSubtitleAlign('center');
setSubtitleLineHeightMultiplier(1.3);
setSubtitleTextColor('#FFFFFF'); setSubtitleBgOpacity(0.6); setSubtitleTextShadow(true); setSubtitleOutline(true); setSubtitleAlign('center'); setSubtitleLineHeightMultiplier(1.3);
}}
style={{ paddingHorizontal: chipPadH, paddingVertical: chipPadV, borderRadius: 20, backgroundColor: 'rgba(59,130,246,0.12)', borderWidth: 1, borderColor: 'rgba(59,130,246,0.35)' }}
>
@ -641,7 +277,6 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
<MaterialIcons name="tune" size={16} color="rgba(255,255,255,0.7)" />
<Text style={{ color: 'rgba(255,255,255,0.7)', fontSize: 12, marginLeft: 6, fontWeight: '600' }}>Core</Text>
</View>
{/* Font Size */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<MaterialIcons name="format-size" size={16} color="rgba(255,255,255,0.7)" />
@ -659,17 +294,16 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</TouchableOpacity>
</View>
</View>
{/* Background toggle */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<MaterialIcons name="layers" size={16} color="rgba(255,255,255,0.7)" />
<Text style={{ color: '#fff', fontWeight: '600', marginLeft: 8 }}>Show Background</Text>
</View>
<TouchableOpacity
style={{ width: isCompact ? 48 : 54, height: isCompact ? 28 : 30, backgroundColor: subtitleBackground ? '#22C55E' : 'rgba(255,255,255,0.25)', borderRadius: 15, justifyContent: 'center', alignItems: subtitleBackground ? 'flex-end' : 'flex-start', paddingHorizontal: 3 }}
style={{ width: isCompact ? 48 : 54, height: isCompact ? 28 : 30, backgroundColor: subtitleBackground ? 'white' : 'rgba(255,255,255,0.25)', borderRadius: 15, justifyContent: 'center', alignItems: subtitleBackground ? 'flex-end' : 'flex-start', paddingHorizontal: 3 }}
onPress={toggleSubtitleBackground}
>
<View style={{ width: 24, height: 24, backgroundColor: 'white', borderRadius: 12 }} />
<View style={{ width: 24, height: 24, backgroundColor: subtitleBackground ? 'black' : 'white', borderRadius: 12 }} />
</TouchableOpacity>
</View>
</View>
@ -680,8 +314,6 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
<MaterialIcons name="build" size={16} color="rgba(255,255,255,0.7)" />
<Text style={{ color: 'rgba(255,255,255,0.7)', fontSize: 12, marginLeft: 6, fontWeight: '600' }}>Advanced</Text>
</View>
{/* Text Color */}
<View style={{ marginTop: 8, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<MaterialIcons name="palette" size={16} color="rgba(255,255,255,0.7)" />
@ -693,28 +325,16 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
))}
</View>
</View>
{/* Align */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{ color: 'white', fontWeight: '600' }}>Align</Text>
<View style={{ flexDirection: 'row', gap: 8 }}>
{([
{ key: 'left', icon: 'format-align-left' },
{ key: 'center', icon: 'format-align-center' },
{ key: 'right', icon: 'format-align-right' },
] as const).map(a => (
<TouchableOpacity
key={a.key}
onPress={() => setSubtitleAlign(a.key)}
style={{ paddingHorizontal: isCompact ? 8 : 10, paddingVertical: isCompact ? 4 : 6, borderRadius: 8, backgroundColor: subtitleAlign === a.key ? 'rgba(255,255,255,0.18)' : 'rgba(255,255,255,0.08)', borderWidth: 1, borderColor: 'rgba(255,255,255,0.15)' }}
>
{([ { key: 'left', icon: 'format-align-left' }, { key: 'center', icon: 'format-align-center' }, { key: 'right', icon: 'format-align-right' } ] as const).map(a => (
<TouchableOpacity key={a.key} onPress={() => setSubtitleAlign(a.key)} style={{ paddingHorizontal: isCompact ? 8 : 10, paddingVertical: isCompact ? 4 : 6, borderRadius: 8, backgroundColor: subtitleAlign === a.key ? 'rgba(255,255,255,0.18)' : 'rgba(255,255,255,0.08)', borderWidth: 1, borderColor: 'rgba(255,255,255,0.15)' }}>
<MaterialIcons name={a.icon as any} size={18} color="#FFFFFF" />
</TouchableOpacity>
))}
</View>
</View>
{/* Bottom Offset */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{ color: 'white', fontWeight: '600' }}>Bottom Offset</Text>
<View style={{ flexDirection: 'row', gap: 8, alignItems: 'center' }}>
@ -729,8 +349,6 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</TouchableOpacity>
</View>
</View>
{/* Background Opacity */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{ color: 'white', fontWeight: '600' }}>Background Opacity</Text>
<View style={{ flexDirection: 'row', gap: 8, alignItems: 'center' }}>
@ -745,15 +363,12 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</TouchableOpacity>
</View>
</View>
{/* Shadow */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{ color: 'white', fontWeight: '600' }}>Text Shadow</Text>
<TouchableOpacity onPress={() => setSubtitleTextShadow(!subtitleTextShadow)} style={{ paddingHorizontal: 10, paddingVertical: 8, borderRadius: 10, backgroundColor: subtitleTextShadow ? 'rgba(255,255,255,0.18)' : 'rgba(255,255,255,0.08)', borderWidth: 1, borderColor: 'rgba(255,255,255,0.15)', alignItems: 'center' }}>
<Text style={{ color: '#fff', fontWeight: '700' }}>{subtitleTextShadow ? 'On' : 'Off'}</Text>
</TouchableOpacity>
</View>
{/* Outline color & width */}
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{ color: 'white' }}>Outline Color</Text>
<View style={{ flexDirection: 'row', gap: 8 }}>
@ -776,8 +391,6 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</TouchableOpacity>
</View>
</View>
{/* Spacing (two columns) */}
<View style={{ flexDirection: isCompact ? 'column' : 'row', justifyContent: 'space-between', gap: 12 }}>
<View style={{ flex: 1 }}>
<Text style={{ color: 'white', fontWeight: '600' }}>Letter Spacing</Text>
@ -808,8 +421,6 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</View>
</View>
</View>
{/* Timing Offset */}
<View style={{ marginTop: 4 }}>
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{ color: 'white', fontWeight: '600' }}>Timing Offset (s)</Text>
@ -827,22 +438,13 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</View>
<Text style={{ color: 'rgba(255,255,255,0.6)', fontSize: 11, marginTop: 6 }}>Nudge subtitles earlier (-) or later (+) to sync if needed.</Text>
</View>
{/* Reset to defaults */}
<View style={{ alignItems: 'flex-end', marginTop: 8 }}>
<TouchableOpacity
onPress={() => {
setSubtitleTextColor('#FFFFFF');
setSubtitleBgOpacity(0.7);
setSubtitleTextShadow(true);
setSubtitleOutline(true);
setSubtitleOutlineColor('#000000');
setSubtitleOutlineWidth(4);
setSubtitleAlign('center');
setSubtitleBottomOffset(10);
setSubtitleLetterSpacing(0);
setSubtitleLineHeightMultiplier(1.2);
setSubtitleOffsetSec(0);
setSubtitleTextColor('#FFFFFF'); setSubtitleBgOpacity(0.7); setSubtitleTextShadow(true);
setSubtitleOutline(true); setSubtitleOutlineColor('#000000'); setSubtitleOutlineWidth(4);
setSubtitleAlign('center'); setSubtitleBottomOffset(10); setSubtitleLetterSpacing(0);
setSubtitleLineHeightMultiplier(1.2); setSubtitleOffsetSec(0);
}}
style={{ paddingHorizontal: chipPadH, paddingVertical: chipPadV, borderRadius: 8, backgroundColor: 'rgba(255,255,255,0.1)', borderWidth: 1, borderColor: 'rgba(255,255,255,0.15)' }}
>
@ -852,18 +454,12 @@ export const SubtitleModals: React.FC<SubtitleModalsProps> = ({
</View>
</View>
)}
</View>
</ScrollView>
</Animated.View>
</View>
</View>
);
};
return (
<>
{renderSubtitleMenu()}
</>
);
};
export default SubtitleModals;