import React from 'react'; import { FlatList, ScrollView, StyleSheet, Text, View, Pressable } from 'react-native'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import { Icon } from '../../../components/Icon'; import { Input, ScreenShell } from '../../../components'; import { ServicesStackParamList } from '../../../navigation/types'; import { useTheme, fontFamily } from '../../../theme'; import { AwarenessCard } from '../components/AwarenessCard'; import { useAwareness } from '../hooks/useAwareness'; import { AwarenessCategory } from '../types'; type Props = NativeStackScreenProps; const CATEGORIES: (AwarenessCategory | 'All')[] = ['All', 'RBI', 'NPCI', 'Fraud Alert', 'Best Practices']; export default function AwarenessListScreen({ navigation }: Props) { const theme = useTheme(); const { articles, filter, setFilter, bookmarks, toggleBookmark, urgentArticles } = useAwareness(); const handleSearch = (query: string) => { setFilter({ ...filter, searchQuery: query }); }; const handleCategoryPress = (category: AwarenessCategory | 'All') => { setFilter({ ...filter, category }); }; return ( } /> {CATEGORIES.map((cat) => { const isActive = filter.category === cat; return ( handleCategoryPress(cat)} style={[ styles.filterChip, { backgroundColor: isActive ? theme.colors.primary : theme.colors.surfaceMuted, borderColor: isActive ? theme.colors.primary : theme.colors.cardBorder, }, ]} > {cat} ); })} item.id} renderItem={({ item }) => ( toggleBookmark(item.id)} onPress={() => navigation.navigate('AwarenessDetail', { articleId: item.id })} /> )} ListHeaderComponent={ <> {urgentArticles.length > 0 && filter.category === 'All' && filter.searchQuery === '' && ( Critical Security Alerts {urgentArticles.map((article) => ( navigation.navigate('AwarenessDetail', { articleId: article.id })} style={[styles.urgentCard, { backgroundColor: theme.tint(theme.colors.error, 0.03), borderColor: theme.tint(theme.colors.error, 0.13) }]} > {article.title} {article.description} ))} )} {filter.category === 'All' ? 'Latest Awareness Articles' : `${filter.category} Guidelines`} } contentContainerStyle={styles.listContent} ListEmptyComponent={ No results found Try adjusting your search or filters to find what you're looking for. } scrollEnabled={false} // Since it's inside ScreenShell's ScrollView /> ); } const styles = StyleSheet.create({ searchContainer: { paddingHorizontal: 16, marginBottom: 16, }, filterWrapper: { marginBottom: 20, }, filterContainer: { paddingHorizontal: 16, gap: 10, }, filterChip: { paddingHorizontal: 16, paddingVertical: 8, borderRadius: 20, borderWidth: 1, }, filterText: { fontSize: 13, fontFamily: fontFamily.bold, }, listContent: { paddingHorizontal: 16, paddingBottom: 100, }, urgentSection: { marginBottom: 24, gap: 12, }, sectionHeader: { flexDirection: 'row', alignItems: 'center', gap: 8, marginBottom: 12, }, sectionTitle: { fontSize: 16, fontFamily: fontFamily.bold, letterSpacing: -0.3, }, urgentCarousel: { gap: 12, }, urgentCard: { width: 260, padding: 16, borderRadius: 16, borderWidth: 1, gap: 8, }, urgentIcon: { width: 36, height: 36, borderRadius: 10, alignItems: 'center', justifyContent: 'center', }, urgentCardTitle: { fontSize: 15, fontFamily: fontFamily.bold, }, urgentCardDesc: { fontSize: 12, }, emptyContainer: { alignItems: 'center', justifyContent: 'center', paddingVertical: 60, gap: 12, }, emptyTitle: { fontSize: 18, fontFamily: fontFamily.bold, }, emptySubtitle: { fontSize: 14, textAlign: 'center', paddingHorizontal: 40, }, });