mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
remove backHandler fro header
This commit is contained in:
@@ -1,22 +1,15 @@
|
||||
import React, {useEffect} from 'react';
|
||||
import {useTracked} from '../../provider';
|
||||
import {SIZE} from '../../utils/SizeUtils';
|
||||
import {DDS} from '../../services/DeviceDetection';
|
||||
import {ActionIcon} from '../ActionIcon';
|
||||
import React from 'react';
|
||||
import { useTracked } from '../../provider';
|
||||
import { DDS } from '../../services/DeviceDetection';
|
||||
import NavigationService from '../../services/Navigation';
|
||||
import {eSendEvent} from '../../services/EventManager';
|
||||
import {eClearSearch} from '../../utils/Events';
|
||||
import {BackHandler} from 'react-native';
|
||||
import { SIZE } from '../../utils/SizeUtils';
|
||||
import { ActionIcon } from '../ActionIcon';
|
||||
|
||||
export const HeaderLeftMenu = () => {
|
||||
const [state] = useTracked();
|
||||
const {colors, headerMenuState, searchResults} = state;
|
||||
|
||||
const onLeftButtonPress = () => {
|
||||
if (searchResults.results.length > 0) {
|
||||
eSendEvent(eClearSearch);
|
||||
return;
|
||||
}
|
||||
if (headerMenuState) {
|
||||
NavigationService.openDrawer();
|
||||
return;
|
||||
@@ -24,26 +17,6 @@ export const HeaderLeftMenu = () => {
|
||||
NavigationService.goBack();
|
||||
};
|
||||
|
||||
const onBackPress = () => {
|
||||
if (searchResults.results.length > 0) {
|
||||
eSendEvent(eClearSearch);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (searchResults.results.length > 0) {
|
||||
BackHandler.addEventListener('hardwareBackPress', onBackPress);
|
||||
} else {
|
||||
BackHandler.removeEventListener('hardwareBackPress', onBackPress);
|
||||
}
|
||||
|
||||
return () => {
|
||||
BackHandler.removeEventListener('hardwareBackPress', onBackPress);
|
||||
};
|
||||
}, [searchResults.results]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{!DDS.isTab ? (
|
||||
@@ -59,11 +32,7 @@ export const HeaderLeftMenu = () => {
|
||||
marginRight: 25,
|
||||
}}
|
||||
onPress={onLeftButtonPress}
|
||||
name={
|
||||
!headerMenuState || searchResults.results.length > 0
|
||||
? 'arrow-left'
|
||||
: 'menu'
|
||||
}
|
||||
name={!headerMenuState ? 'arrow-left' : 'menu'}
|
||||
size={SIZE.xxxl}
|
||||
color={colors.pri}
|
||||
iconStyle={{
|
||||
|
||||
Reference in New Issue
Block a user