import { Ionicons, MaterialIcons } from "@expo/vector-icons"; import type { BaseItemDto, MediaSourceInfo, } from "@jellyfin/sdk/lib/generated-client"; import { useRouter } from "expo-router"; import { type FC, useCallback, useState } from "react"; import { Platform, TouchableOpacity, useWindowDimensions, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useHaptic } from "@/hooks/useHaptic"; import { useOrientation } from "@/hooks/useOrientation"; import { OrientationLock } from "@/packages/expo-screen-orientation"; import { useSettings, VideoPlayerIOS } from "@/utils/atoms/settings"; import { ICON_SIZES } from "./constants"; import DropdownView from "./dropdown/DropdownView"; import { type AspectRatio } from "./VideoScalingModeSelector"; import { ZoomToggle } from "./ZoomToggle"; interface HeaderControlsProps { item: BaseItemDto; showControls: boolean; offline: boolean; mediaSource?: MediaSourceInfo | null; startPictureInPicture?: () => Promise; switchOnEpisodeMode: () => void; goToPreviousItem: () => void; goToNextItem: (options: { isAutoPlay?: boolean }) => void; previousItem?: BaseItemDto | null; nextItem?: BaseItemDto | null; aspectRatio?: AspectRatio; setVideoAspectRatio?: (aspectRatio: string | null) => Promise; isZoomedToFill?: boolean; onZoomToggle?: () => void; } export const HeaderControls: FC = ({ item, showControls, offline, mediaSource, startPictureInPicture, switchOnEpisodeMode, goToPreviousItem, goToNextItem, previousItem, nextItem, aspectRatio: _aspectRatio = "default", setVideoAspectRatio: _setVideoAspectRatio, isZoomedToFill = false, onZoomToggle, }) => { const { settings } = useSettings(); const router = useRouter(); const insets = useSafeAreaInsets(); const { width: _screenWidth } = useWindowDimensions(); const lightHapticFeedback = useHaptic("light"); const { orientation, lockOrientation } = useOrientation(); const [isTogglingOrientation, setIsTogglingOrientation] = useState(false); const onClose = async () => { lightHapticFeedback(); router.back(); }; const toggleOrientation = useCallback(async () => { if (isTogglingOrientation) return; setIsTogglingOrientation(true); lightHapticFeedback(); try { const isPortrait = orientation === OrientationLock.PORTRAIT_UP || orientation === OrientationLock.PORTRAIT_DOWN; await lockOrientation( isPortrait ? OrientationLock.LANDSCAPE : OrientationLock.PORTRAIT_UP, ); } finally { setIsTogglingOrientation(false); } }, [ orientation, lockOrientation, isTogglingOrientation, lightHapticFeedback, ]); return ( {!Platform.isTV && (!offline || !mediaSource?.TranscodingUrl) && ( )} {!Platform.isTV && ( )} {!Platform.isTV && startPictureInPicture && settings?.videoPlayerIOS !== VideoPlayerIOS.VLC && ( )} {item?.Type === "Episode" && ( )} {previousItem && ( )} {nextItem && ( goToNextItem({ isAutoPlay: false })} className='aspect-square flex flex-col rounded-xl items-center justify-center p-2' > )} {/* { if (setVideoAspectRatio) { const aspectRatioString = newRatio === "default" ? null : newRatio; await setVideoAspectRatio(aspectRatioString); } }} disabled={!setVideoAspectRatio} />*/} {})} disabled={!onZoomToggle} /> ); };