close tooltip and scroll toolbar to start on closing

This commit is contained in:
ammarahm-ed
2021-02-08 16:00:51 +05:00
parent 1885f940db
commit 87d5de6a09
5 changed files with 20 additions and 35 deletions

View File

@@ -57,6 +57,7 @@ const onChangeTab = async (obj) => {
if (getNote()?.locked) {
eSendEvent(eClearEditor);
}
eSendEvent("showTooltip");
editing.movedAway = true;
tiny.call(EditorWebView, tiny.blur);
}

View File

@@ -32,6 +32,7 @@ import {
} from './Functions';
import HistoryComponent from './HistoryComponent';
import tiny from './tiny/tiny';
import { toolbarRef } from './tiny/toolbar/constants';
let handleBack;
let tapCount = 0;
@@ -46,23 +47,12 @@ const EditorHeader = () => {
}, [colors.bg]);
const _onBackPress = async () => {
if (sideMenuRef.current === null) {
if (tapCount > 0) {
tapCount = 0;
setIntent(false);
editing.currentlyEditing = false;
await clearEditor();
RNExitApp.exitApp();
} else {
await saveNote();
tapCount = 1;
setTimeout(() => {
tapCount = 0;
}, 3000);
ToastEvent.show('Note saved, press back again to exit app.', 'success');
}
return true;
}
eSendEvent("showTooltip");
toolbarRef.current?.scrollTo({
x:0,
y:0,
animated:false
})
editing.isFocused = false;
editing.currentlyEditing = false;
if (DDS.isLargeTablet()) {

View File

@@ -28,6 +28,7 @@ import {
saveNote,
setIntent,
} from './Functions';
import { toolbarRef } from './tiny/toolbar/constants';
let handleBack;
let tapCount = 0;
@@ -95,23 +96,12 @@ const EditorRoot = () => {
};
const _onBackPress = async () => {
if (sideMenuRef.current === null) {
if (tapCount > 0) {
tapCount = 0;
setIntent(false);
editing.currentlyEditing = false;
await clearEditor();
RNExitApp.exitApp();
} else {
await saveNote();
tapCount = 1;
setTimeout(() => {
tapCount = 0;
}, 3000);
ToastEvent.show('Note saved, press back again to exit app.', 'success');
}
return true;
}
eSendEvent("showTooltip");
toolbarRef.current?.scrollTo({
x:0,
y:0,
animated:false
})
editing.currentlyEditing = false;
if (DDS.isLargeTablet()) {
if (fullscreen) {

View File

@@ -1,3 +1,4 @@
import { createRef } from 'react';
import {Platform} from 'react-native';
import { eSendEvent } from '../../../../services/EventManager';
import {EditorWebView} from '../../Functions';
@@ -10,6 +11,8 @@ export const properties = {
userBlur: false,
};
export const toolbarRef = createRef();
export function formatSelection(command) {
EditorWebView.current?.injectJavaScript(command);
}

View File

@@ -4,7 +4,7 @@ import {ScrollView} from 'react-native';
import {useTracked} from '../../../../provider';
import {eSendEvent} from '../../../../services/EventManager';
import {TOOLBAR_CONFIG} from './config';
import {properties} from './constants';
import {properties, toolbarRef} from './constants';
import ToolbarGroup from './group';
import Tooltip from './tooltip';
@@ -29,6 +29,7 @@ const EditorToolbar = React.memo(
}}>
<Tooltip />
<ScrollView
ref={toolbarRef}
style={{
width: '100%',
maxWidth: '100%',