Files
notesnook/apps/mobile/src/components/SelectionHeader/index.js

126 lines
3.2 KiB
JavaScript
Raw Normal View History

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';
import {SIZE, WEIGHT} from '../../common/common';
2020-01-18 01:04:33 +05:00
import {ACTIONS, useTracked} from '../../provider';
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;
// 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,
opacity: selectionMode ? 1 : 0,
2020-01-18 00:46:29 +05:00
backgroundColor: colors.bg,
paddingTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
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});
}}
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;