import React, { useCallback } from 'react'; import { View, ScrollView, Text, StyleSheet, SafeAreaView, TouchableOpacity, RefreshControl, } from 'react-native'; import { useCommunity } from '../../hooks/useCommunity'; import { LoadingState } from '../../components/ui/LoadingState'; import { ErrorState } from '../../components/ui/ErrorState'; import { EmptyState } from '../../components/ui/EmptyState'; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f5f5f5', }, header: { backgroundColor: '#fff', padding: 16, borderBottomWidth: 1, borderBottomColor: '#e0e0e0', }, headerTitle: { fontSize: 24, fontWeight: '700', color: '#000', marginBottom: 8, }, section: { paddingHorizontal: 16, marginTop: 16, }, communityCard: { backgroundColor: '#fff', borderRadius: 12, padding: 16, marginBottom: 12, }, communityCardHeader: { flexDirection: 'row', alignItems: 'center', marginBottom: 12, }, communityIcon: { width: 40, height: 40, borderRadius: 20, backgroundColor: '#f0f0f0', justifyContent: 'center', alignItems: 'center', marginRight: 12, }, communityTitle: { fontSize: 16, fontWeight: '600', color: '#000', }, communityDescription: { fontSize: 13, color: '#666', lineHeight: 20, marginBottom: 12, }, memberCount: { fontSize: 12, color: '#999', marginBottom: 10, }, joinButton: { backgroundColor: '#0066cc', paddingVertical: 10, paddingHorizontal: 16, borderRadius: 6, alignItems: 'center', }, joinButtonText: { color: '#fff', fontSize: 13, fontWeight: '600', }, sectionTitle: { fontSize: 18, fontWeight: '700', color: '#000', marginBottom: 12, }, postCard: { backgroundColor: '#fff', borderRadius: 12, padding: 16, marginBottom: 12, }, postHeader: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 8, }, postAuthor: { fontWeight: '600', fontSize: 14, }, postTime: { color: '#666', fontSize: 12, }, postContent: { fontSize: 14, lineHeight: 20, color: '#333', marginBottom: 12, }, postFooter: { flexDirection: 'row', borderTopWidth: 1, borderTopColor: '#f0f0f0', paddingTop: 12, }, postStat: { marginRight: 16, color: '#666', fontSize: 12, }, }); export default function CommunityScreen() { const { data: posts, isLoading, isError, refetch } = useCommunity(); const onRefresh = useCallback(() => { refetch(); }, [refetch]); const communities = [ { title: 'Support Group', description: 'Join our growing community of folks navigating chronic illness and cancer. Connect, share, and find strength together.', members: '2,341 members', icon: '👥', }, { title: 'The Living Room', description: 'Exclusive support circle for members. A safe space to share your journey, connect with others, and find support.', members: '856 members', icon: '🛋️', }, { title: 'The Journal', description: 'Read inspiring stories from our community members as they navigate their journeys. Share your own story.', members: '1,203 stories', icon: '📖', }, { title: 'Podcast Community', description: 'Discuss episodes of our podcast and connect with listeners who share your experiences.', members: '432 members', icon: '🎙️', }, ]; if (isLoading) { return ; } if (isError) { return ; } return ( } > Community Join Our Communities {communities.map((community, index) => ( {community.icon} {community.title} {community.description} {community.members} Join Community ))} Recent Activity {!posts || posts.length === 0 ? ( ) : ( posts.map((post) => ( {post.author} {post.timestamp} {post.content} {post.likes} Likes {post.comments} Comments )) )} Community Guidelines • Be respectful and supportive{'\n'} • Share your authentic story{'\n'} • Respect others' privacy{'\n'} • No medical advice{'\n'} • Check in, not out ); }