fix tooltip on ios

This commit is contained in:
ammarahm-ed
2022-02-14 14:54:15 +05:00
parent 292a08b7e9
commit ad73bbbd29
8 changed files with 25779 additions and 2139 deletions

View File

@@ -4,7 +4,7 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
platform :ios, '11.0' platform :ios, '11.0'
pod 'Base64' pod 'Base64'
pod 'SexyTooltip',:git => 'https://github.com/prscX/SexyTooltip.git' pod 'SexyTooltip',:git => 'https://github.com/ammarahm-ed/SexyTooltip.git'
pod 'MMKV' pod 'MMKV'
target 'Notesnook' do target 'Notesnook' do

View File

@@ -453,7 +453,7 @@ DEPENDENCIES:
- RNSVG (from `../node_modules/react-native-svg`) - RNSVG (from `../node_modules/react-native-svg`)
- RNTooltips (from `../node_modules/react-native-tooltips`) - RNTooltips (from `../node_modules/react-native-tooltips`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`) - RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- SexyTooltip (from `https://github.com/prscX/SexyTooltip.git`) - SexyTooltip (from `https://github.com/ammarahm-ed/SexyTooltip.git`)
- "toolbar-android (from `../node_modules/@react-native-community/toolbar-android`)" - "toolbar-android (from `../node_modules/@react-native-community/toolbar-android`)"
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`) - Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
@@ -601,7 +601,7 @@ EXTERNAL SOURCES:
RNVectorIcons: RNVectorIcons:
:path: "../node_modules/react-native-vector-icons" :path: "../node_modules/react-native-vector-icons"
SexyTooltip: SexyTooltip:
:git: https://github.com/prscX/SexyTooltip.git :git: https://github.com/ammarahm-ed/SexyTooltip.git
toolbar-android: toolbar-android:
:path: "../node_modules/@react-native-community/toolbar-android" :path: "../node_modules/@react-native-community/toolbar-android"
Yoga: Yoga:
@@ -609,8 +609,8 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS: CHECKOUT OPTIONS:
SexyTooltip: SexyTooltip:
:commit: 2fbe10260fb1b0f7dcd9822681a6970ce88112af :commit: bb13cf11a7c19b635f10047fc04d857dd6cb6553
:git: https://github.com/prscX/SexyTooltip.git :git: https://github.com/ammarahm-ed/SexyTooltip.git
SPEC CHECKSUMS: SPEC CHECKSUMS:
Base64: cecfb41a004124895a7bcee567a89bae5a89d49b Base64: cecfb41a004124895a7bcee567a89bae5a89d49b
@@ -684,12 +684,12 @@ SPEC CHECKSUMS:
RNSecureRandom: 0dcee021fdb3d50cd5cee5db0ebf583c42f5af0e RNSecureRandom: 0dcee021fdb3d50cd5cee5db0ebf583c42f5af0e
RNShare: 3185c074441b7e8897014d95ba982434a0a024a1 RNShare: 3185c074441b7e8897014d95ba982434a0a024a1
RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
RNTooltips: 47a992eb7b12f624e5a8a40f0990fbef49dcb83e RNTooltips: 5424d4bf0b3d441104127943b1115cc7f0616b1f
RNVectorIcons: 4143ba35feebab8fdbe6bc43d1e776b393d47ac8 RNVectorIcons: 4143ba35feebab8fdbe6bc43d1e776b393d47ac8
SexyTooltip: 5c9b4dec52bfb317938cb0488efd9da3717bb6fd SexyTooltip: 5c9b4dec52bfb317938cb0488efd9da3717bb6fd
toolbar-android: 2a73856e98b750d7e71ce4644d3f41cc98211719 toolbar-android: 2a73856e98b750d7e71ce4644d3f41cc98211719
Yoga: 5cbf25add73edb290e1067017690f7ebf56c5468 Yoga: 5cbf25add73edb290e1067017690f7ebf56c5468
PODFILE CHECKSUM: 69a787dbce9f45b28a09e255a4ae39a9cfe82d20 PODFILE CHECKSUM: caa8e050bad1a0f4d452e7e74a6dc724578310b1
COCOAPODS: 1.11.2 COCOAPODS: 1.11.2

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { NativeModules, Platform, View } from 'react-native'; import { NativeModules, Platform, StatusBar, View } from 'react-native';
import RNBootSplash from 'react-native-bootsplash'; import RNBootSplash from 'react-native-bootsplash';
import { checkVersion } from 'react-native-check-version'; import { checkVersion } from 'react-native-check-version';
import { useTracked } from '../../provider'; import { useTracked } from '../../provider';
@@ -75,9 +75,13 @@ const AppLoader = ({ onLoad }) => {
await sleep(requireIntro.value ? 500 : 0); await sleep(requireIntro.value ? 500 : 0);
await RNBootSplash.hide({ fade: true }); await RNBootSplash.hide({ fade: true });
setTimeout(async () => { setTimeout(async () => {
NativeModules.RNBars.setStatusBarStyle(!colors.night ? 'light-content' : 'dark-content'); if (Platform.OS === 'android') {
await sleep(5); NativeModules.RNBars.setStatusBarStyle(!colors.night ? 'light-content' : 'dark-content');
NativeModules.RNBars.setStatusBarStyle(colors.night ? 'light-content' : 'dark-content'); await sleep(5);
NativeModules.RNBars.setStatusBarStyle(colors.night ? 'light-content' : 'dark-content');
} else {
StatusBar.setBarStyle(colors.night ? 'light-content' : 'dark-content');
}
}, 500); }, 500);
}; };

View File

@@ -1,6 +1,7 @@
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { View } from 'react-native'; import { View } from 'react-native';
import { SheetManager } from 'react-native-actions-sheet'; import { SheetManager } from 'react-native-actions-sheet';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useTracked } from '../../provider'; import { useTracked } from '../../provider';
import { useUserStore } from '../../provider/stores'; import { useUserStore } from '../../provider/stores';
import { DDS } from '../../services/DeviceDetection'; import { DDS } from '../../services/DeviceDetection';
@@ -34,6 +35,7 @@ export const Login = ({ changeMode }) => {
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const insets = useSafeAreaInsets();
const setUser = useUserStore(state => state.setUser); const setUser = useUserStore(state => state.setUser);
@@ -109,7 +111,7 @@ export const Login = ({ changeMode }) => {
position: 'absolute', position: 'absolute',
zIndex: 999, zIndex: 999,
left: 12, left: 12,
top: 12 top: 12 + insets.top
}} }}
/> />

View File

@@ -1,5 +1,6 @@
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import { View } from 'react-native'; import { Dimensions, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useTracked } from '../../provider'; import { useTracked } from '../../provider';
import { useUserStore } from '../../provider/stores'; import { useUserStore } from '../../provider/stores';
import { DDS } from '../../services/DeviceDetection'; import { DDS } from '../../services/DeviceDetection';
@@ -31,6 +32,8 @@ export const Signup = ({ changeMode, welcome }) => {
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const insets = useSafeAreaInsets();
const setUser = useUserStore(state => state.setUser); const setUser = useUserStore(state => state.setUser);
const setLastSynced = useUserStore(state => state.setLastSynced); const setLastSynced = useUserStore(state => state.setLastSynced);
@@ -87,7 +90,7 @@ export const Signup = ({ changeMode, welcome }) => {
position: 'absolute', position: 'absolute',
zIndex: 999, zIndex: 999,
left: 12, left: 12,
top: 12 top: 12 + insets.top
}} }}
/> />
)} )}
@@ -118,7 +121,7 @@ export const Signup = ({ changeMode, welcome }) => {
alignSelf: 'center', alignSelf: 'center',
paddingHorizontal: 12, paddingHorizontal: 12,
marginBottom: 30, marginBottom: 30,
marginTop: 15 marginTop: Dimensions.get('window').height < 700 ? -75 : 15
}} }}
> >
<Heading <Heading

View File

@@ -355,18 +355,20 @@ export const TOOLTIP_POSITIONS = {
BOTTOM: 4 BOTTOM: 4
}; };
let prevTarget = null; let prevTarget = null;
export function showTooltip(event, text, position) { export function showTooltip(event, text, position = 2) {
if (!event._targetInst?.ref?.current) return; if (!event._targetInst?.ref?.current) return;
prevTarget && RNTooltips.Dismiss(prevTarget); prevTarget && RNTooltips.Dismiss(prevTarget);
prevTarget = null; prevTarget = null;
prevTarget = event._targetInst.ref.current; prevTarget = event._targetInst.ref.current;
RNTooltips.Show(event._targetInst.ref.current, tabBarRef.current, { RNTooltips.Show(prevTarget, tabBarRef.current, {
text: text, text: text,
tintColor: 'black', tintColor: '#000000',
corner: 40, corner: Platform.OS === 'ios' ? 5 : 40,
textSize: 14, textSize: 14,
position: position, position: position,
duration: 1000 duration: 1000,
autoHide: true,
clickToHide: true
}); });
} }

View File

@@ -1,4 +1,5 @@
import { RefObject, useEffect, useRef } from 'react'; import { RefObject, useEffect, useRef } from 'react';
import { Platform } from 'react-native';
//@ts-ignore //@ts-ignore
import RNTooltips from 'react-native-tooltips'; import RNTooltips from 'react-native-tooltips';
import { useTracked } from '../provider'; import { useTracked } from '../provider';
@@ -52,12 +53,13 @@ const useTooltip = () => {
RNTooltips.Show(target.current, parent.current, { RNTooltips.Show(target.current, parent.current, {
text: popup.text, text: popup.text,
tintColor: colors.night ? colors.nav : '#404040', tintColor: colors.night ? colors.nav : '#404040',
corner: 80, corner: Platform.OS === 'ios' ? 5 : 80,
textSize: 15, textSize: 15,
position: positions[position], position: positions[position],
duration: duration || 10000, duration: duration || 10000,
clickToHide: true, clickToHide: true,
shadow: true shadow: true,
autoHide: true
}); });
}, 1000); }, 1000);
} }