// app/(workout)/template/[id]/social.tsx import React, { useState } from 'react'; import { View, ScrollView, ActivityIndicator, TouchableOpacity } from 'react-native'; import { Text } from '@/components/ui/text'; import { Badge } from '@/components/ui/badge'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { MessageSquare, Zap, Heart, Repeat, Bookmark } from 'lucide-react-native'; import { useTemplate } from './_templateContext'; import { cn } from '@/lib/utils'; // Mock social feed data const mockSocialFeed = [ { id: 'social1', userName: 'FitnessFanatic', userAvatar: 'https://randomuser.me/api/portraits/men/32.jpg', pubkey: 'npub1q8s7vw...', timestamp: new Date(Date.now() - 3600000 * 2), // 2 hours ago content: 'Just crushed this Full Body workout! New PR on bench press 🎉', metrics: { duration: 58, // in minutes volume: 4500, // total weight exercises: 5 }, likes: 12, comments: 3, zaps: 5, reposts: 2, bookmarked: false }, { id: 'social2', userName: 'StrengthJourney', userAvatar: 'https://randomuser.me/api/portraits/women/44.jpg', pubkey: 'npub1z92r3...', timestamp: new Date(Date.now() - 3600000 * 24), // 1 day ago content: 'Modified this workout with extra leg exercises. Feeling the burn!', metrics: { duration: 65, volume: 5200, exercises: "5+2" }, likes: 8, comments: 1, zaps: 3, reposts: 0, bookmarked: false }, { id: 'social3', userName: 'GymCoach', userAvatar: 'https://randomuser.me/api/portraits/men/62.jpg', pubkey: 'npub1xne8q...', timestamp: new Date(Date.now() - 3600000 * 48), // 2 days ago content: 'Great template for beginners! I recommend starting with lighter weights.', metrics: { duration: 45, volume: 3600, exercises: 5 }, likes: 24, comments: 7, zaps: 15, reposts: 6, bookmarked: true }, { id: 'social4', userName: 'WeightLifter', userAvatar: 'https://randomuser.me/api/portraits/women/28.jpg', pubkey: 'npub1r72df...', timestamp: new Date(Date.now() - 3600000 * 72), // 3 days ago content: 'Second time doing this workout. Improved my squat form significantly!', metrics: { duration: 52, volume: 4100, exercises: 5 }, likes: 15, comments: 2, zaps: 8, reposts: 1, bookmarked: false } ]; // Social Feed Item Component function SocialFeedItem({ item }: { item: typeof mockSocialFeed[0] }) { const [liked, setLiked] = useState(false); const [zapCount, setZapCount] = useState(item.zaps); const [bookmarked, setBookmarked] = useState(item.bookmarked); const [reposted, setReposted] = useState(false); const [commentCount, setCommentCount] = useState(item.comments); const formatDate = (date: Date) => { const now = new Date(); const diffInHours = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60)); if (diffInHours < 1) { return 'now'; } else if (diffInHours < 24) { return `${diffInHours}h`; } else { const diffInDays = Math.floor(diffInHours / 24); return `${diffInDays}d`; } }; return ( {/* User info and timestamp */} {item.userName.substring(0, 2)} {item.userName} {formatDate(item.timestamp)} @{item.pubkey.substring(0, 10)}... {/* Post content */} {item.content} {/* Workout metrics */} Duration {item.metrics.duration} min Volume {item.metrics.volume} lbs Exercises {item.metrics.exercises} {/* Twitter-like action buttons */} {/* Comment button */} setCommentCount(prev => prev + 1)} > {commentCount > 0 && ( {commentCount} )} {/* Repost button */} setReposted(!reposted)} > {(reposted || item.reposts > 0) && ( {reposted ? item.reposts + 1 : item.reposts} )} {/* Like button */} setLiked(!liked)} > {(liked || item.likes > 0) && ( {liked ? item.likes + 1 : item.likes} )} {/* Zap button */} setZapCount(prev => prev + 1)} > {zapCount > 0 && ( {zapCount} )} {/* Bookmark button */} setBookmarked(!bookmarked)} > ); } export default function SocialTab() { const template = useTemplate(); const [isLoading, setIsLoading] = useState(false); return ( Recent Activity Nostr {isLoading ? ( Loading activity... ) : mockSocialFeed.length > 0 ? ( {mockSocialFeed.map((item) => ( ))} ) : ( No social activity found This workout hasn't been shared on Nostr yet )} ); }