mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
add search input in main header
This commit is contained in:
@@ -3,22 +3,19 @@ import {ActivityIndicator, Platform, StyleSheet, View} from 'react-native';
|
|||||||
import * as Animatable from 'react-native-animatable';
|
import * as Animatable from 'react-native-animatable';
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {
|
import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
|
||||||
eSendEvent,
|
import NavigationService from '../../services/Navigation';
|
||||||
eSubscribeEvent,
|
|
||||||
eUnSubscribeEvent,
|
|
||||||
} from '../../services/EventManager';
|
|
||||||
import {dWidth} from '../../utils';
|
import {dWidth} from '../../utils';
|
||||||
import {ActionIcon} from '../ActionIcon';
|
|
||||||
import {HeaderMenu} from './HeaderMenu';
|
|
||||||
import {HeaderTitle} from './HeaderTitle';
|
|
||||||
import {SIZE} from '../../utils/SizeUtils';
|
|
||||||
import {HeaderLeftMenu} from './HeaderLeftMenu';
|
|
||||||
import {eScrollEvent} from '../../utils/Events';
|
import {eScrollEvent} from '../../utils/Events';
|
||||||
|
import {SIZE} from '../../utils/SizeUtils';
|
||||||
|
import {ActionIcon} from '../ActionIcon';
|
||||||
|
import {SearchInput} from '../SearchInput';
|
||||||
|
import {HeaderLeftMenu} from './HeaderLeftMenu';
|
||||||
|
import {HeaderTitle} from './HeaderTitle';
|
||||||
|
|
||||||
export const Header = ({root}) => {
|
export const Header = ({root}) => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors, syncing} = state;
|
const {colors, syncing, currentScreen} = state;
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
const [hide, setHide] = useState(false);
|
const [hide, setHide] = useState(false);
|
||||||
|
|
||||||
@@ -47,13 +44,28 @@ export const Header = ({root}) => {
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
borderBottomColor: hide ? 'transparent' : colors.nav,
|
borderBottomColor: hide ? 'transparent' : colors.nav,
|
||||||
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
<View style={styles.leftBtnContainer}>
|
<View style={styles.leftBtnContainer}>
|
||||||
<HeaderLeftMenu />
|
<HeaderLeftMenu />
|
||||||
{Platform.OS === 'android' ? <HeaderTitle root={root} /> : null}
|
|
||||||
|
{Platform.OS === 'android' && currentScreen !== 'search' ? (
|
||||||
|
<HeaderTitle root={root} />
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
{Platform.OS !== 'android' ? <HeaderTitle root={root} /> : null}
|
{Platform.OS !== 'android' && currentScreen !== 'search' ? (
|
||||||
|
<HeaderTitle root={root} />
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{currentScreen === 'search' ? (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
width: '80%',
|
||||||
|
}}>
|
||||||
|
<SearchInput />
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<Animatable.View
|
<Animatable.View
|
||||||
transition={['opacity']}
|
transition={['opacity']}
|
||||||
@@ -75,12 +87,23 @@ export const Header = ({root}) => {
|
|||||||
<ActivityIndicator size={25} color={colors.accent} />
|
<ActivityIndicator size={25} color={colors.accent} />
|
||||||
</Animatable.View>
|
</Animatable.View>
|
||||||
|
|
||||||
|
{currentScreen === 'search' ? (
|
||||||
<View style={styles.rightBtnContainer}>
|
<View style={styles.rightBtnContainer}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onPress={() => {
|
onPress={async () => {
|
||||||
if (!hideHeader) return;
|
NavigationService.navigate('Search');
|
||||||
setHideHeader(false);
|
}}
|
||||||
eSendEvent('showSearch');
|
name="tune"
|
||||||
|
size={SIZE.xxxl}
|
||||||
|
color={colors.pri}
|
||||||
|
style={styles.rightBtn}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View style={styles.rightBtnContainer}>
|
||||||
|
<ActionIcon
|
||||||
|
onPress={async () => {
|
||||||
|
NavigationService.navigate('Search');
|
||||||
}}
|
}}
|
||||||
name="magnify"
|
name="magnify"
|
||||||
size={SIZE.xxxl}
|
size={SIZE.xxxl}
|
||||||
@@ -88,6 +111,7 @@ export const Header = ({root}) => {
|
|||||||
style={styles.rightBtn}
|
style={styles.rightBtn}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user