import React from "react"; import { Image, StyleSheet, ScrollView, Dimensions, TouchableWithoutFeedback } from "react-native"; import { Block, Text, theme } from "galio-framework"; import { Card } from "../components/"; import categories from "../constants/categories"; import { argonTheme } from "../constants"; const { width } = Dimensions.get("window"); const cardWidth = width - theme.SIZES.BASE * 2; export default class Category extends React.Component { renderSuggestions = () => { const { navigation, route } = this.props; // const { params } = navigation && navigation.state; // const category = categories[params.id]; // const suggestions = category && category.suggestions; const category = categories[route.params?.id]; const suggestions = category && category.suggestions; if (!suggestions) return null; return ( ); }; renderCard = (item, index) => { const { navigation } = this.props; return ( navigation.navigate("Product", { product: item })} > $125 {item.title} {item.description} ); }; render() { const { navigation, route } = this.props; // const { params } = navigation && navigation.state; // const category = categories[params.id]; const category = categories[route.params?.id]; return ( {category && category.images.map((item, index) => this.renderCard(item, index) )} {this.renderSuggestions()} ); } } const styles = StyleSheet.create({ Card: { width: cardWidth - theme.SIZES.BASE * 2, marginHorizontal: theme.SIZES.BASE, marginTop: theme.SIZES.BASE * 2, shadowColor: "black", shadowOffset: { width: 0, height: 7 }, shadowRadius: 10, shadowOpacity: 0.2 }, image: { width: cardWidth - theme.SIZES.BASE, height: cardWidth - theme.SIZES.BASE, borderRadius: 3 }, imageVertical: { overflow: "hidden", borderTopRightRadius: 4, borderTopLeftRadius: 4 }, price: { fontFamily: 'open-sans-bold', paddingTop: theme.SIZES.BASE, paddingBottom: theme.SIZES.BASE / 2 }, description: { fontFamily: 'open-sans-regular', paddingTop: theme.SIZES.BASE, paddingBottom: theme.SIZES.BASE * 2 }, suggestion: { backgroundColor: theme.COLORS.WHITE, marginBottom: theme.SIZES.BASE, borderWidth: 0, marginLeft: theme.SIZES.BASE / 2, marginRight: theme.SIZES.BASE / 2 }, suggestionTitle: { flex: 1, flexWrap: "wrap", paddingBottom: 6 }, suggestionDescription: { padding: theme.SIZES.BASE / 2 } });