mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-05-22 10:07:34 +08:00
feat(ui): update Pressable ripple effect for device type in HomeScreen, StyledButton, and VideoCard components
This commit is contained in:
@@ -167,7 +167,7 @@ export default function HomeScreen() {
|
|||||||
<View style={dynamicStyles.headerContainer}>
|
<View style={dynamicStyles.headerContainer}>
|
||||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||||
<ThemedText style={dynamicStyles.headerTitle}>首页</ThemedText>
|
<ThemedText style={dynamicStyles.headerTitle}>首页</ThemedText>
|
||||||
<Pressable android_ripple={Platform.isTV ? {color:'transparent'} : {color: Colors.dark.link}} style={{ marginLeft: 20 }} onPress={() => router.push("/live")}>
|
<Pressable android_ripple={Platform.isTV ? {color:'transparent'} : ( deviceType==='tv' ? {color: Colors.dark.link}: {color:'transparent'})} style={{ marginLeft: 20 }} onPress={() => router.push("/live")}>
|
||||||
{({ focused }) => (
|
{({ focused }) => (
|
||||||
<ThemedText style={[dynamicStyles.headerTitle, { color: focused ? "white" : "grey" }]}>直播</ThemedText>
|
<ThemedText style={[dynamicStyles.headerTitle, { color: focused ? "white" : "grey" }]}>直播</ThemedText>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Animated, Pressable, StyleSheet, StyleProp, ViewStyle, PressableProps,
|
|||||||
import { ThemedText } from "./ThemedText";
|
import { ThemedText } from "./ThemedText";
|
||||||
import { Colors } from "@/constants/Colors";
|
import { Colors } from "@/constants/Colors";
|
||||||
import { useButtonAnimation } from "@/hooks/useAnimation";
|
import { useButtonAnimation } from "@/hooks/useAnimation";
|
||||||
|
import { useResponsiveLayout } from "@/hooks/useResponsiveLayout";
|
||||||
|
|
||||||
interface StyledButtonProps extends PressableProps {
|
interface StyledButtonProps extends PressableProps {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
@@ -19,6 +20,7 @@ export const StyledButton = forwardRef<View, StyledButtonProps>(
|
|||||||
const colors = Colors[colorScheme];
|
const colors = Colors[colorScheme];
|
||||||
const [isFocused, setIsFocused] = React.useState(false);
|
const [isFocused, setIsFocused] = React.useState(false);
|
||||||
const animationStyle = useButtonAnimation(isFocused);
|
const animationStyle = useButtonAnimation(isFocused);
|
||||||
|
const deviceType = useResponsiveLayout().deviceType;
|
||||||
|
|
||||||
const variantStyles = {
|
const variantStyles = {
|
||||||
default: StyleSheet.create({
|
default: StyleSheet.create({
|
||||||
@@ -108,7 +110,7 @@ export const StyledButton = forwardRef<View, StyledButtonProps>(
|
|||||||
return (
|
return (
|
||||||
<Animated.View style={[animationStyle, style]}>
|
<Animated.View style={[animationStyle, style]}>
|
||||||
<Pressable
|
<Pressable
|
||||||
android_ripple={Platform.isTV ? {color:'transparent'} : { color: Colors.dark.link, borderless: false }}
|
android_ripple={Platform.isTV ? { color: 'transparent' } : (deviceType === 'tv' ? { color: Colors.dark.link } : { color: 'transparent' })}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
onFocus={() => setIsFocused(true)}
|
onFocus={() => setIsFocused(true)}
|
||||||
onBlur={() => setIsFocused(false)}
|
onBlur={() => setIsFocused(false)}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { API } from "@/services/api";
|
|||||||
import { ThemedText } from "@/components/ThemedText";
|
import { ThemedText } from "@/components/ThemedText";
|
||||||
import { Colors } from "@/constants/Colors";
|
import { Colors } from "@/constants/Colors";
|
||||||
import Logger from '@/utils/Logger';
|
import Logger from '@/utils/Logger';
|
||||||
|
import { useResponsiveLayout } from "@/hooks/useResponsiveLayout";
|
||||||
|
|
||||||
const logger = Logger.withTag('VideoCardTV');
|
const logger = Logger.withTag('VideoCardTV');
|
||||||
|
|
||||||
@@ -54,6 +55,8 @@ const VideoCard = forwardRef<View, VideoCardProps>(
|
|||||||
|
|
||||||
const scale = useRef(new Animated.Value(1)).current;
|
const scale = useRef(new Animated.Value(1)).current;
|
||||||
|
|
||||||
|
const deviceType = useResponsiveLayout().deviceType;
|
||||||
|
|
||||||
const animatedStyle = {
|
const animatedStyle = {
|
||||||
transform: [{ scale }],
|
transform: [{ scale }],
|
||||||
};
|
};
|
||||||
@@ -148,11 +151,7 @@ const VideoCard = forwardRef<View, VideoCardProps>(
|
|||||||
return (
|
return (
|
||||||
<Animated.View style={[styles.wrapper, animatedStyle, { opacity: fadeAnim }]}>
|
<Animated.View style={[styles.wrapper, animatedStyle, { opacity: fadeAnim }]}>
|
||||||
<Pressable
|
<Pressable
|
||||||
android_ripple={Platform.isTV ? {color:'transparent'} : {
|
android_ripple={Platform.isTV ? { color: 'transparent' } : (deviceType === 'tv' ? { color: Colors.dark.link } : { color: 'transparent' })}
|
||||||
color: Colors.dark.link,
|
|
||||||
borderless: false,
|
|
||||||
foreground: true,
|
|
||||||
}}
|
|
||||||
onPress={handlePress}
|
onPress={handlePress}
|
||||||
onLongPress={handleLongPress}
|
onLongPress={handleLongPress}
|
||||||
onFocus={handleFocus}
|
onFocus={handleFocus}
|
||||||
@@ -229,9 +228,14 @@ const styles = StyleSheet.create({
|
|||||||
marginHorizontal: 8,
|
marginHorizontal: 8,
|
||||||
},
|
},
|
||||||
pressable: {
|
pressable: {
|
||||||
|
width: CARD_WIDTH + 20,
|
||||||
|
height: CARD_HEIGHT + 60,
|
||||||
|
justifyContent: 'center',
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
overflow: "visible",
|
||||||
},
|
},
|
||||||
card: {
|
card: {
|
||||||
|
marginTop: 10,
|
||||||
width: CARD_WIDTH,
|
width: CARD_WIDTH,
|
||||||
height: CARD_HEIGHT,
|
height: CARD_HEIGHT,
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user