Files
notesnook/apps/mobile/src/components/Header/HeaderLeftMenu.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-11-14 10:09:54 +05:00
import React from 'react';
import {useTracked} from '../../provider';
import {DDS} from '../../services/DeviceDetection';
2020-11-04 20:29:45 +05:00
import NavigationService from '../../services/Navigation';
import {sideMenuRef} from '../../utils/Refs';
import {SIZE} from '../../utils/SizeUtils';
import {ActionIcon} from '../ActionIcon';
2020-10-18 13:15:24 +05:00
export const HeaderLeftMenu = () => {
2020-11-04 20:29:45 +05:00
const [state] = useTracked();
const {colors, headerMenuState, currentScreen, deviceMode} = state;
2020-10-18 13:15:24 +05:00
2020-11-04 20:29:45 +05:00
const onLeftButtonPress = () => {
if (headerMenuState) {
sideMenuRef.current?.openMenu(true);
2020-11-04 20:29:45 +05:00
return;
}
NavigationService.goBack();
};
return (
<>
{deviceMode === 'mobile' || currentScreen === 'search' ? (
2020-11-04 20:29:45 +05:00
<ActionIcon
testID="left_menu_button"
customStyle={{
justifyContent: 'center',
alignItems: 'center',
height: 40,
width: 40,
borderRadius: 100,
marginLeft: -5,
marginRight: 25,
}}
onPress={onLeftButtonPress}
2020-11-14 10:09:54 +05:00
name={!headerMenuState ? 'arrow-left' : 'menu'}
2020-11-04 20:29:45 +05:00
size={SIZE.xxxl}
color={colors.pri}
iconStyle={{
marginLeft: !headerMenuState ? -5 : 0,
}}
/>
) : undefined}
</>
);
2020-10-18 13:15:24 +05:00
};