import React, { useState, useEffect, useCallback } from 'react'; import { View, Text, ScrollView, TouchableOpacity, FlatList, } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { BottomTabNavigationProp } from '@react-navigation/bottom-tabs'; import { getStyles } from './homeScreen.styles'; import { SearchBar, ProviderCard, CategoryChip } from '@components'; import { useAppTheme } from '@theme'; import { deliveryService } from '../../../services/deliveryService'; import { Provider } from '../../../interfaces'; import { AppStackParamList } from '../../../navigation/appStack'; type NavProp = BottomTabNavigationProp; const CATEGORIES = [ { key: 'all', icon: '🏠', label: 'All' }, { key: 'Food', icon: '🍔', label: 'Food' }, { key: 'Groceries', icon: '🛒', label: 'Groceries' }, { key: 'Pharmacy', icon: '💊', label: 'Pharmacy' }, { key: 'More', icon: '📦', label: 'More' }, ]; export const HomeScreen: React.FC = () => { const { colors } = useAppTheme(); const styles = getStyles(colors); const navigation = useNavigation(); const [providers, setProviders] = useState([]); const [selectedCategory, setSelectedCategory] = useState('all'); useEffect(() => { deliveryService.getProviders().then(setProviders); }, []); const filteredProviders = selectedCategory === 'all' ? providers : providers.filter((p) => p.tag === selectedCategory); const handleSearchFocus = useCallback(() => { navigation.navigate('SearchScreen'); }, [navigation]); return ( Deliver to Koramangala 4th Block, B... {}} placeholder="Search providers or items..." onFocus={handleSearchFocus} /> 50% OFF on your first order item.key} showsHorizontalScrollIndicator={false} contentContainerStyle={styles.chipRow} renderItem={({ item }) => ( setSelectedCategory(item.key)} /> )} /> {selectedCategory === 'all' ? 'Popular Providers' : selectedCategory} {filteredProviders.map((provider) => ( navigation.navigate('SearchScreen')} /> ))} ); };