import React, {createRef} from 'react'; import { Platform, StatusBar, Text, TouchableOpacity, View, ActivityIndicator, } from 'react-native'; import * as Animatable from 'react-native-animatable'; import {SIZE, WEIGHT} from '../../common/common'; import {useTracked} from '../../provider'; import {eSendEvent} from '../../services/eventManager'; import {eCloseLoginDialog} from '../../services/events'; import NavigationService from '../../services/NavigationService'; import {DDS, w} from '../../utils/utils'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import Menu, {MenuItem, MenuDivider} from 'react-native-material-menu'; import {ACTIONS} from '../../provider/actions'; import {sideMenuRef} from '../../utils/refs'; import {moveNoteHideEvent} from '../DialogManager/recievers'; import {useSafeArea} from 'react-native-safe-area-context'; const menuRef = createRef(); export const Header = ({ heading, canGoBack = true, hide, showSearch, menu, verticalMenu = false, preventDefaultMargins, navigation = null, isLoginNavigator, headerColor, route, }) => { const [state, dispatch] = useTracked(); const {colors, syncing} = state; const insets = useSafeArea(); return ( {canGoBack ? ( { if (navigation && preventDefaultMargins) { if (route.name === 'Folders') { moveNoteHideEvent(); } else { navigation.goBack(); } } else if (navigation && isLoginNavigator) { if (route.name === 'Login') { eSendEvent(eCloseLoginDialog); } else { navigation.goBack(); } } else { NavigationService.goBack(); } }} style={{ justifyContent: 'center', alignItems: 'flex-start', height: 40, width: 50, }}> ) : ( undefined )} {menu && !DDS.isTab ? ( { sideMenuRef.current?.openMenu(true); }} style={{ justifyContent: 'center', alignItems: 'flex-start', height: 40, width: 60, }}> ) : ( undefined )} {heading.slice(0, 1) === '#' ? '#' : null} {heading.slice(0, 1) === '#' ? heading.slice(1) : heading} showSearch()} style={{ justifyContent: 'center', alignItems: 'flex-end', height: 40, width: 60, paddingRight: 0, }}> {verticalMenu ? ( { menuRef.current?.show(); }} style={{ justifyContent: 'center', alignItems: 'flex-end', height: 40, width: 60, }}> }> Sort by: { dispatch({type: ACTIONS.NOTES, sort: null}); menuRef.current?.hide(); }}> Default { dispatch({type: ACTIONS.NOTES, sort: 'abc'}); menuRef.current?.hide(); }}> Alphabetical { dispatch({type: ACTIONS.NOTES, sort: 'year'}); menuRef.current?.hide(); }}> By year { dispatch({type: ACTIONS.NOTES, sort: 'month'}); menuRef.current?.hide(); }}> By month { dispatch({type: ACTIONS.NOTES, sort: 'week'}); menuRef.current?.hide(); }}> By week ) : null} ); };