2020-01-13 14:47:28 +05:00
|
|
|
import React from 'react';
|
2020-01-18 00:46:29 +05:00
|
|
|
import {
|
2020-01-18 01:04:33 +05:00
|
|
|
Platform,
|
2020-01-18 00:46:29 +05:00
|
|
|
SafeAreaView,
|
2020-01-18 01:04:33 +05:00
|
|
|
StatusBar,
|
|
|
|
|
Text,
|
2020-01-18 00:46:29 +05:00
|
|
|
TouchableOpacity,
|
|
|
|
|
View,
|
|
|
|
|
} from 'react-native';
|
2020-01-18 01:04:33 +05:00
|
|
|
import * as Animatable from 'react-native-animatable';
|
|
|
|
|
import Icon from 'react-native-vector-icons/Feather';
|
2020-01-13 14:47:28 +05:00
|
|
|
import {SIZE, WEIGHT} from '../../common/common';
|
2020-01-18 01:04:33 +05:00
|
|
|
import {ACTIONS, useTracked} from '../../provider';
|
2020-01-13 14:47:28 +05:00
|
|
|
import {w} from '../../utils/utils';
|
|
|
|
|
|
|
|
|
|
export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(
|
|
|
|
|
SafeAreaView,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export const SelectionHeader = ({navigation}) => {
|
|
|
|
|
// State
|
2020-01-17 21:26:01 +05:00
|
|
|
const [state, dispatch] = useTracked();
|
|
|
|
|
const {colors, selectionMode, selectedItemsList} = state;
|
|
|
|
|
|
2020-01-13 14:47:28 +05:00
|
|
|
// Render
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Animatable.View
|
|
|
|
|
transition={['backgroundColor', 'opacity', 'height']}
|
|
|
|
|
duration={300}
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
position: 'absolute',
|
2020-01-18 00:46:29 +05:00
|
|
|
height: selectionMode ? 50 + StatusBar.currentHeight : 0,
|
2020-01-13 14:47:28 +05:00
|
|
|
opacity: selectionMode ? 1 : 0,
|
2020-01-18 00:46:29 +05:00
|
|
|
backgroundColor: colors.bg,
|
|
|
|
|
paddingTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
|
2020-01-13 14:47:28 +05:00
|
|
|
justifyContent: 'flex-end',
|
|
|
|
|
zIndex: 11,
|
|
|
|
|
}}>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: w - 24,
|
|
|
|
|
marginHorizontal: 12,
|
|
|
|
|
height: 50,
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
}}>
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
}}>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() => {
|
2020-01-18 00:46:29 +05:00
|
|
|
dispatch({type: ACTIONS.SELECTION_MODE, enabled: !selectionMode});
|
2020-01-13 14:47:28 +05:00
|
|
|
}}
|
|
|
|
|
hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}
|
|
|
|
|
style={{
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'flex-start',
|
|
|
|
|
height: 40,
|
|
|
|
|
width: 50,
|
|
|
|
|
marginTop: 2.5,
|
|
|
|
|
}}>
|
|
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
marginLeft: -5,
|
|
|
|
|
}}
|
|
|
|
|
color={colors.pri}
|
|
|
|
|
name={'chevron-left'}
|
|
|
|
|
size={SIZE.xxxl - 3}
|
|
|
|
|
/>
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
|
<Text
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: SIZE.lg,
|
|
|
|
|
fontFamily: WEIGHT.regular,
|
|
|
|
|
color: colors.pri,
|
|
|
|
|
textAlignVertical: 'center',
|
|
|
|
|
}}>
|
|
|
|
|
{selectedItemsList.length}
|
|
|
|
|
</Text>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
}}>
|
|
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
paddingLeft: 25,
|
|
|
|
|
}}
|
|
|
|
|
color={colors.accent}
|
|
|
|
|
name={'plus'}
|
|
|
|
|
size={SIZE.xl}
|
|
|
|
|
/>
|
|
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
paddingLeft: 25,
|
|
|
|
|
}}
|
|
|
|
|
color={colors.accent}
|
|
|
|
|
name={'star'}
|
|
|
|
|
size={SIZE.xl - 3}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
paddingLeft: 25,
|
|
|
|
|
}}
|
|
|
|
|
color={colors.errorText}
|
|
|
|
|
name={'trash'}
|
|
|
|
|
size={SIZE.xl - 3}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
</Animatable.View>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SelectionHeader;
|