|
| 1 | +import React, { Component } from 'react'; |
| 2 | +import { StyleSheet, ScrollView, View } from 'react-native'; |
| 3 | +import OrderItem from './OrderItem'; |
| 4 | +import Total from './Total'; |
| 5 | + |
| 6 | +class ShoppingList extends Component { |
| 7 | + //state = { total: 0 }; |
| 8 | + constructor(props) { |
| 9 | + super(props); |
| 10 | + /*this.ds = new ListView.DataSource({ |
| 11 | + rowHasChanged: (r1, r2) => r1.title !== r2.title |
| 12 | + });*/ |
| 13 | + this.state = { total: 0 }; |
| 14 | + } |
| 15 | + |
| 16 | + updateTotal(amount) { |
| 17 | + this.setState({ total: this.state.total + amount }); |
| 18 | + } |
| 19 | + |
| 20 | + render() { |
| 21 | + return ( |
| 22 | + <View style={styles.wrapper}> |
| 23 | + <Total total={this.state.total} /> |
| 24 | + <ScrollView> |
| 25 | + |
| 26 | + <OrderItem |
| 27 | + img="https://pbs.twimg.com/profile_images/569593540674473984/slHSRznT.jpeg" |
| 28 | + title="BUH" |
| 29 | + desc="buh" |
| 30 | + price={25.36} |
| 31 | + onQuantityUpdate={this.updateTotal.bind(this)} |
| 32 | + /> |
| 33 | + <OrderItem |
| 34 | + img="https://pbs.twimg.com/profile_images/569593540674473984/slHSRznT.jpeg" |
| 35 | + title="BUH" |
| 36 | + desc="buh" |
| 37 | + price={25.36} |
| 38 | + onQuantityUpdate={this.updateTotal.bind(this)} |
| 39 | + /> |
| 40 | + <OrderItem |
| 41 | + img="https://pbs.twimg.com/profile_images/569593540674473984/slHSRznT.jpeg" |
| 42 | + title="BUH" |
| 43 | + desc="buh" |
| 44 | + price={25.36} |
| 45 | + onQuantityUpdate={this.updateTotal.bind(this)} |
| 46 | + /> |
| 47 | + <OrderItem |
| 48 | + img="https://pbs.twimg.com/profile_images/569593540674473984/slHSRznT.jpeg" |
| 49 | + title="BUH" |
| 50 | + desc="buh" |
| 51 | + price={25.36} |
| 52 | + onQuantityUpdate={this.updateTotal.bind(this)} |
| 53 | + /> |
| 54 | + |
| 55 | + </ScrollView> |
| 56 | + </View> |
| 57 | + ); |
| 58 | + } |
| 59 | +} |
| 60 | +export default ShoppingList; |
| 61 | +const styles = StyleSheet.create({ |
| 62 | + wrapper: { |
| 63 | + flex: 1 |
| 64 | + //justifyContent: 'flex-start' |
| 65 | + |
| 66 | + } |
| 67 | +}); |
| 68 | + |
| 69 | + /*renderOrderItems() { |
| 70 | + this.props.items.map(currentItem => |
| 71 | + <OrderItem |
| 72 | + imgsrc={currentItem.thumbnailUrl} |
| 73 | + title={currentItem.title} |
| 74 | + desc={currentItem.description} |
| 75 | + price={currentItem.price} |
| 76 | + onQuantityUpdate={this.updateTotal.bind(this)} |
| 77 | +
|
| 78 | + />); |
| 79 | + }*/ |
| 80 | +/*ShoppingList.defaultProps = |
| 81 | + { items: |
| 82 | + [{ title: 'Masterining React Native', |
| 83 | + thumbnailUrl: 'https://images-na.ssl-images-amazon.com/images/I/51OqHiEyDtL.jpg', |
| 84 | + description: 'One of the book used during the LAP2 course for learning React Native development', |
| 85 | + price: 30.4, |
| 86 | + url: 'https://www.amazon.it/dp/1785885782/ref=cm_sw_r_cp_ep_dp_xxFdzb4HAR9N9'}, |
| 87 | + {title:"Getting Started With React Native","thumbnailUrl":"https://images-na.ssl-images-amazon.com/images/I/51DkGupUKoL.jpg","description":"One of the book used during the LAP2 course for learning React Native development","price":30.4,"url":"https://www.amazon.it/dp/1785885189/ref=cm_sw_r_cp_ep_dp_XyFdzbBK48PEE"},{"title":"Masterining React Native","thumbnailUrl":"https://images-na.ssl-images-amazon.com/images/I/51OqHiEyDtL.jpg","description":"One of the book used during the LAP2 course for learning React Native development","price":30.4,"url":"https://www.amazon.it/dp/1785885782/ref=cm_sw_r_cp_ep_dp_xxFdzb4HAR9N9"},{"title":"Getting Started With React Native","thumbnailUrl":"https://images-na.ssl-images-amazon.com/images/I/51DkGupUKoL.jpg","description":"One of the book used during the LAP2 course for learning React Native development","price":30.4,"url":"https://www.amazon.it/dp/1785885189/ref=cm_sw_r_cp_ep_dp_XyFdzbBK48PEE"},{"title":"Masterining React Native","thumbnailUrl":"https://images-na.ssl-images-amazon.com/images/I/51OqHiEyDtL.jpg","description":"One of the book used during the LAP2 course for learning React Native development","price":30.4,"url":"https://www.amazon.it/dp/1785885782/ref=cm_sw_r_cp_ep_dp_xxFdzb4HAR9N9"},{"title":"Getting Started With React Native","thumbnailUrl":"https://images-na.ssl-images-amazon.com/images/I/51DkGupUKoL.jpg","description":"One of the book used during the LAP2 course for learning React Native development","price":30.4,"url":"https://www.amazon.it/dp/1785885189/ref=cm_sw_r_cp_ep_dp_XyFdzbBK48PEE"}]}*/ |
0 commit comments