/** * Chromecast Device Info Sheet * Shows device details, volume control, and disconnect option */ import { Ionicons } from "@expo/vector-icons"; import React, { useState } from "react"; import { Modal, Pressable, View } from "react-native"; import { Slider } from "react-native-awesome-slider"; import type { Device } from "react-native-google-cast"; import { useSharedValue } from "react-native-reanimated"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Text } from "@/components/common/Text"; interface ChromecastDeviceSheetProps { visible: boolean; onClose: () => void; device: Device | null; onDisconnect: () => Promise; volume?: number; onVolumeChange?: (volume: number) => Promise; } export const ChromecastDeviceSheet: React.FC = ({ visible, onClose, device, onDisconnect, volume = 0.5, onVolumeChange, }) => { const insets = useSafeAreaInsets(); const [isDisconnecting, setIsDisconnecting] = useState(false); const volumeValue = useSharedValue(volume * 100); const handleDisconnect = async () => { setIsDisconnecting(true); try { await onDisconnect(); onClose(); } catch (error) { console.error("Failed to disconnect:", error); } finally { setIsDisconnecting(false); } }; const handleVolumeComplete = async (value: number) => { if (onVolumeChange) { await onVolumeChange(value / 100); } }; return ( e.stopPropagation()} > {/* Header */} Chromecast {/* Device info */} Device Name {device?.friendlyName || device?.deviceId || "Unknown Device"} {device?.deviceId && ( Device ID {device.deviceId} )} {/* Volume control */} Volume {Math.round((volume || 0) * 100)}% { volumeValue.value = value; }} onSlidingComplete={handleVolumeComplete} /> {/* Disconnect button */} {isDisconnecting ? "Disconnecting..." : "Stop Casting"} ); };