- Add React Query provider and client - Create reusable UI components (Loading, Error, Empty) - Implement custom hooks with fallback data - Integrate hooks into Resources and Community screens - Add pull-to-refresh support - Configure EAS Build profiles and environment variables
137 lines
3.6 KiB
TypeScript
137 lines
3.6 KiB
TypeScript
import React, { useCallback } from 'react';
|
|
import {
|
|
View,
|
|
ScrollView,
|
|
Text,
|
|
StyleSheet,
|
|
SafeAreaView,
|
|
TouchableOpacity,
|
|
RefreshControl,
|
|
} from 'react-native';
|
|
import { useResources } from '../../hooks/useResources';
|
|
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,
|
|
},
|
|
headerDescription: {
|
|
fontSize: 14,
|
|
color: '#666',
|
|
lineHeight: 20,
|
|
},
|
|
section: {
|
|
paddingHorizontal: 16,
|
|
marginTop: 16,
|
|
},
|
|
sectionTitle: {
|
|
fontSize: 16,
|
|
fontWeight: '600',
|
|
color: '#000',
|
|
marginBottom: 12,
|
|
},
|
|
resourceCard: {
|
|
backgroundColor: '#fff',
|
|
borderRadius: 12,
|
|
padding: 16,
|
|
marginBottom: 12,
|
|
borderLeftWidth: 4,
|
|
borderLeftColor: '#0066cc',
|
|
},
|
|
resourceTitle: {
|
|
fontSize: 15,
|
|
fontWeight: '600',
|
|
color: '#000',
|
|
marginBottom: 6,
|
|
},
|
|
resourceDescription: {
|
|
fontSize: 13,
|
|
color: '#666',
|
|
lineHeight: 18,
|
|
},
|
|
resourceLink: {
|
|
marginTop: 10,
|
|
paddingVertical: 8,
|
|
paddingHorizontal: 12,
|
|
backgroundColor: '#f0f0f0',
|
|
borderRadius: 6,
|
|
},
|
|
resourceLinkText: {
|
|
color: '#0066cc',
|
|
fontSize: 12,
|
|
fontWeight: '600',
|
|
textAlign: 'center',
|
|
},
|
|
});
|
|
|
|
export default function ResourcesScreen() {
|
|
const { data: resources, isLoading, isError, refetch } = useResources();
|
|
|
|
const onRefresh = useCallback(() => {
|
|
refetch();
|
|
}, [refetch]);
|
|
|
|
if (isLoading) {
|
|
return <LoadingState message="Loading resources..." />;
|
|
}
|
|
|
|
if (isError) {
|
|
return <ErrorState message="Failed to load resources" onRetry={refetch} />;
|
|
}
|
|
|
|
return (
|
|
<SafeAreaView style={styles.container}>
|
|
<ScrollView
|
|
showsVerticalScrollIndicator={false}
|
|
refreshControl={
|
|
<RefreshControl refreshing={isLoading} onRefresh={onRefresh} />
|
|
}
|
|
>
|
|
<View style={styles.header}>
|
|
<Text style={styles.headerTitle}>Resources</Text>
|
|
<Text style={styles.headerDescription}>
|
|
We know how scary and overwhelming it can be to receive a diagnosis. We've curated helpful resources to make your journey a little easier.
|
|
</Text>
|
|
</View>
|
|
|
|
{!resources || resources.length === 0 ? (
|
|
<EmptyState title="No Resources Found" message="Check back later for updates." />
|
|
) : (
|
|
resources.map((resource) => (
|
|
<View key={resource.id} style={styles.section}>
|
|
<View style={styles.resourceCard}>
|
|
<Text style={styles.resourceTitle}>{resource.title}</Text>
|
|
<Text style={styles.resourceDescription}>{resource.description}</Text>
|
|
<TouchableOpacity style={styles.resourceLink}>
|
|
<Text style={styles.resourceLinkText}>Learn More →</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
</View>
|
|
))
|
|
)}
|
|
|
|
<View style={[styles.section, { marginBottom: 40 }]}>
|
|
<Text style={styles.sectionTitle}>More Coming Soon</Text>
|
|
<Text style={{ fontSize: 14, color: '#666', lineHeight: 20 }}>
|
|
Be sure to check back often or sign up to receive updates as we're adding new resources all the time!
|
|
</Text>
|
|
</View>
|
|
</ScrollView>
|
|
</SafeAreaView>
|
|
);
|
|
}
|