Files
streamyfin/components/tv/TVThemeMusicIndicator.tsx
Lance Chant 03f17a758f chore: updated usage of tv scaling, alert text fix
Sweep across a few pages to ensure they use the scaling factors now
Added a plugin to fix the alert text on android tv

Signed-off-by: Lance Chant <13349722+lancechant@users.noreply.github.com>
2026-05-22 15:00:13 +02:00

80 lines
2.0 KiB
TypeScript

import { Ionicons } from "@expo/vector-icons";
import React, { useRef, useState } from "react";
import { Animated, Easing, Pressable, View } from "react-native";
import { AnimatedEqualizer } from "@/components/music/AnimatedEqualizer";
import { scaleSize } from "@/utils/scaleSize";
interface TVThemeMusicIndicatorProps {
isPlaying: boolean;
isMuted: boolean;
hasThemeMusic: boolean;
onToggleMute: () => void;
disabled?: boolean;
}
export const TVThemeMusicIndicator: React.FC<TVThemeMusicIndicatorProps> = ({
isPlaying,
isMuted,
hasThemeMusic,
onToggleMute,
disabled = false,
}) => {
const [focused, setFocused] = useState(false);
const scale = useRef(new Animated.Value(1)).current;
const animateTo = (v: number) =>
Animated.timing(scale, {
toValue: v,
duration: 150,
easing: Easing.out(Easing.quad),
useNativeDriver: true,
}).start();
if (!hasThemeMusic || !isPlaying) return null;
return (
<Pressable
onPress={onToggleMute}
onFocus={() => {
setFocused(true);
animateTo(1.15);
}}
onBlur={() => {
setFocused(false);
animateTo(1);
}}
disabled={disabled}
focusable={!disabled}
>
<Animated.View
style={{
transform: [{ scale }],
backgroundColor: focused
? "rgba(255,255,255,0.25)"
: "rgba(255,255,255,0.1)",
borderRadius: scaleSize(12),
padding: scaleSize(12),
alignItems: "center",
justifyContent: "center",
width: scaleSize(48),
height: scaleSize(48),
}}
>
{isMuted ? (
<Ionicons name='volume-mute' size={scaleSize(22)} color='#FFFFFF' />
) : (
<View style={{ marginRight: 0 }}>
<AnimatedEqualizer
color='#FFFFFF'
barWidth={3}
barCount={3}
height={18}
gap={2}
/>
</View>
)}
</Animated.View>
</Pressable>
);
};