Optimizations / editing works
better styling
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React, { useRef, useEffect, useState, Suspense } from 'react';
|
import React, { useRef, useEffect, useState } from 'react';
|
||||||
import { StyleSheet, Text, TouchableOpacity, View, Animated } from 'react-native';
|
import { StyleSheet, Text, TouchableOpacity, View, Animated, Image } from 'react-native';
|
||||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
//themes
|
//themes
|
||||||
import { COLORS } from '../../themes/Colors';
|
import { COLORS } from '../../themes/Colors';
|
||||||
@@ -19,7 +19,7 @@ const ListedItem = (props) => {
|
|||||||
if (!product) {
|
if (!product) {
|
||||||
product = {
|
product = {
|
||||||
productName: props.id,
|
productName: props.id,
|
||||||
tag: 'uncathegorized',
|
tag: 'uncategorized',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const tag = useSelector(state => state.tags.find((tag) => tag.tagName === product.tag))
|
const tag = useSelector(state => state.tags.find((tag) => tag.tagName === product.tag))
|
||||||
@@ -95,9 +95,36 @@ const ListedItem = (props) => {
|
|||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<Text>Loading</Text>}>
|
<View style={{ flex: 1, paddingLeft: 8, paddingRight: 8, flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between' }}>
|
||||||
<View style={{ flex: 1, paddingLeft: 8, paddingRight: 8, flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between' }}>
|
<Animated.View style={[styles.listedItemStyle, { backgroundColor: tag.color + '33' }, item.checked ? styles.listedItemChecked : {}, {
|
||||||
<Animated.View style={[styles.listedItemStyle, { backgroundColor: tag.color + '33' }, item.checked ? styles.listedItemChecked : {}, {
|
transform: [{
|
||||||
|
scaleX: scaleAnimValue
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scaleY: scaleAnimValue
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]} >
|
||||||
|
<Image source={{ uri: product.image ? product.image : 'https://icons-for-free.com/iconfiles/png/512/linecon+products+round+icon-1320165923260225670.png' }}
|
||||||
|
style={styles.image} />
|
||||||
|
|
||||||
|
<TouchableOpacity style={{ flex: 1, }}
|
||||||
|
onPress={() => dispatch(modalToggle(props.id))}
|
||||||
|
onLongPress={() => dispatchAnim()}>
|
||||||
|
<View style={styles.nameTag}>
|
||||||
|
{item.person ? <Text style={styles.textPerson}>{item.person}</Text> : <View />}
|
||||||
|
</View>
|
||||||
|
<Text style={styles.textItem}>{product.productName}</Text>
|
||||||
|
<Text style={styles.textAmount}>{item.amount}</Text>
|
||||||
|
{item.details ? <Text style={styles.textDetails}>{item.details}</Text> : <View />}
|
||||||
|
|
||||||
|
</TouchableOpacity>
|
||||||
|
</Animated.View>
|
||||||
|
<TouchableOpacity style={[styles.checkButton, { flex: 1 }]} onPress={() => dispatchAnim()}>
|
||||||
|
<Animated.View style={[styles.checkmark, item.checked ? {
|
||||||
|
borderWidth: 0,
|
||||||
|
} : {}, {
|
||||||
|
backgroundColor: interpolateColor,
|
||||||
transform: [{
|
transform: [{
|
||||||
scaleX: scaleAnimValue
|
scaleX: scaleAnimValue
|
||||||
},
|
},
|
||||||
@@ -105,48 +132,22 @@ const ListedItem = (props) => {
|
|||||||
scaleY: scaleAnimValue
|
scaleY: scaleAnimValue
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]} >
|
},]} >
|
||||||
<TouchableOpacity style={{ flex: 1, }}
|
<Animated.View style={[{
|
||||||
onPress={() => dispatch(modalToggle(props.id))}
|
|
||||||
onLongPress={() => dispatchAnim()}>
|
|
||||||
<View style={styles.nameTag}>
|
|
||||||
{item.person ? <Text style={styles.textPerson}>{item.person}</Text> : <View />}
|
|
||||||
</View>
|
|
||||||
<Text style={styles.textItem}>{product.productName}</Text>
|
|
||||||
<Text style={styles.textAmount}>{item.amount}</Text>
|
|
||||||
{item.details ? <Text style={styles.textDetails}>{item.details}</Text> : <View />}
|
|
||||||
|
|
||||||
</TouchableOpacity>
|
|
||||||
</Animated.View>
|
|
||||||
<TouchableOpacity style={[styles.checkButton, { flex: 1 }]} onPress={() => dispatchAnim()}>
|
|
||||||
<Animated.View style={[styles.checkmark, item.checked ? {
|
|
||||||
borderWidth: 0,
|
|
||||||
} : {}, {
|
|
||||||
backgroundColor: interpolateColor,
|
|
||||||
transform: [{
|
transform: [{
|
||||||
scaleX: scaleAnimValue
|
scaleX: checkAnimValue
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
scaleY: scaleAnimValue
|
scaleY: checkAnimValue
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},]} >
|
}]}>
|
||||||
<Animated.View style={[{
|
<MaterialCommunityIcons name="check" color={COLORS.dp00} size={25} />
|
||||||
transform: [{
|
|
||||||
scaleX: checkAnimValue
|
|
||||||
},
|
|
||||||
{
|
|
||||||
scaleY: checkAnimValue
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}]}>
|
|
||||||
<MaterialCommunityIcons name="check" color={COLORS.dp00} size={25} />
|
|
||||||
</Animated.View>
|
|
||||||
|
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
</Animated.View>
|
||||||
</Suspense>
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default React.memo(ListedItem);
|
export default React.memo(ListedItem);
|
||||||
@@ -165,6 +166,18 @@ const styles = StyleSheet.create({
|
|||||||
listedItemChecked: {
|
listedItemChecked: {
|
||||||
backgroundColor: '#253f34',
|
backgroundColor: '#253f34',
|
||||||
},
|
},
|
||||||
|
image: {
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
opacity: 0.06,
|
||||||
|
width: 200,
|
||||||
|
|
||||||
|
|
||||||
|
borderTopLeftRadius: 150,
|
||||||
|
borderBottomLeftRadius: 150,
|
||||||
|
},
|
||||||
textItem: {
|
textItem: {
|
||||||
width: '80%',
|
width: '80%',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
@@ -158,8 +158,6 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
listedItemButton: {
|
listedItemButton: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
padding: 2,
|
|
||||||
paddingBottom: 3,
|
|
||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
@@ -181,11 +179,18 @@ const styles = StyleSheet.create({
|
|||||||
color: COLORS.textW1,
|
color: COLORS.textW1,
|
||||||
},
|
},
|
||||||
textPrice: {
|
textPrice: {
|
||||||
left: 8,
|
backgroundColor: '#000' + '3',
|
||||||
fontFamily: 'Roboto',
|
minWidth: 50,
|
||||||
fontSize: height * 0.5,
|
maxWidth: '70%',
|
||||||
color: COLORS.textW1,
|
borderBottomLeftRadius: height / 2,
|
||||||
|
borderRadius: height / 3,
|
||||||
|
|
||||||
|
marginBottom: 3,
|
||||||
|
marginLeft: 3,
|
||||||
|
paddingLeft: 5,
|
||||||
|
paddingRight: 10,
|
||||||
|
fontFamily: 'Roboto',
|
||||||
|
fontSize: height * 0.55,
|
||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|||||||
@@ -61,12 +61,11 @@ export default AddItemModal = () => {
|
|||||||
setDetails('');
|
setDetails('');
|
||||||
setFocussed(false)
|
setFocussed(false)
|
||||||
setProductsList(products.map((product) => product.productName));
|
setProductsList(products.map((product) => product.productName));
|
||||||
|
dispatch(toggleVisibility('addItemModalVisible'));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
alert('You should give both a product and an amount');
|
alert('You should insert both a product name and an amount');
|
||||||
}
|
}
|
||||||
dispatch(toggleVisibility('addItemModalVisible'));
|
|
||||||
};
|
};
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
setFocussed(false)
|
setFocussed(false)
|
||||||
@@ -91,7 +90,7 @@ export default AddItemModal = () => {
|
|||||||
|
|
||||||
<Text style={styles.modalHeaderText}>Add item</Text>
|
<Text style={styles.modalHeaderText}>Add item</Text>
|
||||||
<View style={styles.inputRow}>
|
<View style={styles.inputRow}>
|
||||||
<MaterialCommunityIcons name="food" color={COLORS.textW0 + '55'} size={30} />
|
<MaterialCommunityIcons name="food" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Product name'}
|
placeholder={'Product name'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
@@ -113,7 +112,7 @@ export default AddItemModal = () => {
|
|||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputRow}>
|
<View style={styles.inputRow}>
|
||||||
<MaterialCommunityIcons name="label-percent-outline" color={COLORS.textW0 + '55'} size={30} />
|
<MaterialCommunityIcons name="label-percent-outline" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Amount'}
|
placeholder={'Amount'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
@@ -125,7 +124,7 @@ export default AddItemModal = () => {
|
|||||||
{amount ? <MaterialCommunityIcons style = {{right:15}}name="check" color={COLORS.primary} size={25} /> : <MaterialCommunityIcons style = {{right:10, bottom: 10,}}name="asterisk" color={COLORS.actionCancel + 'aa'} size={12} />}
|
{amount ? <MaterialCommunityIcons style = {{right:15}}name="check" color={COLORS.primary} size={25} /> : <MaterialCommunityIcons style = {{right:10, bottom: 10,}}name="asterisk" color={COLORS.actionCancel + 'aa'} size={12} />}
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputRow}>
|
<View style={styles.inputRow}>
|
||||||
<MaterialCommunityIcons name="account-supervisor-circle" color={COLORS.textW0 + '55'} size={30} />
|
<MaterialCommunityIcons name="account-supervisor-circle" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'For'}
|
placeholder={'For'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
@@ -136,7 +135,7 @@ export default AddItemModal = () => {
|
|||||||
{person ? <MaterialCommunityIcons style = {{right:15}}name="check" color={COLORS.primary} size={25} /> : <View/>}
|
{person ? <MaterialCommunityIcons style = {{right:15}}name="check" color={COLORS.primary} size={25} /> : <View/>}
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputRow}>
|
<View style={styles.inputRow}>
|
||||||
<MaterialCommunityIcons name="folder-information-outline" color={COLORS.textW0 + '55'} size={30} />
|
<MaterialCommunityIcons name="pencil-plus-outline" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Additional details'}
|
placeholder={'Additional details'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { COLORS } from '../../../themes/Colors';
|
|||||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
|
|
||||||
//redux
|
//redux
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector} from 'react-redux';
|
||||||
import { productAdded } from '../../../redux/slices/groceryList/productsSlice';
|
import { productAdded } from '../../../redux/slices/groceryList/productsSlice';
|
||||||
import { toggleVisibility } from '../../../redux/slices/groceryList/toggleSlice';
|
import { toggleVisibility } from '../../../redux/slices/groceryList/toggleSlice';
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ export default AddProductModal = () => {
|
|||||||
const [product, setProduct] = useState('');
|
const [product, setProduct] = useState('');
|
||||||
const [tag, setTag] = useState('');
|
const [tag, setTag] = useState('');
|
||||||
const [price, setPrice] = useState('');
|
const [price, setPrice] = useState('');
|
||||||
const [image, setImage] = useState('https://icons-for-free.com/iconfiles/png/512/linecon+products+round+icon-1320165923260225670.png');
|
const [image, setImage] = useState('');
|
||||||
|
|
||||||
//tags
|
//tags
|
||||||
const tags = useSelector(state => state.tags)
|
const tags = useSelector(state => state.tags)
|
||||||
@@ -47,29 +47,26 @@ export default AddProductModal = () => {
|
|||||||
};
|
};
|
||||||
//tags
|
//tags
|
||||||
const toggleModal = () => {
|
const toggleModal = () => {
|
||||||
if (modalVisible) {
|
if (modalVisible && product !== '' && tags.find((listTag) => listTag.tagName === tag)) {
|
||||||
if (product !== '' && tags.find((listTag) => listTag.tagName === tag)) {
|
|
||||||
dispatch(productAdded(product, tag, price, image));
|
dispatch(productAdded(product, tag, price, image));
|
||||||
}
|
setTagsList(tags.map((listTag) => listTag.tagName));
|
||||||
else {
|
dispatch(toggleVisibility('addProductModalVisible'));
|
||||||
alert('You should give both a product name and a useable tag');
|
setProduct('');
|
||||||
}
|
setTag('');
|
||||||
|
setPrice();
|
||||||
|
setFocussed(false)
|
||||||
|
setImage('');
|
||||||
}
|
}
|
||||||
setTagsList(tags.map((listTag) => listTag.tagName));
|
else {
|
||||||
dispatch(toggleVisibility('addProductModalVisible'));
|
alert('You should give both a product name and a useable tag');
|
||||||
setProduct('');
|
}
|
||||||
setTag('');
|
}
|
||||||
setPrice();
|
|
||||||
setFocussed(false)
|
|
||||||
setImage('https://icons-for-free.com/iconfiles/png/512/linecon+products+round+icon-1320165923260225670.png');
|
|
||||||
|
|
||||||
};
|
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
setTagsList(tags.map((listTag) => listTag.tagName));
|
setTagsList(tags.map((listTag) => listTag.tagName));
|
||||||
setProduct('');
|
setProduct('');
|
||||||
setTag();
|
setTag();
|
||||||
setPrice();
|
setPrice();
|
||||||
setImage('https://icons-for-free.com/iconfiles/png/512/linecon+products+round+icon-1320165923260225670.png');
|
setImage('');
|
||||||
setFocussed(false)
|
setFocussed(false)
|
||||||
dispatch(toggleVisibility('addProductModalVisible'));
|
dispatch(toggleVisibility('addProductModalVisible'));
|
||||||
|
|
||||||
@@ -83,7 +80,6 @@ export default AddProductModal = () => {
|
|||||||
style={styles.modalAddProduct} >
|
style={styles.modalAddProduct} >
|
||||||
<View style={{
|
<View style={{
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
padding: 5,
|
|
||||||
backgroundColor: COLORS.dp01,
|
backgroundColor: COLORS.dp01,
|
||||||
}}>
|
}}>
|
||||||
<Text style={styles.modalHeaderText}>Add product</Text>
|
<Text style={styles.modalHeaderText}>Add product</Text>
|
||||||
@@ -91,19 +87,23 @@ export default AddProductModal = () => {
|
|||||||
<View style={{
|
<View style={{
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'flex-start',
|
justifyContent: 'flex-start',
|
||||||
|
width: '100%',
|
||||||
}}>
|
}}>
|
||||||
<View style={{
|
<View style={{
|
||||||
width: '60%',
|
width: '60%',
|
||||||
}}>
|
}}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
|
<View style={styles.inputRow}>
|
||||||
|
<MaterialCommunityIcons name="food" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Product name'}
|
placeholder={'Product name'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
style={styles.textInput}
|
style={styles.textInput}
|
||||||
onChangeText={text => setProduct(text)}
|
onChangeText={text => setProduct(text)}
|
||||||
/>
|
/>
|
||||||
|
{product ? <MaterialCommunityIcons style={{ right: 15 }} name="check" color={COLORS.primary} size={25} /> : <MaterialCommunityIcons style={{ right: 10, bottom: 10, }} name="asterisk" color={COLORS.actionCancel + 'aa'} size={12} />}
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
|
<View style={styles.inputRow}>
|
||||||
|
<MaterialCommunityIcons name="tag-text-outline" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Tag'}
|
placeholder={'Tag'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
@@ -113,6 +113,7 @@ export default AddProductModal = () => {
|
|||||||
onFocus={() => setFocussed(true)}
|
onFocus={() => setFocussed(true)}
|
||||||
onEndEditing={() => setFocussed(false)}
|
onEndEditing={() => setFocussed(false)}
|
||||||
/>
|
/>
|
||||||
|
{tag ? <MaterialCommunityIcons style={{ right: 15 }} name="check" color={COLORS.primary} size={25} /> : <MaterialCommunityIcons style={{ right: 10, bottom: 10, }} name="asterisk" color={COLORS.actionCancel + 'aa'} size={12} />}
|
||||||
<ScrollView style={styles.dropdown} keyboardShouldPersistTaps={'always'}>
|
<ScrollView style={styles.dropdown} keyboardShouldPersistTaps={'always'}>
|
||||||
{focussed ? tagsList.map((newTag, index) =>
|
{focussed ? tagsList.map((newTag, index) =>
|
||||||
<TouchableOpacity key={index} onPress={() => filterTagsList(newTag)} style={styles.dropdownProduct}>
|
<TouchableOpacity key={index} onPress={() => filterTagsList(newTag)} style={styles.dropdownProduct}>
|
||||||
@@ -121,33 +122,37 @@ export default AddProductModal = () => {
|
|||||||
) : <View />}
|
) : <View />}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
|
<View style={styles.inputRow}>
|
||||||
<Text style={styles.currencyPrefix}>€</Text>
|
<MaterialCommunityIcons name="currency-usd" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Price'}
|
placeholder={'Price'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
style={[styles.textInput, { paddingLeft: 20 }]}
|
style={[styles.textInput]}
|
||||||
onChangeText={text => setPrice(text)}
|
onChangeText={text => setPrice(text)}
|
||||||
keyboardType={'number-pad'}
|
keyboardType={'number-pad'}
|
||||||
/>
|
/>
|
||||||
|
{price ? <MaterialCommunityIcons style={{ right: 15 }} name="check" color={COLORS.primary} size={25} /> : <View />}
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
|
<View style={styles.inputRow}>
|
||||||
|
<MaterialCommunityIcons name="link-plus" color={COLORS.textW0 + '55'} size={25} />
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Image url'}
|
placeholder={'Image url'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
style={styles.textInput}
|
style={styles.textInput}
|
||||||
onChangeText={text => { if (text !== '') { return setImage(`https://www.googleapis.com/customsearch/v1?key=${product}&cx=017576662512468239146:omuauf_lfve&q=lectures`) } }}
|
onChangeText={text => setImage(text)}
|
||||||
/>
|
/>
|
||||||
|
{image ? <MaterialCommunityIcons style={{ right: 15 }} name="check" color={COLORS.primary} size={25} /> : <View />}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Image source={{ uri: image }}
|
{image ? <Image source={{ uri: image }}
|
||||||
style={{ width: 130, height: 130, marginTop: '5%', right: 10, borderRadius: 30, }} />
|
style={styles.image} />
|
||||||
|
: <View style={[styles.image,{borderColor: COLORS.dp00 +'88', borderWidth: 3,}]}/>}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-evenly', marginTop: 20, marginBottom: 10, }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-evenly', marginTop: 20, marginBottom: 10, }}>
|
||||||
<TouchableOpacity title="Hide modal" style={styles.modalCloseButton} onPress={closeModal} >
|
<TouchableOpacity title="Hide modal" style={styles.modalCloseButton} onPress={closeModal} >
|
||||||
<Text style={styles.modalCloseButtonText}>Cancel </Text>
|
<Text style={styles.modalCloseButtonText}> Cancel </Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<View style={{
|
<View style={{
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
@@ -158,7 +163,7 @@ export default AddProductModal = () => {
|
|||||||
|
|
||||||
}} />
|
}} />
|
||||||
<TouchableOpacity title="Hide modal" style={styles.modalAddButton} onPress={toggleModal} >
|
<TouchableOpacity title="Hide modal" style={styles.modalAddButton} onPress={toggleModal} >
|
||||||
<Text style={styles.modalAddButtonText}>Add product</Text>
|
<Text style={styles.modalAddButtonText}> Add product </Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -183,6 +188,14 @@ const styles = StyleSheet.create({
|
|||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
color: COLORS.textB0,
|
color: COLORS.textB0,
|
||||||
},
|
},
|
||||||
|
image: {
|
||||||
|
width: '40%',
|
||||||
|
height: '100%',
|
||||||
|
marginTop: '2%',
|
||||||
|
borderTopLeftRadius: 15,
|
||||||
|
borderBottomLeftRadius: 15,
|
||||||
|
|
||||||
|
},
|
||||||
modalAddButtonText: {
|
modalAddButtonText: {
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -195,37 +208,35 @@ const styles = StyleSheet.create({
|
|||||||
color: COLORS.primary,
|
color: COLORS.primary,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
},
|
},
|
||||||
|
inputRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'flex-end',
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
width: '100%',
|
||||||
|
marginLeft: 5,
|
||||||
|
},
|
||||||
textInput: {
|
textInput: {
|
||||||
|
|
||||||
height: 25,
|
height: 25,
|
||||||
width: '80%',
|
width: '80%',
|
||||||
left: 10,
|
|
||||||
|
|
||||||
borderBottomColor: COLORS.primary + 'aa',
|
borderBottomColor: COLORS.primary + 'aa',
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
borderRadius: 3,
|
borderRadius: 3,
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
padding: 0,
|
padding: 0,
|
||||||
paddingLeft: 5,
|
paddingLeft: 5,
|
||||||
paddingRight: 5,
|
paddingRight: 15,
|
||||||
|
|
||||||
color: COLORS.textW0,
|
color: COLORS.textW0,
|
||||||
fontSize: 18
|
fontSize: 18
|
||||||
|
|
||||||
},
|
},
|
||||||
currencyPrefix: {
|
|
||||||
position: 'absolute',
|
|
||||||
alignSelf: 'flex-end',
|
|
||||||
left: 15,
|
|
||||||
color: COLORS.primary + '99',
|
|
||||||
fontSize: 18,
|
|
||||||
},
|
|
||||||
dropdown: {
|
dropdown: {
|
||||||
|
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
maxHeight: 100,
|
maxHeight: 100,
|
||||||
width: 150,
|
width: '100%',
|
||||||
top: 40,
|
top: 40,
|
||||||
left: 10,
|
left: 10,
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default EditItemModal = (props) => {
|
|||||||
if (!product) {
|
if (!product) {
|
||||||
product = {
|
product = {
|
||||||
productName: props.id,
|
productName: props.id,
|
||||||
tag: 'uncathegorized',
|
tag: 'uncategorized',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ export default EditItemModal = (props) => {
|
|||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
|
||||||
<View style={{ width: '100%', flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'flex-start', backgroundColor: tag.color + '22', borderRadius: 10, }}>
|
<View style={{ width: '100%', flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'flex-start', backgroundColor: tag.color + '22', borderRadius: 10, }}>
|
||||||
{product.price ? <Text style={[styles.textPrice, { color: COLORS.textW0 + 'de', }]}>€{product.price}</Text> : <View />}
|
{product.price ? <Text style={[styles.textPrice, { color: COLORS.price, }]}>€{product.price}</Text> : <View />}
|
||||||
<Image source={{ uri: product.image }}
|
<Image source={{ uri: product.image }}
|
||||||
style={styles.image} />
|
style={styles.image} />
|
||||||
<Text style={[styles.textTags, { color: tag.color, }]}>{tag.tagName}</Text>
|
<Text style={[styles.textTags, { color: tag.color, }]}>{tag.tagName}</Text>
|
||||||
|
|||||||
@@ -22,9 +22,31 @@ export default EditProductModal = () => {
|
|||||||
const [tagName, setTagName] = useState(product.tag);
|
const [tagName, setTagName] = useState(product.tag);
|
||||||
const [price, setPrice] = useState(product.price.toString());
|
const [price, setPrice] = useState(product.price.toString());
|
||||||
const [imageURL, setImageURL] = useState(product.image);
|
const [imageURL, setImageURL] = useState(product.image);
|
||||||
|
//tags
|
||||||
|
const [tagsList, setTagsList] = useState(tags.map((listTag) => listTag.tagName));
|
||||||
|
const [focussed, setFocussed] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
const filterTagsList = (text) => {
|
||||||
|
let regex = new RegExp(text);
|
||||||
|
|
||||||
|
let newTagsList = tags.filter((tag) =>
|
||||||
|
regex.test(tag.tagName)
|
||||||
|
)
|
||||||
|
text !== '' ? newTagsList = newTagsList.map((tag) => tag.tagName) : newTagsList = tags.map((tag) => tag.tagName)
|
||||||
|
if (newTagsList.length === 1 && newTagsList[0] === text) {
|
||||||
|
setTagsList([]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setTagsList(newTagsList);
|
||||||
|
}
|
||||||
|
setTagName(text);
|
||||||
|
};
|
||||||
|
//tags
|
||||||
|
|
||||||
const saveModal = () => {
|
const saveModal = () => {
|
||||||
dispatch(editProduct(product.id, productName, tagName, price, imageURL));
|
let tagFound = tags.find((tag)=>tag.tagName === tagName)
|
||||||
|
dispatch(editProduct(product.id, productName, tagFound ? tagName : 'uncategorized', Number(price) ? Number(price) : 0, imageURL));
|
||||||
dispatch(modalToggle(product.id))
|
dispatch(modalToggle(product.id))
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@@ -34,7 +56,7 @@ export default EditProductModal = () => {
|
|||||||
swipeDirection={'down'}
|
swipeDirection={'down'}
|
||||||
onSwipeComplete={saveModal}
|
onSwipeComplete={saveModal}
|
||||||
useNativeDriverForBackdrop
|
useNativeDriverForBackdrop
|
||||||
style={styles.modalEditItem} >
|
style={styles.modalEditProduct} >
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={{ width: '100%', flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'flex-start', backgroundColor: tag.color + '22', borderRadius: 10, }}>
|
<View style={{ width: '100%', flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'flex-start', backgroundColor: tag.color + '22', borderRadius: 10, }}>
|
||||||
<Image source={{ uri: product.image }}
|
<Image source={{ uri: product.image }}
|
||||||
@@ -55,10 +77,19 @@ export default EditProductModal = () => {
|
|||||||
<TextInput
|
<TextInput
|
||||||
placeholder={'Tag'}
|
placeholder={'Tag'}
|
||||||
placeholderTextColor={'grey'}
|
placeholderTextColor={'grey'}
|
||||||
style={styles.textInput}
|
style={[styles.textInput]}
|
||||||
onChangeText={text => setTagName(text)}
|
|
||||||
value={tagName}
|
value={tagName}
|
||||||
|
onChangeText={text => filterTagsList(text)}
|
||||||
|
onFocus={() => setFocussed(true)}
|
||||||
|
onEndEditing={() => setFocussed(false)}
|
||||||
/>
|
/>
|
||||||
|
<ScrollView style={styles.dropdown} keyboardShouldPersistTaps={'always'}>
|
||||||
|
{focussed ? tagsList.map((newTag, index) =>
|
||||||
|
<TouchableOpacity key={index} onPress={() => filterTagsList(newTag)} style={styles.dropdownProduct}>
|
||||||
|
<Text style={styles.dropdownText}>{newTag}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
) : <View />}
|
||||||
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.inputRow}>
|
<View style={styles.inputRow}>
|
||||||
<MaterialCommunityIcons name="currency-usd" color={COLORS.textW0 + '55'} size={30} />
|
<MaterialCommunityIcons name="currency-usd" color={COLORS.textW0 + '55'} size={30} />
|
||||||
@@ -71,6 +102,16 @@ export default EditProductModal = () => {
|
|||||||
value={price}
|
value={price}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.inputRow}>
|
||||||
|
<MaterialCommunityIcons name="link-plus" color={COLORS.textW0 + '55'} size={30} />
|
||||||
|
<TextInput
|
||||||
|
placeholder={'Image'}
|
||||||
|
placeholderTextColor={'grey'}
|
||||||
|
style={styles.textInput}
|
||||||
|
onChangeText={text => setImageURL(text)}
|
||||||
|
value={imageURL}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<TouchableOpacity style={styles.modalSaveButton} onPress={saveModal} >
|
<TouchableOpacity style={styles.modalSaveButton} onPress={saveModal} >
|
||||||
<Text style={styles.modalSaveButtonText}>Save</Text>
|
<Text style={styles.modalSaveButtonText}>Save</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -89,7 +130,7 @@ const styles = StyleSheet.create({
|
|||||||
backgroundColor: COLORS.dp01,
|
backgroundColor: COLORS.dp01,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
},
|
},
|
||||||
modalEditItem: {
|
modalEditProduct: {
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
margin: 0,
|
margin: 0,
|
||||||
padding: 0,
|
padding: 0,
|
||||||
@@ -102,7 +143,6 @@ const styles = StyleSheet.create({
|
|||||||
alignSelf: 'flex-start',
|
alignSelf: 'flex-start',
|
||||||
borderTopRightRadius: 20,
|
borderTopRightRadius: 20,
|
||||||
},
|
},
|
||||||
|
|
||||||
textInput: {
|
textInput: {
|
||||||
|
|
||||||
height: 30,
|
height: 30,
|
||||||
@@ -124,7 +164,6 @@ const styles = StyleSheet.create({
|
|||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
justifyContent: 'flex-start',
|
justifyContent: 'flex-start',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
marginLeft: 5,
|
|
||||||
},
|
},
|
||||||
textItem: {
|
textItem: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -138,24 +177,6 @@ const styles = StyleSheet.create({
|
|||||||
color: COLORS.textW0 + 'ff',
|
color: COLORS.textW0 + 'ff',
|
||||||
backgroundColor: '#000' + '3',
|
backgroundColor: '#000' + '3',
|
||||||
},
|
},
|
||||||
textPrice: {
|
|
||||||
paddingLeft: '52%',
|
|
||||||
position: 'absolute',
|
|
||||||
fontSize: 18,
|
|
||||||
color: COLORS.textW1,
|
|
||||||
backgroundColor: '#000' + '5',
|
|
||||||
padding: 5,
|
|
||||||
width: '100%',
|
|
||||||
borderTopRightRadius: 10,
|
|
||||||
},
|
|
||||||
textTags: {
|
|
||||||
left: 8,
|
|
||||||
marginTop: 35,
|
|
||||||
fontFamily: 'Roboto',
|
|
||||||
fontSize: 18,
|
|
||||||
color: COLORS.textW1,
|
|
||||||
},
|
|
||||||
|
|
||||||
modalSaveButtonText: {
|
modalSaveButtonText: {
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
@@ -165,7 +186,35 @@ const styles = StyleSheet.create({
|
|||||||
modalSaveButton: {
|
modalSaveButton: {
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
}
|
},
|
||||||
|
dropdown: {
|
||||||
|
|
||||||
|
zIndex: 1,
|
||||||
|
position: 'absolute',
|
||||||
|
maxHeight: 100,
|
||||||
|
width: 150,
|
||||||
|
top: 40,
|
||||||
|
left: 10,
|
||||||
|
|
||||||
|
borderRadius: 10,
|
||||||
|
backgroundColor: COLORS.dp16 + 'ee',
|
||||||
|
},
|
||||||
|
dropdownProduct: {
|
||||||
|
|
||||||
|
zIndex: 1,
|
||||||
|
width: 150,
|
||||||
|
minHeight: 20,
|
||||||
|
borderBottomWidth: 1.0,
|
||||||
|
borderColor: '#666' + '5',
|
||||||
|
},
|
||||||
|
dropdownText: {
|
||||||
|
|
||||||
|
zIndex: 1,
|
||||||
|
left: 10,
|
||||||
|
fontSize: 17,
|
||||||
|
color: COLORS.textW0 + 'ee',
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createSlice } from '@reduxjs/toolkit';
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
const initialState = [
|
const initialState = [
|
||||||
{ tagName: 'uncathegorized', color: '#253f34' },
|
{ tagName: 'uncategorized', color: '#253f34' },
|
||||||
{ tagName: 'Meat', color: '#ef5350' },
|
{ tagName: 'Meat', color: '#ef5350' },
|
||||||
{ tagName: 'Vegetables & fruit', color: '#BDD684' },
|
{ tagName: 'Vegetables & fruit', color: '#BDD684' },
|
||||||
{ tagName: 'Meal', color: '#FA9600' },
|
{ tagName: 'Meal', color: '#FA9600' },
|
||||||
|
|||||||
@@ -102,10 +102,10 @@ function GroceryList() {
|
|||||||
const compareFunction = (a,b) => {
|
const compareFunction = (a,b) => {
|
||||||
const newA = products.find((product=>product.id === a.productId))
|
const newA = products.find((product=>product.id === a.productId))
|
||||||
let tagA
|
let tagA
|
||||||
newA ? tagA = newA.tag : tagA = "uncathegorized"
|
newA ? tagA = newA.tag : tagA = "uncategorized"
|
||||||
const newB = products.find((product=>product.id === b.productId))
|
const newB = products.find((product=>product.id === b.productId))
|
||||||
let tagB
|
let tagB
|
||||||
newB ? tagB = newB.tag : tagB = "uncathegorized"
|
newB ? tagB = newB.tag : tagB = "uncategorized"
|
||||||
return tagA.localeCompare(tagB)
|
return tagA.localeCompare(tagB)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const COLORS = {
|
|||||||
secondary: '#f2aeac', //secondary
|
secondary: '#f2aeac', //secondary
|
||||||
secondaryVar: '#ffffff', //secondary variant
|
secondaryVar: '#ffffff', //secondary variant
|
||||||
|
|
||||||
price: '#C6A337',
|
price: '#ece1bc',
|
||||||
|
|
||||||
|
|
||||||
//layout colors #DAE9FF
|
//layout colors #DAE9FF
|
||||||
|
|||||||
Reference in New Issue
Block a user