Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

upgrade login dialog navigator

ammarahm-ed18027590cf42
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index 84c33f3de..19089659a 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -13,6 +13,7 @@ import { VaultDialog } from '../VaultDialog';
import { moveNoteEvent } from './recievers';
import { TEMPLATE_DELETE, TEMPLATE_PERMANANT_DELETE } from './templates';
import MoveNoteDialog from '../MoveNoteDialog';
+import LoginDialog from '../LoginDialog';
export class DialogManager extends Component {
constructor(props) {
@@ -310,7 +311,7 @@ export class DialogManager extends Component {
colors={colors}
/>
- {/* <LoginDialog colors={colors} ref={ref => (this.loginDialog = ref)} /> */}
+ <LoginDialog colors={colors} ref={ref => (this.loginDialog = ref)} />
<MergeEditor />
</>
diff --git a/apps/mobile/src/components/LoginDialog/index.js b/apps/mobile/src/components/LoginDialog/index.js
index 5e939c315..54b87427c 100644
--- a/apps/mobile/src/components/LoginDialog/index.js
+++ b/apps/mobile/src/components/LoginDialog/index.js
@@ -1,8 +1,6 @@
-/* import React from 'react';
+import React, { createRef } from 'react';
import {Modal, TouchableOpacity, View} from 'react-native';
import * as Animatable from 'react-native-animatable';
-import {createAppContainer} from 'react-navigation';
-import {createStackNavigator} from 'react-navigation-stack';
import {normalize} from '../../common/common';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
@@ -12,58 +10,32 @@ import ForgotPassword from '../../views/ForgotPassword';
import Login from '../../views/Login';
import Signup from '../../views/Signup';
import {updateEvent} from '../DialogManager/recievers';
+import {NavigationContainer} from '@react-navigation/native';
+import {createStackNavigator} from '@react-navigation/stack';
-const fade = props => {
- const {position, scene} = props;
+const Stack = createStackNavigator();
- const index = scene.index;
-
- const translateX = 0;
- const translateY = 0;
-
- const opacity = position.interpolate({
- inputRange: [index - 0.7, index, index + 0.7],
- outputRange: [0.7, 1, 0.7],
- });
-
- return {
- opacity,
- transform: [{translateX}, {translateY}],
- };
+const modalNavigatorRef2 = createRef();
+const ModalNavigator = () => {
+ return (
+ <NavigationContainer independent={true} ref={modalNavigatorRef2}>
+ <Stack.Navigator
+ initialRouteName="Login"
+ screenOptions={{
+ headerShown: false,
+ animationEnabled: false,
+ gestureEnabled: false,
+ cardOverlayEnabled: false,
+ cardShadowEnabled: false,
+ }}>
+ <Stack.Screen name="Login" component={Login} />
+ <Stack.Screen name="Signup" component={Signup} />
+ <Stack.Screen name="ForgotPassword" component={ForgotPassword} />
+ </Stack.Navigator>
+ </NavigationContainer>
+ );
};
-const ModalNavigator = createStackNavigator(
- {
- Login: {
- screen: Login,
- },
- Signup: {
- screen: Signup,
- },
- ForgotPassword: {
- screen: ForgotPassword,
- },
- },
- {
- initialRouteName: 'Login',
- defaultNavigationOptions: {
- gesturesEnabled: false,
- headerStyle: {
- backgroundColor: 'transparent',
- borderBottomWidth: 0,
- height: 0,
- },
- },
- transitionConfig: () => ({
- screenInterpolator: props => {
- return fade(props);
- },
- }),
- },
-);
-
-const Navigator = createAppContainer(ModalNavigator);
-
class LoginDialog extends React.Component {
constructor(props) {
super(props);
@@ -155,12 +127,7 @@ class LoginDialog extends React.Component {
paddingVertical: 16,
zIndex: 10,
}}>
- <Navigator
- ref={ref => (this.navigation = ref)}
- onNavigationStateChange={state => {
- this.routeIndex = state.index;
- }}
- />
+ <ModalNavigator />
</View>
</Animatable.View>
</Modal>
@@ -169,4 +136,3 @@ class LoginDialog extends React.Component {
}
export default LoginDialog;
- */
\ No newline at end of file
diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js
index fd747259d..e0e3f5e10 100644
--- a/apps/mobile/src/components/MoveNoteDialog/index.js
+++ b/apps/mobile/src/components/MoveNoteDialog/index.js
@@ -47,7 +47,7 @@ class MoveNoteDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
- visible: true,
+ visible: false,
animated: false,
};
this.routeIndex = 0;
diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js
index 27d682330..24cf79093 100644
--- a/apps/mobile/src/views/Login/index.js
+++ b/apps/mobile/src/views/Login/index.js
@@ -17,11 +17,9 @@ import {eSendEvent} from '../../services/eventManager';
import {eCloseSideMenu, refreshNotesPage} from '../../services/events';
import {validatePass, validateUsername} from '../../services/validation';
import {db, DDS, ToastEvent, getElevation} from '../../utils/utils';
-import { useIsFocused } from '@react-navigation/native';
+import {useIsFocused} from '@react-navigation/native';
-
-
-export const Login = ({navigation}) => {
+export const Login = ({route, navigation}) => {
const [state, dispatch] = useTracked();
const {colors, isLoginNavigator} = state;
const [status, setStatus] = useState('Logging in...');
@@ -105,7 +103,9 @@ export const Login = ({navigation}) => {
console.log('user', user);
dispatch({type: ACTIONS.USER, user: user});
ToastEvent.show(`Logged in as ${username}`, 'success');
+
navigation.goBack();
+
await db.sync();
eSendEvent(refreshNotesPage);
dispatch({type: ACTIONS.ALL});
@@ -159,6 +159,7 @@ export const Login = ({navigation}) => {
<>
<Header
navigation={navigation}
+ route={route}
isLoginNavigator={isLoginNavigator}
colors={colors}
heading="Login"
@@ -377,7 +378,7 @@ export const Login = ({navigation}) => {
</Text>
<View
- ref={_passContainer}
+ ref={_passContainer}
style={{
borderWidth: 1.5,
borderColor: colors.nav,
@@ -385,7 +386,7 @@ export const Login = ({navigation}) => {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
- paddingHorizontal:10,
+ paddingHorizontal: 10,
marginHorizontal: 12,
}}>
<TextInput
@@ -407,15 +408,12 @@ export const Login = ({navigation}) => {
style: {
color: colors.errorText,
},
-
});
_passContainer.current?.setNativeProps({
style: {
borderColor: colors.errorText,
},
});
-
-
} else {
setInvalidPassword(false);
_passContainer.current?.setNativeProps({
@@ -439,7 +437,6 @@ export const Login = ({navigation}) => {
borderColor: colors.accent,
},
});
-
}
}}
onSubmitEditing={() => {
@@ -453,8 +450,8 @@ export const Login = ({navigation}) => {
}
}}
style={{
- paddingVertical:pv,
- paddingHorizontal:0,
+ paddingVertical: pv,
+ paddingHorizontal: 0,
fontSize: SIZE.sm,
fontFamily: WEIGHT.regular,
width: '85%',
@@ -477,8 +474,6 @@ export const Login = ({navigation}) => {
color={secureEntry ? colors.icon : colors.accent}
/>
</View>
-
-
</View>
<TouchableOpacity
activeOpacity={opacity}
@@ -491,7 +486,6 @@ export const Login = ({navigation}) => {
marginHorizontal: 12,
marginBottom: 10,
alignItems: 'center',
-
}}>
<Text
style={{
diff --git a/apps/mobile/src/views/Signup/index.js b/apps/mobile/src/views/Signup/index.js
index 6be9030b5..e1ec08246 100644
--- a/apps/mobile/src/views/Signup/index.js
+++ b/apps/mobile/src/views/Signup/index.js
@@ -32,7 +32,7 @@ const _pass = createRef();
const _username = createRef();
const _passConfirm = createRef();
const _passContainer = createRef();
-export const Signup = ({navigation}) => {
+export const Signup = ({route,navigation}) => {
const [state, dispatch] = useTracked();
const {colors, isLoginNavigator} = state;
const [signingIn, setSigningIn] = useState(false);
@@ -285,6 +285,7 @@ export const Signup = ({navigation}) => {
isLoginNavigator={isLoginNavigator}
navigation={navigation}
colors={colors}
+ route={route}
heading="Create Account"
/>