Skip to content

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

fix keyboard avoiding view issue on ios

ammarahm-edb08b531aed00
diff --git a/apps/mobile/src/views/Editor/EditorWrapper.js b/apps/mobile/src/views/Editor/EditorWrapper.js
index e3f6417aa..db8f5ea8c 100644
--- a/apps/mobile/src/views/Editor/EditorWrapper.js
+++ b/apps/mobile/src/views/Editor/EditorWrapper.js
@@ -1,5 +1,11 @@
import React from 'react';
-import {TextInput, View} from 'react-native';
+import {
+ KeyboardAvoidingView,
+ LayoutAnimation,
+ Platform,
+ TextInput,
+ View
+} from 'react-native';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Editor from '.';
import {PremiumToast} from '../../components/Premium/premium-toast';
@@ -7,6 +13,7 @@ import {useTracked} from '../../provider';
import {useNoteStore, useSettingStore} from '../../provider/stores';
import {DDS} from '../../services/DeviceDetection';
import {editorRef} from '../../utils/Refs';
+import useIsFloatingKeyboard from '../../utils/use-is-floating-keyboard';
import EditorOverlay from './EditorOverlay';
import {textInput} from './Functions';
@@ -16,6 +23,7 @@ export const EditorWrapper = ({width, dimensions}) => {
const deviceMode = useSettingStore(state => state.deviceMode);
const loading = useNoteStore(state => state.loading);
const insets = useSafeAreaInsets();
+ const floating = useIsFloatingKeyboard();
return (
<View
@@ -26,18 +34,26 @@ export const EditorWrapper = ({width, dimensions}) => {
backgroundColor: state.colors.bg,
borderLeftWidth: 1,
borderLeftColor: DDS.isTab ? colors.nav : 'transparent',
- paddingTop:insets.top,
- paddingBottom:insets.bottom
+ paddingTop: Platform.OS === 'ios' ? insets.top : 0,
+ paddingBottom: Platform.OS === 'ios' ? insets.bottom : 0
}}>
- <PremiumToast key="toast" context="editor" offset={50 + insets.top} />
- <TextInput
- key="input"
- ref={textInput}
- style={{height: 1, padding: 0, width: 1, position: 'absolute'}}
- blurOnSubmit={false}
- />
- {loading ? null : <Editor key="editor" />}
- <EditorOverlay key="overlay" />
+ <KeyboardAvoidingView
+ behavior="padding"
+ style={{
+ width:'100%',
+ height:'100%'
+ }}
+ enabled={!floating && Platform.OS === 'ios'}>
+ <PremiumToast key="toast" context="editor" offset={50 + insets.top} />
+ <TextInput
+ key="input"
+ ref={textInput}
+ style={{height: 1, padding: 0, width: 1, position: 'absolute'}}
+ blurOnSubmit={false}
+ />
+ {loading ? null : <Editor key="editor" />}
+ <EditorOverlay key="overlay" />
+ </KeyboardAvoidingView>
</View>
);
};