2020-01-13 17:33:41 +05:00
|
|
|
import React from 'react';
|
|
|
|
|
import {View, TouchableOpacity} from 'react-native';
|
|
|
|
|
import {SIZE} from '../../common/common';
|
|
|
|
|
import Icon from 'react-native-vector-icons/Feather';
|
|
|
|
|
import {w} from '../../utils/utils';
|
2020-01-18 00:46:29 +05:00
|
|
|
import {useTracked, ACTIONS} from '../../provider';
|
2020-01-13 17:33:41 +05:00
|
|
|
|
|
|
|
|
const SelectionWrapper = ({children, item}) => {
|
2020-01-17 21:26:01 +05:00
|
|
|
const [state, dispatch] = useTracked();
|
|
|
|
|
const {colors, selectionMode, selectedItemsList} = state;
|
2020-01-17 00:23:16 +05:00
|
|
|
|
2020-01-13 17:33:41 +05:00
|
|
|
return (
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
2020-01-22 02:51:24 +05:00
|
|
|
width: '100%',
|
|
|
|
|
paddingHorizontal: 12,
|
2020-01-13 17:33:41 +05:00
|
|
|
}}>
|
2020-01-22 02:51:24 +05:00
|
|
|
<View
|
2020-01-18 00:46:29 +05:00
|
|
|
onPress={() => {
|
|
|
|
|
dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
|
|
|
|
|
}}
|
2020-01-13 17:33:41 +05:00
|
|
|
style={{
|
2020-01-22 02:51:24 +05:00
|
|
|
width: '10%',
|
2020-01-13 17:33:41 +05:00
|
|
|
height: 70,
|
|
|
|
|
justifyContent: 'center',
|
2020-01-22 02:51:24 +05:00
|
|
|
alignItems: 'center',
|
2020-01-13 17:33:41 +05:00
|
|
|
display: selectionMode ? 'flex' : 'none',
|
2020-01-17 00:23:16 +05:00
|
|
|
opacity: selectionMode ? 1 : 0,
|
2020-01-22 02:51:24 +05:00
|
|
|
paddingRight: 10,
|
2020-01-13 17:33:41 +05:00
|
|
|
}}>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
borderColor: selectedItemsList.includes(item)
|
|
|
|
|
? colors.accent
|
|
|
|
|
: colors.icon,
|
|
|
|
|
width: 30,
|
|
|
|
|
height: 30,
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
borderRadius: 100,
|
|
|
|
|
paddingTop: 4,
|
|
|
|
|
}}>
|
|
|
|
|
{selectedItemsList.includes(item) ? (
|
|
|
|
|
<Icon size={SIZE.md} color={colors.accent} name="check" />
|
|
|
|
|
) : null}
|
|
|
|
|
</View>
|
2020-01-22 02:51:24 +05:00
|
|
|
</View>
|
2020-01-13 17:33:41 +05:00
|
|
|
|
|
|
|
|
{children}
|
|
|
|
|
</View>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SelectionWrapper;
|