import { useNavigation } from '@react-navigation/native'; import React from 'react'; import { View, Text, StyleSheet, FlatList, TouchableOpacity, Image, useWindowDimensions, } from 'react-native'; import pizzas, { Pizza as PizzaType } from '../data/pizzas'; import { CartButton, Header, Pager } from '../components'; import theme from '../config/theme'; const LIST_MARGIN = 14; const ITEM_MARGIN = 6; const styles = StyleSheet.create({ container: { height: '100%', width: '100%', backgroundColor: theme.colors.bg, }, pizzaBox: { margin: ITEM_MARGIN, width: '100%', height: '100%', }, pizzaImage: { borderTopLeftRadius: 8, borderTopRightRadius: 8, height: '100%', width: '100%', }, pizzaBorder: { borderBottomLeftRadius: 8, borderBottomRightRadius: 8, borderColor: theme.colors.lighterGray, borderWidth: 2, borderTopColor: theme.colors.transparent, }, pizzaTitle: { margin: 8, fontWeight: '400', fontSize: 12, lineHeight: 12, color: theme.colors.text, }, listContainer: { margin: LIST_MARGIN, height: '100%', width: '100%', marginTop: 60, }, cart: { position: 'absolute', right: 20, top: 60, }, }); const renderPizza: React.FC<{ item: PizzaType; navigation: any; size: number; }> = ({ item, navigation, size, }: { item: PizzaType; navigation: any; size: number; }) => { return ( navigation.navigate('Pizza', { pizza: item })} > {item.title} ); }; const PizzaList: React.FC = () => { const navigation = useNavigation(); const { width } = useWindowDimensions(); const pizzaSize = (width - LIST_MARGIN * 2 - ITEM_MARGIN * 4 - 8) / 2; return (
renderPizza({ item, navigation, size: pizzaSize }) } numColumns={2} /> ), }, { title: 'Calzones', content: , }, ]} /> navigation.navigate('Pizza')}> {'Login'} ); }; export default PizzaList;