-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMyList.js
More file actions
61 lines (52 loc) · 1.75 KB
/
MyList.js
File metadata and controls
61 lines (52 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { FlatList, Text, View, Button, Image, TouchableOpacity} from 'react-native';
import { addItem } from './ItemsActions';
import { styles } from './styles'
import { data } from './data';
function AddItemsScreen(props) {
const ItemView = ({ item, index }) => {
return (
<View style={styles.listItem}>
<View style={{ flex: 1 }}>
<Image
source={ data[data.findIndex(element => element.groceryItem.localeCompare(item) == 0)].src }
style={styles.itemImage}
/>
</View>
<Text style={styles.itemTextStyle} onPress={() => props.addItem(index)}>{item}</Text>
</View>
);
};
const ItemSeparatorView = () => {
return (
<View style={styles.fList} />
);
};
return (
<View style={styles.container2}>
<Text style={styles.heading11}>JIV'S GROCERIES</Text>
<Text style={styles.heading2}>Groceries</Text>
<FlatList
data={props.items.possible}
ItemSeparatorComponent={ItemSeparatorView}
renderItem={ItemView}
keyExtractor={item => item.id} />
<TouchableOpacity
onPress={() => props.navigation.navigate('My Lists')}>
<Text style={styles.myListText}>Click Here to view Your List!</Text>
</TouchableOpacity>
</View>
);
}
const mapStateToProps = (state) => {
const { items } = state
return { items }
};
const mapDispatchToProps = dispatch => (
bindActionCreators({
addItem,
}, dispatch)
);
export default connect(mapStateToProps, mapDispatchToProps)(AddItemsScreen);