Files
notesnook/apps/mobile/src/components/SimpleList/sectionheader.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-02-09 11:33:57 +05:00
import React from 'react';
import { TouchableOpacity, useWindowDimensions, View } from 'react-native';
import { useTracked } from '../../provider';
import { eSendEvent } from '../../services/EventManager';
import { eOpenJumpToDialog } from '../../utils/Events';
import { SIZE } from '../../utils/SizeUtils';
import { HeaderMenu } from '../Header/HeaderMenu';
2021-02-09 11:33:57 +05:00
import Heading from '../Typography/Heading';
export const SectionHeader = ({
2021-06-08 12:26:55 +05:00
item,
index,
headerProps,
jumpToDialog,
sortMenuButton,
}) => {
const [state] = useTracked();
const {colors} = state;
const {fontScale} = useWindowDimensions();
2021-06-08 12:26:55 +05:00
return (
<View
style={{
flexDirection: 'row',
alignItems: 'center',
width: '100%',
justifyContent: 'space-between',
paddingHorizontal: 12,
2021-07-09 12:15:06 +05:00
height: 35 * fontScale,
backgroundColor: colors.nav,
2021-06-08 12:26:55 +05:00
marginTop: index === 0 ? 0 : 5 * fontScale,
}}>
<TouchableOpacity
onPress={() => {
console.log('called');
if (jumpToDialog) {
console.log('sending event');
eSendEvent(eOpenJumpToDialog);
}
}}
activeOpacity={0.9}
hitSlop={{top: 10, left: 10, right: 30, bottom: 15}}
style={{
height: '100%',
justifyContent: 'center',
}}>
<Heading
color={colors.accent}
size={SIZE.sm}
style={{
minWidth: 60,
alignSelf: 'center',
textAlignVertical: 'center',
}}>
{!item.title || item.title === '' ? 'Pinned' : item.title}
</Heading>
</TouchableOpacity>
{index === 0 && sortMenuButton ? <HeaderMenu /> : null}
</View>
);
};