Files
notesnook/apps/mobile/src/components/Container/ContainerTopSection.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

import React, {useEffect} from 'react';
import Animated, {Easing, useValue} from 'react-native-reanimated';
2020-05-10 22:14:44 +05:00
import {useTracked} from '../../provider';
import {Header} from '../header';
import {Search} from '../SearchInput';
export const ContainerTopSection = ({root}) => {
const [state, dispatch] = useTracked();
const {colors, selectionMode} = state;
const opacity = useValue(0);
const translateY = useValue(0);
useEffect(() => {
Animated.timing(opacity, {
duration: 100,
toValue: selectionMode ? 0 : 1,
easing: Easing.in(Easing.ease),
}).start();
Animated.timing(translateY, {
toValue: selectionMode ? -150 : 0,
duration: 100,
easing: Easing.in(Easing.ease),
}).start();
}, [selectionMode]);
2020-05-10 22:14:44 +05:00
return (
<Animated.View
2020-05-10 22:14:44 +05:00
style={{
position: 'absolute',
2020-05-10 22:14:44 +05:00
backgroundColor: colors.bg,
zIndex: 998,
display: 'flex',
2020-05-10 22:14:44 +05:00
width: '100%',
opacity: opacity,
overflow: 'hidden',
transform: [
{
translateY: translateY,
},
],
2020-05-10 22:14:44 +05:00
}}>
<Header root={root} />
2020-05-10 22:14:44 +05:00
<Search root={root} />
</Animated.View>
2020-05-10 22:14:44 +05:00
);
};