Skip to content

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

refactor

ammarahm-edbe5a2a5c513b
diff --git a/apps/mobile/src/components/header/index.js b/apps/mobile/src/components/header/index.js
index 14837e53c..35441054a 100644
--- a/apps/mobile/src/components/header/index.js
+++ b/apps/mobile/src/components/header/index.js
@@ -1,5 +1,12 @@
import React from 'react';
-import {Platform, StatusBar, Text, TouchableOpacity, View} from 'react-native';
+import {
+ Platform,
+ StatusBar,
+ Text,
+ TouchableOpacity,
+ View,
+ DeviceEventEmitter,
+} from 'react-native';
import * as Animatable from 'react-native-animatable';
import Icon from 'react-native-vector-icons/Feather';
import {SIZE, WEIGHT} from '../../common/common';
@@ -19,6 +26,7 @@ export const Header = ({
sendHeight = e => {},
preventDefaultMargins,
navigation = null,
+ isLoginNavigator,
}) => {
const [state, dispatch] = useTracked();
const {colors} = state;
@@ -34,7 +42,7 @@ export const Header = ({
marginTop:
Platform.OS === 'ios'
? 0
- : preventDefaultMargins
+ : preventDefaultMargins || isLoginNavigator
? 0
: StatusBar.currentHeight,
marginBottom: 10,
@@ -59,6 +67,12 @@ export const Header = ({
} else {
navigation.goBack();
}
+ } else if (navigation && isLoginNavigator) {
+ if (navigation.state.routeName === 'Login') {
+ DeviceEventEmitter.emit('hideLoginDialog');
+ } else {
+ navigation.goBack();
+ }
} else {
NavigationService.goBack();
}
diff --git a/apps/mobile/src/provider/index.js b/apps/mobile/src/provider/index.js
index 19080be62..b74e8cc0c 100644
--- a/apps/mobile/src/provider/index.js
+++ b/apps/mobile/src/provider/index.js
@@ -34,6 +34,7 @@ const defaultState = {
warningText: '#9F6000',
},
preventDefaultMargins: false,
+ isLoginNavigator: false,
};
export const ACTIONS = {
@@ -48,6 +49,7 @@ export const ACTIONS = {
THEME: 'theme',
MODAL_NAVIGATOR: 'modalNavigator',
CLEAR_SELECTION: 'clearSelection',
+ LOGIN_NAVIGATOR: 'loginNavigator',
};
const reducer = (state, action) => {
@@ -129,6 +131,12 @@ const reducer = (state, action) => {
preventDefaultMargins: action.enabled,
};
}
+ case ACTIONS.LOGIN_NAVIGATOR: {
+ return {
+ ...state,
+ isLoginNavigator: action.enabled,
+ };
+ }
default:
throw new Error('unknown action type');
}
diff --git a/apps/mobile/src/services/NavigationService.js b/apps/mobile/src/services/NavigationService.js
index 34c1b56d2..21785b592 100755
--- a/apps/mobile/src/services/NavigationService.js
+++ b/apps/mobile/src/services/NavigationService.js
@@ -32,7 +32,7 @@ const fade = props => {
const opacity = position.interpolate({
inputRange: [index - 0.7, index, index + 0.7],
- outputRange: [0.3, 1, 0.3],
+ outputRange: [0.9, 1, 0.9],
});
return {
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index c0537b781..c32f2bd63 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -256,7 +256,9 @@ const Editor = ({navigation, noMenu}) => {
{noMenu ? null : (
<TouchableOpacity
onPress={() => {
- simpleDialogEvent(TEMPLATE_EXIT('Editor'));
+ DDS.isTab
+ ? simpleDialogEvent(TEMPLATE_EXIT_FULLSCREEN())
+ : simpleDialogEvent(TEMPLATE_EXIT('Editor'));
}}
style={{
width: 60,
@@ -282,51 +284,72 @@ const Editor = ({navigation, noMenu}) => {
</TouchableOpacity>
)}
- <TouchableOpacity
- onPress={() => {
- if (fullscreen) {
- DeviceEventEmitter.emit('closeFullScreenEditor');
- fullscreen = false;
- post(
- JSON.stringify({
- type: 'nomenu',
- value: true,
- }),
- );
- } else {
- DeviceEventEmitter.emit('showFullScreenEditor');
- fullscreen = true;
- post(
- JSON.stringify({
- type: 'nomenu',
- value: false,
- }),
- );
- }
-
- return;
- ActionSheetEvent(
- note,
- true,
- true,
- ['Add to', 'Share', 'Export', 'Delete'],
- ['Dark Mode', 'Add to Vault', 'Pin', 'Favorite'],
- );
- }}
+ <View
style={{
- width: 60,
- height: 50,
- justifyContent: 'center',
- alignItems: 'flex-end',
+ flexDirection: 'row',
+ marginRight: 0,
position: 'absolute',
+ marginTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
+ zIndex: 999,
right: 0,
top: 0,
- marginTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
- paddingRight: 12,
- zIndex: 800,
}}>
- <Icon name="more-horizontal" color={colors.icon} size={SIZE.xxxl} />
- </TouchableOpacity>
+ {DDS.isTab ? (
+ <TouchableOpacity
+ onPress={() => {
+ if (fullscreen) {
+ DeviceEventEmitter.emit('closeFullScreenEditor');
+ fullscreen = false;
+ post(
+ JSON.stringify({
+ type: 'nomenu',
+ value: true,
+ }),
+ );
+ } else {
+ DeviceEventEmitter.emit('showFullScreenEditor');
+ fullscreen = true;
+ post(
+ JSON.stringify({
+ type: 'nomenu',
+ value: false,
+ }),
+ );
+ }
+ }}
+ style={{
+ width: 60,
+ height: 50,
+ justifyContent: 'center',
+ alignItems: 'flex-end',
+ paddingRight: 12,
+ zIndex: 800,
+ }}>
+ <Icon name="square" color={colors.icon} size={SIZE.xxxl} />
+ </TouchableOpacity>
+ ) : null}
+ <TouchableOpacity
+ onPress={() => {
+ ActionSheetEvent(
+ note,
+ true,
+ true,
+ ['Add to', 'Share', 'Export', 'Delete'],
+ ['Dark Mode', 'Add to Vault', 'Pin', 'Favorite'],
+ );
+ }}
+ style={{
+ width: 60,
+ height: 50,
+ justifyContent: 'center',
+ alignItems: 'flex-end',
+
+ paddingRight: 12,
+ zIndex: 800,
+ }}>
+ <Icon name="more-horizontal" color={colors.icon} size={SIZE.xxxl} />
+ </TouchableOpacity>
+ </View>
<WebView
ref={ref => (EditorWebView = ref)}
@@ -334,7 +357,7 @@ const Editor = ({navigation, noMenu}) => {
onLoad={onWebViewLoad}
javaScriptEnabled
injectedJavaScript={Platform.OS === 'ios' ? injectedJS : null}
- //onShouldStartLoadWithRequest={_onShouldStartLoadWithRequest}
+ onShouldStartLoadWithRequest={_onShouldStartLoadWithRequest}
renderLoading={() => (
<View
style={{
@@ -354,9 +377,14 @@ const Editor = ({navigation, noMenu}) => {
allowFileAccessFromFileURLs={true}
allowUniversalAccessFromFileURLs={true}
originWhitelist={'*'}
- source={{
- uri: 'http://192.168.10.9:8080/texteditor.html',
- }}
+ source={
+ Platform.OS === 'ios'
+ ? sourceUri
+ : {
+ uri: 'file:///android_asset/texteditor.html',
+ baseUrl: 'file:///android_asset/',
+ }
+ }
style={{
height: '100%',
maxHeight: '100%',
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index b9974f021..7f9e02e29 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -31,17 +31,27 @@ export const Folders = ({navigation}) => {
///
const handleBackPress = () => {
+ alert('here');
return true;
};
useEffect(() => {
dispatch({type: ACTIONS.NOTEBOOKS});
- console.log(selectedItemsList[0]);
- let backhandler = BackHandler.addEventListener(
- 'hardwareBackPress',
- handleBackPress,
- );
+ let backhandler;
+ if (isFocused) {
+ backhandler = BackHandler.addEventListener(
+ 'hardwareBackPress',
+ handleBackPress,
+ );
+ } else {
+ if (backhandler) {
+ backhandler.remove();
+ backhandler = null;
+ }
+ }
+
return () => {
+ if (!backhandler) return;
backhandler.remove();
backhandler = null;
};