mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
persist header title state for each screen
This commit is contained in:
@@ -8,11 +8,32 @@ import Heading from '../Typography/Heading';
|
|||||||
|
|
||||||
const opacity = new Animated.Value(0);
|
const opacity = new Animated.Value(0);
|
||||||
|
|
||||||
|
let scrollPostions = {};
|
||||||
|
|
||||||
export const HeaderTitle = () => {
|
export const HeaderTitle = () => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors, headerTextState} = state;
|
const {colors, headerTextState} = state;
|
||||||
|
|
||||||
const onScroll = async (y) => {
|
const onScroll = async (y) => {
|
||||||
|
if (typeof y !== 'number') {
|
||||||
|
if (y.type === 'back') {
|
||||||
|
scrollPostions[y.name] = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (scrollPostions[y.name]) {
|
||||||
|
if (scrollPostions[y.name] > 200) {
|
||||||
|
opacity.setValue(1);
|
||||||
|
} else {
|
||||||
|
scrollPostions[y.name] = 0;
|
||||||
|
opacity.setValue(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scrollPostions[y.name] = 0;
|
||||||
|
opacity.setValue(0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (y > 75) {
|
if (y > 75) {
|
||||||
let yVal = y - 75;
|
let yVal = y - 75;
|
||||||
o = yVal / 75;
|
o = yVal / 75;
|
||||||
@@ -20,6 +41,8 @@ export const HeaderTitle = () => {
|
|||||||
} else {
|
} else {
|
||||||
opacity.setValue(0);
|
opacity.setValue(0);
|
||||||
}
|
}
|
||||||
|
scrollPostions[headerTextState.heading] = y;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -27,7 +50,7 @@ export const HeaderTitle = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
eUnSubscribeEvent(eScrollEvent, onScroll);
|
eUnSubscribeEvent(eScrollEvent, onScroll);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [headerTextState.heading]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View
|
<Animated.View
|
||||||
|
|||||||
Reference in New Issue
Block a user