import { IconSymbol } from "@/components/ui/IconSymbol"; import { Feather, FontAwesome, Ionicons } from "@expo/vector-icons"; import * as ImagePicker from "expo-image-picker"; import { router } from "expo-router"; import React, { useState } from "react"; import { Alert, Image, SafeAreaView, ScrollView, StatusBar, Text, TextInput, TouchableOpacity, View, } from "react-native"; // Sample recipe data const foodHighlights = [ { id: 1, name: "Pad Kra Pao Moo Sab with Eggs", image: require("@/assets/images/food/padkrapao.jpg"), description: "Thai stir-fry with ground pork and holy basil", time: "30 Mins", calories: "520 kcal", }, { id: 2, name: "Jjajangmyeon", image: require("@/assets/images/food/jjajangmyeon.jpg"), description: "Korean black bean noodles", time: "45 Mins", calories: "650 kcal", }, { id: 3, name: "Ramen", image: require("@/assets/images/food/ramen.jpg"), description: "Japanese noodle soup", time: "60 Mins", calories: "480 kcal", }, { id: 4, name: "Beef Wellington", image: require("@/assets/images/food/beef.jpg"), description: "Tender beef wrapped in puff pastry", time: "90 Mins", calories: "750 kcal", }, ]; const navigateToFoodDetail = (foodId: string) => { router.push({ pathname: "/food/[id]", params: { id: foodId } }); }; export default function HomeScreen() { const [searchQuery, setSearchQuery] = useState(""); const [filteredRecipes, setFilteredRecipes] = useState(foodHighlights); // Handle search const handleSearch = (text: string): void => { setSearchQuery(text); if (text) { const filtered = foodHighlights.filter((food) => food.name.toLowerCase().includes(text.toLowerCase()) ); setFilteredRecipes(filtered); } else { setFilteredRecipes(foodHighlights); } }; // 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 */} {/* Show your dishes */} Show your dishes From Camera Straight from Camera From Gallery Straight from Gallery {/* Food Highlights Section */} Food Highlights {foodHighlights.map((food) => ( navigateToFoodDetail(String(food.id))} > {food.name} {food.description} {food.time} {food.calories} ))} {/* Extra space at bottom */} ); }