food/src/views/Product.vue

98 lines
3.3 KiB
Vue
Raw Normal View History

2017-09-20 04:11:40 +02:00
<template>
2017-09-22 20:33:24 +02:00
<div>
<Loading v-if="isLoading"/>
2017-09-27 02:24:51 +02:00
<v-container fluid grid-list-lg v-else>
<v-layout row wrap align-baseline>
<v-flex xs12>
<v-card>
<v-container fluid grid-list-lg>
<v-layout row mb-3>
<v-flex xs5>
<v-avatar size="100%">
<img class="icon" :src="this.product.icon" />
</v-avatar>
</v-flex>
<v-flex xs7 class="text-xs-center">
<div>
<div class="headline">Herta</div>
<h2 class="title">{{ product.name }}</h2>
</div>
</v-flex>
</v-layout>
<ProductOverviewItem name="Diet" icon="check_circle" />
<ProductOverviewItem name="Allergens" icon="clear" />
<ProductOverviewItem name="Nutriscore">
<span>A</span>
</ProductOverviewItem>
<ProductOverviewItem name="Labels">
<span>A</span>
</ProductOverviewItem>
<ProductOverviewItem name="Made">
<span>300km away</span>
</ProductOverviewItem>
</v-container>
</v-card>
2017-09-22 20:33:24 +02:00
</v-flex>
</v-layout>
</v-container>
2017-09-27 02:24:51 +02:00
<v-bottom-nav v-if="!isLoading" :value="true" class="white">
<v-btn flat class="teal--text" value="recent">
<span>Overview</span>
<v-icon>view_list</v-icon>
</v-btn>
<v-btn flat class="teal--text" value="recent">
<span>Nutrition</span>
<v-icon>info_outline</v-icon>
</v-btn>
<v-btn flat class="teal--text" value="recent">
2017-09-27 02:24:51 +02:00
<span>Alerts</span>
<v-icon>warning</v-icon>
</v-btn>
</v-bottom-nav>
2017-09-22 20:33:24 +02:00
</div>
2017-09-20 04:11:40 +02:00
</template>
<script>
2017-09-22 20:33:24 +02:00
import Loading from '@/views/Loading';
2017-09-27 02:24:51 +02:00
import ProductOverviewItem from '@/components/ProductOverviewItem';
2017-09-22 20:33:24 +02:00
2017-09-20 04:11:40 +02:00
export default {
2017-09-22 20:33:24 +02:00
components: {
Loading,
2017-09-27 02:24:51 +02:00
ProductOverviewItem,
2017-09-22 20:33:24 +02:00
},
2017-09-20 04:11:40 +02:00
created() {
2017-09-22 20:33:24 +02:00
this.$store.dispatch('setTitle', { title: '' });
this.$store.dispatch('setBackgroundColor', { backgroundColor: '#9CCC65' });
2017-09-20 04:11:40 +02:00
this.fetchData();
},
watch: {
// Fetch again when the component is updated
$route: 'fetchData',
},
computed: {
product() {
2017-09-22 20:33:24 +02:00
return this.$store.state.product;
2017-09-20 04:11:40 +02:00
},
isLoading() {
2017-09-22 15:51:24 +02:00
return this.$store.state.isLoading;
2017-09-20 04:11:40 +02:00
},
},
methods: {
fetchData() {
this.$store.dispatch('getProduct', { EAN: this.$route.params.barcode });
},
},
};
</script>
2017-09-22 20:33:24 +02:00
<style scoped>
2017-09-27 02:24:51 +02:00
.icon {
height: auto;
width: auto;
max-width: 100%;
max-height: 100%;
2017-09-22 20:33:24 +02:00
}
</style>