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) { if (getNote()?.locked) {
eSendEvent(eClearEditor); eSendEvent(eClearEditor);
} }
eSendEvent("showTooltip");
editing.movedAway = true; editing.movedAway = true;
tiny.call(EditorWebView, tiny.blur); tiny.call(EditorWebView, tiny.blur);
} }

View File

@@ -32,6 +32,7 @@ import {
} from './Functions'; } from './Functions';
import HistoryComponent from './HistoryComponent'; import HistoryComponent from './HistoryComponent';
import tiny from './tiny/tiny'; import tiny from './tiny/tiny';
import { toolbarRef } from './tiny/toolbar/constants';
let handleBack; let handleBack;
let tapCount = 0; let tapCount = 0;
@@ -46,23 +47,12 @@ const EditorHeader = () => {
}, [colors.bg]); }, [colors.bg]);
const _onBackPress = async () => { const _onBackPress = async () => {
if (sideMenuRef.current === null) { eSendEvent("showTooltip");
if (tapCount > 0) { toolbarRef.current?.scrollTo({
tapCount = 0; x:0,
setIntent(false); y:0,
editing.currentlyEditing = false; animated: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;
}
editing.isFocused = false; editing.isFocused = false;
editing.currentlyEditing = false; editing.currentlyEditing = false;
if (DDS.isLargeTablet()) { if (DDS.isLargeTablet()) {

View File

@@ -28,6 +28,7 @@ import {
saveNote, saveNote,
setIntent, setIntent,
} from './Functions'; } from './Functions';
import { toolbarRef } from './tiny/toolbar/constants';
let handleBack; let handleBack;
let tapCount = 0; let tapCount = 0;
@@ -95,23 +96,12 @@ const EditorRoot = () => {
}; };
const _onBackPress = async () => { const _onBackPress = async () => {
if (sideMenuRef.current === null) { eSendEvent("showTooltip");
if (tapCount > 0) { toolbarRef.current?.scrollTo({
tapCount = 0; x:0,
setIntent(false); y:0,
editing.currentlyEditing = false; animated: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;
}
editing.currentlyEditing = false; editing.currentlyEditing = false;
if (DDS.isLargeTablet()) { if (DDS.isLargeTablet()) {
if (fullscreen) { if (fullscreen) {

View File

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

View File

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