2017-04-01 20:53:37 -05:00
|
|
|
// @flow
|
|
|
|
|
import React, { Component } from 'react';
|
2017-04-14 21:47:54 -05:00
|
|
|
import { Picker, Text, View } from 'react-native';
|
2017-04-01 20:53:37 -05:00
|
|
|
import theme from '../ui-theme';
|
2017-04-14 12:28:48 -05:00
|
|
|
import { NameAndPlace } from '../components/ItemTile';
|
2017-04-15 15:11:22 -05:00
|
|
|
import { type FoodItem } from '../records/FoodItemRecord';
|
2017-04-09 23:28:28 -05:00
|
|
|
import { compose, pure } from 'recompose';
|
2017-04-14 12:28:48 -05:00
|
|
|
import ImageThumb from '../components/ImageThumb';
|
|
|
|
|
import ImageBackdrop from '../components/ImageBackdrop';
|
|
|
|
|
import IconButton from '../components/IconButton';
|
|
|
|
|
import { type Quantity, getQuantityText } from '../helpers/QuantityHelpers';
|
2017-04-14 21:47:54 -05:00
|
|
|
import Modal from '../components/Modal';
|
2017-04-15 15:11:22 -05:00
|
|
|
import { withFoodItem } from '../enhancers/foodItemEnhancers';
|
2017-04-14 12:28:48 -05:00
|
|
|
|
|
|
|
|
const QuantityText = pure(({ quantity }: { quantity: Quantity }) => (
|
2017-04-20 06:32:13 -05:00
|
|
|
<View style={{ flex: 1, alignItems: 'center', paddingTop: 20 }}>
|
|
|
|
|
<Text style={{ fontSize: 50, color: 'black', height: 100 }}>{getQuantityText(quantity)}</Text>
|
|
|
|
|
</View>
|
2017-04-14 12:28:48 -05:00
|
|
|
));
|
2017-04-01 20:53:37 -05:00
|
|
|
|
|
|
|
|
export class FoodItemDetail extends Component {
|
2017-04-20 06:32:13 -05:00
|
|
|
static displayName = 'FoodItemDetail';
|
2017-04-01 20:53:37 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
props: {
|
|
|
|
|
foodItem: FoodItem,
|
|
|
|
|
};
|
2017-04-01 20:53:37 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
state: {
|
|
|
|
|
quantityModalOpen: boolean,
|
|
|
|
|
};
|
2017-04-14 21:47:54 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
state = { quantityModalOpen: false };
|
2017-04-14 21:47:54 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
addToFaves = () => {};
|
2017-04-14 21:47:54 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
updateAmount = () => this.toggleQuantityModal();
|
2017-04-14 21:47:54 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
addPhoto = () => {};
|
2017-04-14 21:47:54 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
toggleQuantityModal = () => {
|
|
|
|
|
this.setState(({ quantityModalOpen }) => {
|
|
|
|
|
return { quantityModalOpen: !quantityModalOpen };
|
|
|
|
|
});
|
|
|
|
|
};
|
2017-04-14 21:47:54 -05:00
|
|
|
|
2017-04-20 06:32:13 -05:00
|
|
|
render() {
|
|
|
|
|
const { foodItem } = this.props;
|
|
|
|
|
return (
|
|
|
|
|
<View style={theme.page.container}>
|
|
|
|
|
<View style={{ flex: 2 }}>
|
|
|
|
|
<ImageBackdrop uri={foodItem.titleImage} />
|
|
|
|
|
<View style={{ position: 'absolute', bottom: 0, left: 0, flexDirection: 'row' }}>
|
|
|
|
|
{foodItem.images.map((imageURI, index) => {
|
|
|
|
|
return <ImageThumb key={index} uri={imageURI} />;
|
|
|
|
|
})}
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<View style={{ flex: 3, paddingTop: 10, paddingLeft: 20, paddingRight: 20 }}>
|
|
|
|
|
<NameAndPlace name="Whole Foods Market" place="525 N. Lamar Blvd. Austin" />
|
|
|
|
|
<QuantityText quantity="many" />
|
|
|
|
|
<View style={{ flexDirection: 'row', paddingBottom: 20 }}>
|
|
|
|
|
<IconButton style={{ flex: 3 }} glyph="stars" text="Add to Faves" onPress={this.addToFaves} />
|
|
|
|
|
<IconButton
|
|
|
|
|
style={{ flex: 3 }}
|
|
|
|
|
glyph="mode-edit"
|
|
|
|
|
text="Update Amount"
|
|
|
|
|
onPress={this.updateAmount}
|
|
|
|
|
/>
|
|
|
|
|
<IconButton style={{ flex: 3 }} glyph="insert-photo" text="Add Photo" onPress={this.addPhoto} />
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<Modal isVisible={this.state.quantityModalOpen}>
|
|
|
|
|
<Picker
|
|
|
|
|
selectedValue={foodItem.quantity}
|
|
|
|
|
onValueChange={this.toggleQuantityModal}
|
|
|
|
|
style={{ width: 250 }}
|
|
|
|
|
>
|
|
|
|
|
{['none', 'few', 'alot', 'plenty'].map(quantity => (
|
|
|
|
|
<Picker.Item key={quantity} label={getQuantityText(quantity)} value={quantity} />
|
|
|
|
|
))}
|
|
|
|
|
</Picker>
|
|
|
|
|
</Modal>
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
}
|
2017-04-01 20:53:37 -05:00
|
|
|
}
|
|
|
|
|
|
2017-04-15 15:11:22 -05:00
|
|
|
const enhance = compose(pure, withFoodItem);
|
2017-04-01 20:53:37 -05:00
|
|
|
|
|
|
|
|
export default enhance(FoodItemDetail);
|