import React, { PureComponent } from "react"; import { View } from 'react-native';…
- User
import React, { PureComponent } from "react"; import { View } from 'react-native'; import { Card, Chip, Text, useTheme } from 'react-native-paper';
import FoodData from './FoodData';
// import { Avatar, Button, Card, CardActionArea, CardActions, CardContent, CardHeader, CardMedia, Collapse, IconButton, Typography } from '@mui/material';
const timeNow = Date.now();
export type Props = { addMessage: (string) => void, data: FoodData; };
class FoodPost extends PureComponent { constructor(props) { super(props); this.state = { expanded: false }; } handlePress = () => { console.log("pressed lol"); // this.setState(prevState => ({ expanded: !prevState.expanded })); }
render() { const { addMessage, data, ...rest } = this.props; const theme = useTheme(); return ( <View style={{ margin: 8 }}> <Card mode="contained" style={{ backgroundColor: theme.colors.inverseOnSurface }} onPress={this.handlePress}> <Card.Title titleStyle={{ fontWeight: 'bold', paddingTop: 8 }} titleVariant="titleLarge" titleNumberOfLines={2} style={{ flex: 3 }} title={data.location} subtitle={getTimeAgo(data.date)} rightStyle={{ paddingRight: 20 }} right={(props) => <Text>< 3 miles</Text>} /> {/* Show chips */} <Card.Content style={{ paddingTop: 8, flexDirection: 'row', gap: 8, flexWrap: 'wrap' }}> {data.transportation && <Chip compact onPress={() => addMessage("This item requires you to leave campus or use transportation")} icon="car">Off-Campus</Chip>} {data.phoneNeeded && <Chip compact onPress={() => addMessage("Bring your phone (fill out form, show voucher, etc.)")} icon="cellphone">Need Phone</Chip>} {data.doorAccess && <Chip compact onPress={() => addMessage("Food is behind locked doors or in a private event")} icon="door-sliding-lock">Entry Needed</Chip>} </Card.Content> {/* Body */} <Card.Content style={{ paddingTop: 8 }}> <Text variant="bodyLarge">{data.details}</Text> </Card.Content> </Card> </View> ); }}
// const FoodPost = ({ addMessage, data, ...rest }: Props) => { // // Not snackbar // const [expanded, setExpanded] = React.useState(false); // const handlePress = () => setExpanded(!expanded); // const theme = useTheme(); // return ( // <View style={{ margin: 8 }}> // <Card mode="contained" style={{ backgroundColor: theme.colors.inverseOnSurface }} onPress={handlePress}> // <Card.Title titleStyle={{ fontWeight: 'bold', paddingTop: 8 }} titleVariant="titleLarge" titleNumberOfLines={2} style={{ flex: 3 }} title={data.location} subtitle={getTimeAgo(data.date)} rightStyle={{ paddingRight: 20 }} // right={(props) => < 3 miles} /> // {/* Show chips /} // <Card.Content style={{ paddingTop: 8, flexDirection: 'row', gap: 8, flexWrap: 'wrap' }}> // {data.transportation && <Chip compact onPress={() => addMessage("This item requires you to leave campus or use transportation")} icon="car">Off-Campus} // {data.phoneNeeded && <Chip compact onPress={() => addMessage("Bring your phone (fill out form, show voucher, etc.)")} icon="cellphone">Need Phone} // {data.doorAccess && <Chip compact onPress={() => addMessage("Food is behind locked doors or in a private event")} icon="door-sliding-lock">Entry Needed} // </Card.Content> // {/ Body */} // <Card.Content style={{ paddingTop: 8 }}> // {data.details} // </Card.Content> // // // ); // }
- Assistant