import React, { useEffect, useState } from 'react'; import { Platform, StyleSheet, View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useTracked } from '../../provider'; import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager'; import Navigation from '../../services/Navigation'; import { dWidth } from '../../utils'; import { eScrollEvent } from '../../utils/Events'; import { SIZE } from '../../utils/SizeUtils'; import { ActionIcon } from '../ActionIcon'; import { SearchInput } from '../SearchInput'; import { HeaderLeftMenu } from './HeaderLeftMenu'; import { HeaderRightMenu } from './HeaderRightMenu'; import { HeaderTitle } from './HeaderTitle'; export const Header = ({root}) => { const [state] = useTracked(); const {colors, currentScreen} = state; const insets = useSafeAreaInsets(); const [hide, setHide] = useState(true); const onScroll = (y) => { if (y > 150) { setHide(false); } else { setHide(true); } }; useEffect(() => { eSubscribeEvent(eScrollEvent, onScroll); return () => { eUnSubscribeEvent(eScrollEvent, onScroll); }; }, []); return ( {(Platform.OS === 'android' && currentScreen !== 'search') || Platform.isPad ? ( ) : null} {Platform.OS !== 'android' && !Platform.isPad && currentScreen !== 'search' ? ( ) : null} {currentScreen === 'search' ? ( ) : null} {currentScreen === 'search' ? ( { Navigation.navigate('Search', { menu: false, }); }} name="tune" size={SIZE.xxxl} color={colors.pri} style={styles.rightBtn} /> ) : ( )} ); }; const styles = StyleSheet.create({ container: { flexDirection: 'row', zIndex: 11, height: 50, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 12, width: '100%', }, loadingContainer: { alignSelf: 'center', alignItems: 'center', justifyContent: 'center', zIndex: 999, left: dWidth / 2 - 20, top: -20, width: 40, height: 40, position: 'absolute', }, loadingInnerContainer: { width: 40, height: 20, position: 'absolute', zIndex: 10, top: 0, }, leftBtnContainer: { flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', position: 'absolute', left: 12, }, leftBtn: { justifyContent: 'center', alignItems: 'center', height: 40, width: 40, borderRadius: 100, marginLeft: -5, marginRight: 25, }, rightBtnContainer: { flexDirection: 'row', alignItems: 'center', position: 'absolute', right: 12, }, rightBtn: { justifyContent: 'center', alignItems: 'flex-end', height: 40, width: 50, paddingRight: 0, }, });