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

41 lines
1.0 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';
2020-10-13 17:02:14 +05:00
import {Header} from '../Header';
2020-05-10 22:14:44 +05:00
export const ContainerTopSection = ({root}) => {
2020-11-03 10:02:36 +05:00
const [state,] = useTracked();
2020-05-10 22:14:44 +05:00
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={{
backgroundColor: colors.bg,
width: '100%',
opacity: opacity,
overflow: 'hidden',
transform: [
{
translateY: translateY,
},
],
2020-05-10 22:14:44 +05:00
}}>
2020-10-13 17:02:14 +05:00
<Header root={root} />
</Animated.View>
2020-05-10 22:14:44 +05:00
);
};