Skip to content

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

remove extra view wrapping

ammarahm-ed539ba6c5807c
diff --git a/apps/mobile/src/views/Editor/EditorWrapper.js b/apps/mobile/src/views/Editor/EditorWrapper.js
index acd4194f2..ef052bd71 100644
--- a/apps/mobile/src/views/Editor/EditorWrapper.js
+++ b/apps/mobile/src/views/Editor/EditorWrapper.js
@@ -1,5 +1,5 @@
import React from 'react';
-import {View} from 'react-native';
+import {KeyboardAvoidingView, Platform, SafeAreaView, View} from 'react-native';
import {PanGestureHandler, State} from 'react-native-gesture-handler';
import Animated, {Easing} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
@@ -8,7 +8,7 @@ import {useTracked} from '../../provider';
import {eSendEvent} from '../../services/EventManager';
import {eOnLoadNote} from '../../utils/Events';
import Editor from './index';
-
+import {editorRef} from "../../utils/Refs"
let prevVal = 0;
let finalValue = 80;
let anim2 = new Animated.Value(0);
@@ -76,16 +76,20 @@ function opacityAnim(a, b, c) {
}).start();
}
-export const EditorWrapper = () => {
+const AnimatedKeyboardView = Animated.createAnimatedComponent(KeyboardAvoidingView)
+
+export const EditorWrapper = ({dimensions}) => {
const [state] = useTracked();
const {colors} = state;
const insets = useSafeAreaInsets();
return (
- <View
+ <SafeAreaView
+ ref={editorRef}
style={{
- width: '100%',
+ width: dimensions.width * 0.55,
height: '100%',
+ backgroundColor: colors.bg,
}}>
<View
style={{
@@ -93,7 +97,7 @@ export const EditorWrapper = () => {
zIndex: 20,
height: insets.top,
top: 0,
- width: '100%',
+ width: dimensions.width,
backgroundColor: colors.bg,
}}
/>
@@ -101,7 +105,8 @@ export const EditorWrapper = () => {
minPointers={2}
onHandlerStateChange={onHandlerStateChange}
onGestureEvent={onGestureEvent}>
- <Animated.View
+ <AnimatedKeyboardView
+ behavior={Platform.OS === 'ios' ? 'padding' : null}
style={{
transform: [
{
@@ -154,15 +159,9 @@ export const EditorWrapper = () => {
</Animated.Text>
</View>
- <View
- style={{
- height: '100%',
- width: '100%',
- }}>
- <Editor noMenu={false} />
- </View>
- </Animated.View>
+ <Editor/>
+ </AnimatedKeyboardView>
</PanGestureHandler>
- </View>
+ </SafeAreaView>
);
};
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index fb05acaa5..14b8a27f7 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -1,106 +1,83 @@
-import React, {createRef} from 'react';
+import React from 'react';
import {
KeyboardAvoidingView,
Platform,
SafeAreaView,
- StatusBar,
TextInput,
View,
} from 'react-native';
import WebView from 'react-native-webview';
import {useTracked} from '../../provider';
+import EditorHeader from './EditorHeader';
import {
- _onMessage,
- _onShouldStartLoadWithRequest,
EditorWebView,
injectedJS,
onWebViewLoad,
sourceUri,
textInput,
+ _onMessage,
+ _onShouldStartLoadWithRequest,
} from './Functions';
-import {DDS} from '../../services/DeviceDetection';
-import EditorHeader from './EditorHeader';
-const Editor = ({noMenu}) => {
+const Editor = () => {
const [state] = useTracked();
const {colors, premiumUser} = state;
return (
- <SafeAreaView
- style={{
- flex: 1,
- backgroundColor:
- DDS.isTab && !DDS.isSmallTab ? 'transparent' : colors.bg,
- height: '100%',
- width: '100%',
- flexDirection: 'row',
- justifyContent: 'space-between',
- }}>
+ <>
<TextInput
ref={textInput}
style={{height: 1, padding: 0, width: 1, position: 'absolute'}}
blurOnSubmit={false}
/>
- <KeyboardAvoidingView
- behavior={Platform.OS === 'ios' ? 'padding' : null}
+ <EditorHeader />
+ <WebView
+ testID="editor"
+ ref={EditorWebView}
+ onError={(error) => console.log(error)}
+ onLoad={async () => await onWebViewLoad(premiumUser, colors)}
+ javaScriptEnabled={true}
+ focusable={true}
+ keyboardDisplayRequiresUserAction={false}
+ injectedJavaScript={Platform.OS === 'ios' ? injectedJS : null}
+ onShouldStartLoadWithRequest={_onShouldStartLoadWithRequest}
+ renderLoading={() => (
+ <View
+ style={{
+ width: '100%',
+ height: '100%',
+ backgroundColor: 'transparent',
+ }}
+ />
+ )}
+ cacheMode="LOAD_DEFAULT"
+ cacheEnabled={false}
+ domStorageEnabled={true}
+ scrollEnabled={false}
+ bounces={false}
+ allowFileAccess={true}
+ scalesPageToFit={true}
+ allowingReadAccessToURL={Platform.OS === 'android' ? true : null}
+ allowFileAccessFromFileURLs={true}
+ allowUniversalAccessFromFileURLs={true}
+ originWhitelist={['*']}
+ source={
+ Platform.OS === 'ios'
+ ? {uri: sourceUri}
+ : {
+ uri: 'file:///android_asset/texteditor.html',
+ baseUrl: 'file:///android_asset/',
+ }
+ }
style={{
height: '100%',
+ maxHeight: '100%',
width: '100%',
- }}>
- <EditorHeader noMenu={noMenu} />
- <WebView
- testID="editor"
- ref={EditorWebView}
- onError={(error) => console.log(error)}
- onLoad={async () => await onWebViewLoad(noMenu, premiumUser, colors)}
- javaScriptEnabled={true}
- focusable={true}
- keyboardDisplayRequiresUserAction={false}
- injectedJavaScript={Platform.OS === 'ios' ? injectedJS : null}
- onShouldStartLoadWithRequest={_onShouldStartLoadWithRequest}
- renderLoading={() => (
- <View
- style={{
- width: '100%',
- height: '100%',
- backgroundColor: 'transparent',
- }}
- />
- )}
- cacheMode="LOAD_DEFAULT"
- cacheEnabled={false}
- domStorageEnabled={true}
- scrollEnabled={false}
- bounces={false}
- allowFileAccess={true}
- scalesPageToFit={true}
- allowingReadAccessToURL={Platform.OS === 'android' ? true : null}
- allowFileAccessFromFileURLs={true}
- allowUniversalAccessFromFileURLs={true}
- originWhitelist={['*']}
- source={
- Platform.OS === 'ios'
- ? {uri: sourceUri}
- : {
- uri: 'file:///android_asset/texteditor.html',
- baseUrl: 'file:///android_asset/',
- }
- }
- style={{
- height: '100%',
- maxHeight: '100%',
- width: '100%',
- backgroundColor: 'transparent',
- marginTop:
- DDS.isTab && !DDS.isSmallTab
- ? Platform.OS === 'ios'
- ? 0
- : StatusBar.currentHeight
- : 0,
- }}
- onMessage={_onMessage}
- />
- </KeyboardAvoidingView>
- </SafeAreaView>
+ alignSelf: 'center',
+ backgroundColor: 'transparent',
+ }}
+ onMessage={_onMessage}
+ />
+ </>
);
};