diff --git a/app/index.tsx b/app/index.tsx index aa3489e..7e8193e 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useCallback, useRef, useState } from "react"; -import { View, StyleSheet, ActivityIndicator, FlatList, Pressable, Animated, StatusBar } from "react-native"; +import { View, StyleSheet, ActivityIndicator, FlatList, Pressable, Animated, StatusBar, Platform } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { ThemedView } from "@/components/ThemedView"; import { ThemedText } from "@/components/ThemedText"; @@ -15,6 +15,7 @@ import { useResponsiveLayout } from "@/hooks/useResponsiveLayout"; import { getCommonResponsiveStyles } from "@/utils/ResponsiveStyles"; import ResponsiveNavigation from "@/components/navigation/ResponsiveNavigation"; import { useApiConfig, getApiConfigErrorMessage } from "@/hooks/useApiConfig"; +import { Colors } from "@/constants/Colors"; const LOAD_MORE_THRESHOLD = 200; @@ -166,7 +167,7 @@ export default function HomeScreen() { 首页 - router.push("/live")}> + router.push("/live")}> {({ focused }) => ( 直播 )} diff --git a/components/StyledButton.tsx b/components/StyledButton.tsx index 7d5a21d..0bdb442 100644 --- a/components/StyledButton.tsx +++ b/components/StyledButton.tsx @@ -1,8 +1,9 @@ import React, { forwardRef } from "react"; -import { Animated, Pressable, StyleSheet, StyleProp, ViewStyle, PressableProps, TextStyle, View } from "react-native"; +import { Animated, Pressable, StyleSheet, StyleProp, ViewStyle, PressableProps, TextStyle, View, Platform } from "react-native"; import { ThemedText } from "./ThemedText"; import { Colors } from "@/constants/Colors"; import { useButtonAnimation } from "@/hooks/useAnimation"; +import { useResponsiveLayout } from "@/hooks/useResponsiveLayout"; interface StyledButtonProps extends PressableProps { children?: React.ReactNode; @@ -19,6 +20,7 @@ export const StyledButton = forwardRef( const colors = Colors[colorScheme]; const [isFocused, setIsFocused] = React.useState(false); const animationStyle = useButtonAnimation(isFocused); + const deviceType = useResponsiveLayout().deviceType; const variantStyles = { default: StyleSheet.create({ @@ -108,6 +110,7 @@ export const StyledButton = forwardRef( return ( setIsFocused(true)} onBlur={() => setIsFocused(false)} diff --git a/components/VideoCard.tv.tsx b/components/VideoCard.tv.tsx index 426c779..423b097 100644 --- a/components/VideoCard.tv.tsx +++ b/components/VideoCard.tv.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useCallback, useRef, forwardRef } from "react"; -import { View, Text, Image, StyleSheet, TouchableOpacity, Alert, Animated } from "react-native"; +import { View, Text, Image, StyleSheet, Pressable, TouchableOpacity, Alert, Animated, Platform } from "react-native"; import { useRouter } from "expo-router"; import { Star, Play } from "lucide-react-native"; import { PlayRecordManager } from "@/services/storage"; @@ -7,6 +7,7 @@ import { API } from "@/services/api"; import { ThemedText } from "@/components/ThemedText"; import { Colors } from "@/constants/Colors"; import Logger from '@/utils/Logger'; +import { useResponsiveLayout } from "@/hooks/useResponsiveLayout"; const logger = Logger.withTag('VideoCardTV'); @@ -54,6 +55,8 @@ const VideoCard = forwardRef( const scale = useRef(new Animated.Value(1)).current; + const deviceType = useResponsiveLayout().deviceType; + const animatedStyle = { transform: [{ scale }], }; @@ -147,63 +150,126 @@ const VideoCard = forwardRef( return ( - - - - {isFocused && ( - - {isContinueWatching && ( - - - 继续观看 - - )} - - )} + {Platform.isTV || deviceType !== 'tv' ? ( + + + + {isFocused && ( + + {isContinueWatching && ( + + + 继续观看 + + )} + + )} - {/* 进度条 */} - {isContinueWatching && ( - - - - )} + {/* 进度条 */} + {isContinueWatching && ( + + + + )} + + {rate && ( + + + {rate} + + )} + {year && ( + + {year} + + )} + {sourceName && ( + + {sourceName} + + )} + + + {title} + {isContinueWatching && ( + + + 第{episodeIndex}集 已观看 {Math.round((progress || 0) * 100)}% + + + )} + + + ) : ( + + + + {isFocused && ( + + {isContinueWatching && ( + + + 继续观看 + + )} + + )} + + {/* 进度条 */} + {isContinueWatching && ( + + + + )} + + {rate && ( + + + {rate} + + )} + {year && ( + + {year} + + )} + {sourceName && ( + + {sourceName} + + )} + + + {title} + {isContinueWatching && ( + + + 第{episodeIndex}集 已观看 {Math.round((progress || 0) * 100)}% + + + )} + + + + )} - {rate && ( - - - {rate} - - )} - {year && ( - - {year} - - )} - {sourceName && ( - - {sourceName} - - )} - - - {title} - {isContinueWatching && ( - - - 第{episodeIndex}集 已观看 {Math.round((progress || 0) * 100)}% - - - )} - - ); } @@ -221,9 +287,14 @@ const styles = StyleSheet.create({ marginHorizontal: 8, }, pressable: { + width: CARD_WIDTH + 20, + height: CARD_HEIGHT + 60, + justifyContent: 'center', alignItems: "center", + overflow: "visible", }, card: { + marginTop: 10, width: CARD_WIDTH, height: CARD_HEIGHT, borderRadius: 8,