import React, { useState } from 'react'; import { View, Text, Image, TextInput, TouchableOpacity, SafeAreaView, StatusBar, ScrollView, Alert } from 'react-native'; import { Feather, FontAwesome, Ionicons } from '@expo/vector-icons'; import { router } from 'expo-router'; import * as ImagePicker from 'expo-image-picker'; // Sample recipe data const recipeData = [ { id: 1, title: "Pad Kra Pao Moo Sab with Eggs", image: "/placeholder.svg?height=400&width=400&query=thai basil stir fry with egg and rice", color: "#ffd60a" }, { id: 2, title: "Chicken Curry", image: "/placeholder.svg?height=400&width=400&query=chicken curry with rice", color: "#ffd60a" }, { id: 3, title: "Beef Steak", image: "/placeholder.svg?height=400&width=400&query=beef steak with vegetables", color: "#bb0718" }, { id: 4, title: "Vegetable Pasta", image: "/placeholder.svg?height=400&width=400&query=vegetable pasta", color: "#ffd60a" }, { id: 5, title: "Salmon Sushi", image: "/placeholder.svg?height=400&width=400&query=salmon sushi", color: "#ffd60a" } ]; export default function HomeScreen() { const [searchQuery, setSearchQuery] = useState(''); const [filteredRecipes, setFilteredRecipes] = useState(recipeData); // Handle search const handleSearch = (text: string): void => { setSearchQuery(text); if (text) { const filtered = recipeData.filter((recipe: Recipe) => recipe.title.toLowerCase().includes(text.toLowerCase()) ); setFilteredRecipes(filtered); } else { setFilteredRecipes(recipeData); } }; // Handle camera const takePhoto = async () => { const { status } = await ImagePicker.requestCameraPermissionsAsync(); if (status !== 'granted') { Alert.alert('Permission needed', 'Please grant camera permissions to use this feature.'); return; } const result = await ImagePicker.launchCameraAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images, allowsEditing: true, aspect: [1, 1], quality: 1, }); if (!result.canceled) { // Navigate to recipe detail with the captured image router.push({ pathname: '/recipe-detail', params: { title: 'My New Recipe', image: result.assets[0].uri } }); } }; // Handle gallery const pickImage = async () => { const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync(); if (status !== 'granted') { Alert.alert('Permission needed', 'Please grant media library permissions to use this feature.'); return; } const result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Images, allowsEditing: true, aspect: [1, 1], quality: 1, }); if (!result.canceled) { // Navigate to recipe detail with the selected image router.push({ pathname: '/recipe-detail', params: { title: 'My New Recipe', image: result.assets[0].uri } }); } }; // Navigate to recipe detail interface Recipe { id: number; title: string; image: string; color: string; } const goToRecipeDetail = (recipe: Recipe): void => { router.push({ pathname: '/recipe-detail', params: { title: recipe.title, image: recipe.image } }); }; return ( {/* Header - Fixed at top */} Hi! Mr. Chef {/* Scrollable Content */} {/* Center Image */} {/* Highlights Section */} Highlights {filteredRecipes.slice(0, 3).map((recipe) => ( goToRecipeDetail(recipe)} > ))} {filteredRecipes.slice(3, 5).map((recipe) => ( goToRecipeDetail(recipe)} > ))} {/* Show your dishes */} Show your dishes From Camera Straight from Camera From Gallery Straight from Gallery {/* Extra space at bottom */} ); }