import React, { memo, useCallback } from 'react' import { View, StyleSheet, Text, Pressable } from 'react-native' import { Ionicons } from '@expo/vector-icons' export interface VideoSocialButtonProps { templateId: string liked?: boolean favorited?: boolean likeCount?: number favoriteCount?: number loading?: boolean onLike?: () => void onUnlike?: () => void onFavorite?: () => void onUnfavorite?: () => void testID?: string } const VideoSocialButtonComponent: React.FC = ({ templateId, liked = false, favorited = false, likeCount, favoriteCount, loading = false, onLike, onUnlike, onFavorite, onUnfavorite, testID, }) => { // 处理点赞按钮点击 const handleLikePress = useCallback(() => { if (!loading) { if (liked) { onUnlike?.() } else { onLike?.() } } }, [loading, liked, onLike, onUnlike]) // 处理收藏按钮点击 const handleFavoritePress = useCallback(() => { if (!loading) { if (favorited) { onUnfavorite?.() } else { onFavorite?.() } } }, [loading, favorited, onFavorite, onUnfavorite]) // 格式化数量显示 const formatCount = (count?: number): string => { if (count === undefined || count === null) return '0' if (count >= 10000) { return `${(count / 10000).toFixed(1)}w` } if (count >= 1000) { return `${(count / 1000).toFixed(1)}k` } return count.toString() } return ( {/* 点赞按钮 */} {formatCount(likeCount)} {/* 收藏按钮 */} {formatCount(favoriteCount)} ) } export const VideoSocialButton = memo(VideoSocialButtonComponent) const styles = StyleSheet.create({ container: { position: 'absolute', right: 12, bottom: 180, flexDirection: 'column', alignItems: 'center', gap: 20, }, buttonWrapper: { alignItems: 'center', gap: 4, }, iconContainer: { width: 52, height: 52, borderRadius: 26, backgroundColor: 'rgba(0, 0, 0, 0.3)', justifyContent: 'center', alignItems: 'center', }, iconContainerActive: { backgroundColor: 'rgba(255, 255, 255, 0.15)', }, count: { color: '#FFFFFF', fontSize: 12, fontWeight: '600', textShadowColor: 'rgba(0, 0, 0, 0.5)', textShadowOffset: { width: 0, height: 1 }, textShadowRadius: 2, }, })