2020-10-13 17:02:14 +05:00
|
|
|
import {NavigationContainer} from '@react-navigation/native';
|
|
|
|
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
|
|
|
import * as React from 'react';
|
2020-11-04 16:52:47 +05:00
|
|
|
import {Animated} from 'react-native';
|
2020-10-13 17:02:14 +05:00
|
|
|
import Container from '../components/Container';
|
2020-11-04 16:52:47 +05:00
|
|
|
import {useTracked} from '../provider';
|
|
|
|
|
import {DDS} from '../services/DeviceDetection';
|
2020-10-13 17:02:14 +05:00
|
|
|
import {rootNavigatorRef} from '../utils/Refs';
|
|
|
|
|
import Favorites from '../views/Favorites';
|
|
|
|
|
import Folders from '../views/Folders';
|
|
|
|
|
import Home from '../views/Home';
|
|
|
|
|
import Notebook from '../views/Notebook';
|
|
|
|
|
import Notes from '../views/Notes';
|
2020-11-14 10:04:11 +05:00
|
|
|
import {Search} from '../views/Search';
|
2020-10-13 17:02:14 +05:00
|
|
|
import Settings from '../views/Settings';
|
|
|
|
|
import Tags from '../views/Tags';
|
|
|
|
|
import Trash from '../views/Trash';
|
|
|
|
|
|
|
|
|
|
const Stack = createStackNavigator();
|
|
|
|
|
|
2020-11-04 16:52:47 +05:00
|
|
|
const forFade = ({current}) => ({
|
|
|
|
|
cardStyle: {
|
|
|
|
|
opacity: current.progress,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const forSlide = ({current, next, inverted, layouts: {screen}}) => {
|
|
|
|
|
const progress = Animated.add(
|
|
|
|
|
current.progress.interpolate({
|
|
|
|
|
inputRange: [0, 1],
|
|
|
|
|
outputRange: [0, 1],
|
|
|
|
|
extrapolate: 'clamp',
|
|
|
|
|
}),
|
|
|
|
|
next
|
|
|
|
|
? next.progress.interpolate({
|
|
|
|
|
inputRange: [0, 1],
|
|
|
|
|
outputRange: [0, 1],
|
|
|
|
|
extrapolate: 'clamp',
|
|
|
|
|
})
|
|
|
|
|
: 0,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
cardStyle: {
|
|
|
|
|
transform: [
|
|
|
|
|
{
|
|
|
|
|
translateX: Animated.multiply(
|
|
|
|
|
progress.interpolate({
|
|
|
|
|
inputRange: [0, 1, 2],
|
|
|
|
|
outputRange: [
|
|
|
|
|
screen.width, // Focused, but offscreen in the beginning
|
|
|
|
|
0, // Fully focused
|
|
|
|
|
screen.width * -0.3, // Fully unfocused
|
|
|
|
|
],
|
|
|
|
|
extrapolate: 'clamp',
|
|
|
|
|
}),
|
|
|
|
|
inverted,
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-14 10:04:11 +05:00
|
|
|
export const NavigatorStack = React.memo(
|
|
|
|
|
() => {
|
|
|
|
|
const [state] = useTracked();
|
|
|
|
|
const {settings} = state;
|
2020-11-02 20:43:52 +05:00
|
|
|
|
2020-11-14 10:04:11 +05:00
|
|
|
React.useEffect(() => {
|
|
|
|
|
console.log("rerendering navigator stack");
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Container root={true}>
|
|
|
|
|
<NavigationContainer independent={true} ref={rootNavigatorRef}>
|
|
|
|
|
<Stack.Navigator
|
|
|
|
|
initialRouteName={settings.homepage}
|
|
|
|
|
screenOptions={{
|
|
|
|
|
headerShown: false,
|
|
|
|
|
cardStyleInterpolator: forFade,
|
|
|
|
|
}}>
|
|
|
|
|
<Stack.Screen name="Notes" component={Home} />
|
|
|
|
|
<Stack.Screen
|
|
|
|
|
initialParams={{
|
|
|
|
|
title: 'Notebooks',
|
|
|
|
|
canGoBack: false,
|
|
|
|
|
root: true,
|
|
|
|
|
}}
|
|
|
|
|
name="Notebooks"
|
|
|
|
|
component={Folders}
|
|
|
|
|
/>
|
|
|
|
|
<Stack.Screen name="Favorites" component={Favorites} />
|
|
|
|
|
<Stack.Screen name="Trash" component={Trash} />
|
|
|
|
|
<Stack.Screen name="NotesPage" component={Notes} />
|
|
|
|
|
<Stack.Screen name="Tags" component={Tags} />
|
|
|
|
|
<Stack.Screen name="Notebook" component={Notebook} />
|
|
|
|
|
<Stack.Screen name="Settings" component={Settings} />
|
|
|
|
|
<Stack.Screen name="Search" component={Search} />
|
|
|
|
|
</Stack.Navigator>
|
|
|
|
|
</NavigationContainer>
|
|
|
|
|
</Container>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
() => true,
|
|
|
|
|
);
|