diff --git a/apps/mobile/src/components/Container/index.js b/apps/mobile/src/components/Container/index.js index 0b20dea19..94ed561e0 100644 --- a/apps/mobile/src/components/Container/index.js +++ b/apps/mobile/src/components/Container/index.js @@ -27,7 +27,7 @@ const AnimatedTouchableOpacity = Animatable.createAnimatableComponent( ); const AnimatedSafeAreaView = Animatable.createAnimatableComponent(SafeAreaView); - +let previousOffset = 0; export const Container = ({ children, bottomButtonOnPress, @@ -55,31 +55,21 @@ export const Container = ({ const [hideHeader, setHideHeader] = useState(false); const [buttonHide, setButtonHide] = useState(false); const insets = useSafeArea(); - let offsetY = 0; - let countUp = 1; - let countDown = 0; + let searchResult = []; - const onScroll = y => { + const onScroll = currentOffset => { if (searchResults.length > 0) return; - if (y < 30) { - countUp = 1; - countDown = 0; - setHideHeader(false); - } - if (y > offsetY) { - if (y - offsetY < 150 || countDown > 0) return; - countDown = 1; - countUp = 0; + if (currentOffset > previousOffset) { + console.log('call A', currentOffset, previousOffset); + setHideHeader(true); } else { - if (offsetY - y < 50 || countUp > 0) return; - countDown = 0; - countUp = 1; + console.log('call B', currentOffset, previousOffset); setHideHeader(false); } - offsetY = y; + previousOffset = currentOffset; }; const onChangeText = value => { diff --git a/apps/mobile/src/components/SearchInput/index.js b/apps/mobile/src/components/SearchInput/index.js index a3bbc3f8b..e7233790a 100644 --- a/apps/mobile/src/components/SearchInput/index.js +++ b/apps/mobile/src/components/SearchInput/index.js @@ -1,17 +1,17 @@ -import React, { useEffect, useState } from 'react'; -import { TextInput } from 'react-native'; -import Animated, { Easing } from 'react-native-reanimated'; +import React, {useEffect, useState} from 'react'; +import {TextInput} from 'react-native'; +import Animated, {Easing} from 'react-native-reanimated'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; -import { br, SIZE, WEIGHT } from '../../common/common'; -import { useTracked } from '../../provider'; -import { inputRef } from '../../utils/refs'; -import { DDS } from '../../utils/utils'; +import {br, SIZE, WEIGHT} from '../../common/common'; +import {useTracked} from '../../provider'; +import {inputRef} from '../../utils/refs'; +import {DDS} from '../../utils/utils'; -const { Value, timing, block } = Animated; +const {Value, timing, block} = Animated; export const Search = props => { const [state, dispatch] = useTracked(); - const { colors, searchResults } = state; + const {colors, searchResults} = state; const [focus, setFocus] = useState(false); @@ -46,7 +46,7 @@ export const Search = props => { height: 60, justifyContent: 'center', marginTop: _marginAnim, - paddingHorizontal: 12 + paddingHorizontal: 12, }}> { placeholderTextColor={colors.icon} /> { props.onSubmitEditing(); }} diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js index c6e4cc173..1fea04b2e 100644 --- a/apps/mobile/src/components/SimpleList/index.js +++ b/apps/mobile/src/components/SimpleList/index.js @@ -40,7 +40,6 @@ const SimpleList = ({ const _onScroll = event => { if (!event) return; let y = event.nativeEvent.contentOffset.y; - eSendEvent(eScrollEvent, y); };