mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
upgrade MoveNote Navigator
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
import "react-native-gesture-handler";
|
import "react-native-gesture-handler";
|
||||||
import 'react-native-get-random-values'
|
import 'react-native-get-random-values'
|
||||||
import { enableScreens } from 'react-native-screens';
|
|
||||||
import { AppRegistry } from 'react-native';
|
import { AppRegistry } from 'react-native';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import { name as appName } from './app.json';
|
import { name as appName } from './app.json';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Provider } from './src/provider';
|
import { Provider } from './src/provider';
|
||||||
enableScreens();
|
|
||||||
|
|
||||||
const AppProvider = () => {
|
const AppProvider = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export const Container = ({
|
|||||||
noSelectionHeader = false,
|
noSelectionHeader = false,
|
||||||
headerColor = null,
|
headerColor = null,
|
||||||
type = null,
|
type = null,
|
||||||
|
route
|
||||||
}) => {
|
}) => {
|
||||||
// State
|
// State
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
@@ -210,6 +211,7 @@ export const Container = ({
|
|||||||
countUp = 0;
|
countUp = 0;
|
||||||
countDown = 0;
|
countDown = 0;
|
||||||
}}
|
}}
|
||||||
|
route={route}
|
||||||
headerColor={headerColor}
|
headerColor={headerColor}
|
||||||
navigation={navigation}
|
navigation={navigation}
|
||||||
colors={colors}
|
colors={colors}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import MergeEditor from '../MergeEditor';
|
|||||||
import { VaultDialog } from '../VaultDialog';
|
import { VaultDialog } from '../VaultDialog';
|
||||||
import { moveNoteEvent } from './recievers';
|
import { moveNoteEvent } from './recievers';
|
||||||
import { TEMPLATE_DELETE, TEMPLATE_PERMANANT_DELETE } from './templates';
|
import { TEMPLATE_DELETE, TEMPLATE_PERMANANT_DELETE } from './templates';
|
||||||
|
import MoveNoteDialog from '../MoveNoteDialog';
|
||||||
|
|
||||||
export class DialogManager extends Component {
|
export class DialogManager extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -287,11 +288,11 @@ export class DialogManager extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<VaultDialog colors={colors} />
|
<VaultDialog colors={colors} />
|
||||||
{/*
|
|
||||||
<MoveNoteDialog
|
<MoveNoteDialog
|
||||||
ref={ref => (this.moveNoteDialog = ref)}
|
ref={ref => (this.moveNoteDialog = ref)}
|
||||||
colors={colors}
|
colors={colors}
|
||||||
/> */}
|
/>
|
||||||
|
|
||||||
<AddTopicDialog
|
<AddTopicDialog
|
||||||
ref={ref => (this.addTopicsDialog = ref)}
|
ref={ref => (this.addTopicsDialog = ref)}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
/* import React from 'react';
|
import React, {createRef} from 'react';
|
||||||
import {Modal, TouchableOpacity, View} from 'react-native';
|
import {Modal, TouchableOpacity, View} from 'react-native';
|
||||||
import * as Animatable from 'react-native-animatable';
|
import * as Animatable from 'react-native-animatable';
|
||||||
import {createAppContainer} from 'react-navigation';
|
|
||||||
import {createStackNavigator} from 'react-navigation-stack';
|
|
||||||
import {ACTIONS} from '../../provider/actions';
|
import {ACTIONS} from '../../provider/actions';
|
||||||
import {eSendEvent} from '../../services/eventManager';
|
import {eSendEvent} from '../../services/eventManager';
|
||||||
import {eMoveNoteDialogNavigateBack} from '../../services/events';
|
import {eMoveNoteDialogNavigateBack} from '../../services/events';
|
||||||
@@ -11,69 +9,45 @@ import Folders from '../../views/Folders';
|
|||||||
import Notebook from '../../views/Notebook';
|
import Notebook from '../../views/Notebook';
|
||||||
import Notes from '../../views/Notes';
|
import Notes from '../../views/Notes';
|
||||||
import {updateEvent} from '../DialogManager/recievers';
|
import {updateEvent} from '../DialogManager/recievers';
|
||||||
|
import {NavigationContainer} from '@react-navigation/native';
|
||||||
|
import {createStackNavigator} from '@react-navigation/stack';
|
||||||
|
|
||||||
const fade = props => {
|
const Stack = createStackNavigator();
|
||||||
const {position, scene} = props;
|
const modalNavigatorRef = createRef();
|
||||||
|
const ModalNavigator = () => {
|
||||||
const index = scene.index;
|
return (
|
||||||
|
<NavigationContainer independent={true} ref={modalNavigatorRef}>
|
||||||
const translateX = 0;
|
<Stack.Navigator
|
||||||
const translateY = 0;
|
initialRouteName="Folders"
|
||||||
|
screenOptions={{
|
||||||
const opacity = position.interpolate({
|
headerShown: false,
|
||||||
inputRange: [index - 0.7, index, index + 0.7],
|
animationEnabled: false,
|
||||||
outputRange: [0.3, 1, 0.3],
|
gestureEnabled: false,
|
||||||
});
|
cardOverlayEnabled: false,
|
||||||
|
cardShadowEnabled: false,
|
||||||
return {
|
}}>
|
||||||
opacity,
|
<Stack.Screen
|
||||||
transform: [{translateX}, {translateY}],
|
name="Folders"
|
||||||
};
|
component={Folders}
|
||||||
|
initialParams={{
|
||||||
|
title: 'Select Notebook',
|
||||||
|
isMove: true,
|
||||||
|
hideMore: true,
|
||||||
|
canGoBack: true,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Stack.Screen name="Notes" component={Notes} />
|
||||||
|
<Stack.Screen name="Notebook" component={Notebook} />
|
||||||
|
</Stack.Navigator>
|
||||||
|
</NavigationContainer>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ModalNavigator = createStackNavigator(
|
|
||||||
{
|
|
||||||
Folders: {
|
|
||||||
screen: Folders,
|
|
||||||
},
|
|
||||||
Notebook: {
|
|
||||||
screen: Notebook,
|
|
||||||
},
|
|
||||||
Notes: {
|
|
||||||
screen: Notes,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
initialRouteName: 'Folders',
|
|
||||||
initialRouteParams: {
|
|
||||||
title: 'Select Notebook',
|
|
||||||
isMove: true,
|
|
||||||
hideMore: true,
|
|
||||||
canGoBack: true,
|
|
||||||
},
|
|
||||||
defaultNavigationOptions: {
|
|
||||||
gesturesEnabled: false,
|
|
||||||
headerStyle: {
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
borderBottomWidth: 0,
|
|
||||||
height: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
transitionConfig: () => ({
|
|
||||||
screenInterpolator: props => {
|
|
||||||
return fade(props);
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const Navigator = createAppContainer(ModalNavigator);
|
|
||||||
|
|
||||||
class MoveNoteDialog extends React.Component {
|
class MoveNoteDialog extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
visible: false,
|
visible: true,
|
||||||
animated: false,
|
animated: false,
|
||||||
};
|
};
|
||||||
this.routeIndex = 0;
|
this.routeIndex = 0;
|
||||||
@@ -161,12 +135,7 @@ class MoveNoteDialog extends React.Component {
|
|||||||
padding: DDS.isTab ? 8 : 0,
|
padding: DDS.isTab ? 8 : 0,
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
}}>
|
}}>
|
||||||
<Navigator
|
<ModalNavigator />
|
||||||
ref={ref => (this.navigation = ref)}
|
|
||||||
onNavigationStateChange={state => {
|
|
||||||
this.routeIndex = state.index;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
</Animatable.View>
|
</Animatable.View>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -175,4 +144,3 @@ class MoveNoteDialog extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default MoveNoteDialog;
|
export default MoveNoteDialog;
|
||||||
*/
|
|
||||||
@@ -32,6 +32,7 @@ export const Header = ({
|
|||||||
navigation = null,
|
navigation = null,
|
||||||
isLoginNavigator,
|
isLoginNavigator,
|
||||||
headerColor,
|
headerColor,
|
||||||
|
route,
|
||||||
}) => {
|
}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {colors, syncing} = state;
|
const {colors, syncing} = state;
|
||||||
@@ -94,13 +95,13 @@ export const Header = ({
|
|||||||
hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}
|
hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (navigation && preventDefaultMargins) {
|
if (navigation && preventDefaultMargins) {
|
||||||
if (navigation.state.routeName === 'Folders') {
|
if (route.name === 'Folders') {
|
||||||
moveNoteHideEvent();
|
moveNoteHideEvent();
|
||||||
} else {
|
} else {
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
}
|
}
|
||||||
} else if (navigation && isLoginNavigator) {
|
} else if (navigation && isLoginNavigator) {
|
||||||
if (navigation.state.routeName === 'Login') {
|
if (route.name === 'Login') {
|
||||||
eSendEvent(eCloseLoginDialog);
|
eSendEvent(eCloseLoginDialog);
|
||||||
} else {
|
} else {
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export const Folders = ({route, navigation}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
if (isFocused) {
|
if (isFocused) {
|
||||||
dispatch({type: ACTIONS.PINNED});
|
dispatch({type: ACTIONS.PINNED});
|
||||||
dispatch({type: ACTIONS.NOTEBOOKS});
|
dispatch({type: ACTIONS.NOTEBOOKS});
|
||||||
@@ -68,6 +69,7 @@ export const Folders = ({route, navigation}) => {
|
|||||||
<NotebookItem
|
<NotebookItem
|
||||||
hideMore={params.hideMore}
|
hideMore={params.hideMore}
|
||||||
navigation={navigation}
|
navigation={navigation}
|
||||||
|
route={route}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
width: selectionMode ? w - 74 : '100%',
|
width: selectionMode ? w - 74 : '100%',
|
||||||
marginHorizontal: 0,
|
marginHorizontal: 0,
|
||||||
@@ -97,10 +99,11 @@ export const Folders = ({route, navigation}) => {
|
|||||||
return (
|
return (
|
||||||
<Container
|
<Container
|
||||||
bottomButtonText="Create a new notebook"
|
bottomButtonText="Create a new notebook"
|
||||||
menu={params.canGoBack ? false : true}
|
menu={route.params.canGoBack ? false : true}
|
||||||
preventDefaultMargins={preventDefaultMargins}
|
preventDefaultMargins={preventDefaultMargins}
|
||||||
heading={params.title}
|
heading={params.title}
|
||||||
canGoBack={params.canGoBack}
|
canGoBack={params.canGoBack}
|
||||||
|
route={route}
|
||||||
navigation={navigation}
|
navigation={navigation}
|
||||||
placeholder="Search all notebooks"
|
placeholder="Search all notebooks"
|
||||||
data={notebooks}
|
data={notebooks}
|
||||||
|
|||||||
Reference in New Issue
Block a user