Skip to content

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

show tooltip in search/replace

ammarahm-ed0262f6e1e751
diff --git a/apps/mobile/src/services/tipmanager.ts b/apps/mobile/src/services/tipmanager.ts
index 5726a5c79..163210513 100644
--- a/apps/mobile/src/services/tipmanager.ts
+++ b/apps/mobile/src/services/tipmanager.ts
@@ -69,6 +69,10 @@ const popups: Popup[] = [
{
id: 'compactmode',
text: 'Try compact mode to fit more items on screen'
+ },
+ {
+ id: 'searchreplace',
+ text: 'Switch to search/replace mode'
}
];
const destructiveContexts = ['first-note'];
diff --git a/apps/mobile/src/utils/useTooltip.ts b/apps/mobile/src/utils/useTooltip.ts
index caa1c0654..7dba81eb9 100644
--- a/apps/mobile/src/utils/useTooltip.ts
+++ b/apps/mobile/src/utils/useTooltip.ts
@@ -3,6 +3,7 @@ import { RefObject, useEffect, useRef } from 'react';
import RNTooltips from 'react-native-tooltips';
import { useTracked } from '../provider';
import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../services/EventManager';
+import { useKeyboard } from './use-keyboard';
let currentTargets: number[] = [];
@@ -21,6 +22,11 @@ const useTooltip = () => {
const [state, dispatch] = useTracked();
const { colors } = state;
const parent = useRef();
+ let keyboard = useKeyboard();
+
+ useEffect(() => {
+ hideAllTooltips();
+ }, [keyboard.keyboardShown]);
const positions = {
left: 1,
@@ -53,7 +59,7 @@ const useTooltip = () => {
return { parent, show };
};
-type TTooltipIdentifiers = 'sectionheader';
+type TTooltipIdentifiers = 'sectionheader' | 'searchreplace';
export const useTooltipHandler = (id: TTooltipIdentifiers, callback: () => void) => {
useEffect(() => {
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/searchreplace.js b/apps/mobile/src/views/Editor/tiny/toolbar/searchreplace.js
index a9f0c9cdf..6aa88e94b 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/searchreplace.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/searchreplace.js
@@ -4,9 +4,12 @@ import { Button } from '../../../../components/Button';
import Input from '../../../../components/Input';
import { useTracked } from '../../../../provider';
import { useEditorStore, useSettingStore } from '../../../../provider/stores';
+import { TipManager } from '../../../../services/tip-manager';
import { showTooltip, TOOLTIP_POSITIONS } from '../../../../utils';
import layoutmanager from '../../../../utils/layout-manager';
import { SIZE } from '../../../../utils/SizeUtils';
+import { useKeyboard } from '../../../../utils/use-keyboard';
+import useTooltip, { hideAllTooltips, useTooltipHandler } from '../../../../utils/use-tooltip';
import { EditorWebView } from '../../Functions';
import tiny from '../tiny';
import { endSearch } from './commands';
@@ -29,6 +32,16 @@ const SearcReplace = () => {
find: null,
replace: null
});
+ const switchModeRef = useRef();
+ const tooltip = useTooltip();
+
+ useTooltipHandler('searchreplace', () => {
+ let popup = TipManager.popup('searchreplace');
+ console.log('showing:', popup);
+ if (popup) {
+ tooltip.show(switchModeRef, popup.text, 'top');
+ }
+ });
async function searchWithSelection() {
values.current.find = searchSelection;
@@ -45,6 +58,7 @@ const SearcReplace = () => {
useEffect(() => {
setTimeout(() => {
findRef.current?.focus();
+ setTimeout(() => useTooltip.present('searchreplace'), 1000);
}, 300);
}, []);
@@ -176,6 +190,7 @@ const SearcReplace = () => {
return (
<View
+ ref={tooltip.parent}
style={{
width: '100%',
backgroundColor: colors.bg,
@@ -192,11 +207,12 @@ const SearcReplace = () => {
<Button
height="93%"
iconSize={SIZE.md + 4}
- icon={enableReplace ? 'chevron-down' : 'chevron-right'}
+ icon={enableReplace ? 'chevron-down' : 'find-replace'}
style={{
paddingHorizontal: 3,
marginBottom: 10
}}
+ fwdRef={switchModeRef}
iconColor={enableReplace ? colors.accent : colors.icon}
onPress={() => {
layoutmanager.withSpringAnimation(500);