mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 21:48:04 -05:00
* [INJIMOB-3622]: cleared the bug related to banner Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: updated .talismanrc file Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: cleared the bug related to banner Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: cleared the bug related to banner Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: updated .talismanrc Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: updated update the snapshots for tests Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: clear the issue according to review comments Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3627]: added icons to the screen Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3627]: added .talismanrc Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3639] fix: modify face permission consent app name Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3628] fix status tooltip content overflow. Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3622]: cleared the header overlaping issue Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622] fix: banner hidden in backup / restore screen Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3622] fix: banner hidden in vc detail view and key management screen Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3622] fix: banner hidden inhelp screen Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3622] refactor: format VC detail view Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3637] fix extra header space across app screens Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3635]: updatd the pin background color to transparent Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3637] fix extra header space across app screens Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-3565] fix: modal screen showing bottom tabs Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3565] fix: modal screen showing bottom tabs Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3635]: added the color back Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3565] fix: bottom tab bar overlaying the safe area Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3635]: updated failing snap shots Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3635]: cleared the icon issue Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: cleared the scroll issue which is happening with vc view screen Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622]: cleared the issues rised by code rabbit Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3565] fix: replace initialWindowMetrics padding with safe area insets initialWindowMetrics will be getting the data only on iniitial phase Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3635]: cleared the icon issue Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3565] fix: iOS notification bar not showing white bg Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3565] refactor: replace SafeAreaView import from react-native-safe-area-context Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3565] refactor: move SafeAreaProvider to root component Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3565] refactor: extract tab bar visibility setter to hook Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3565] refactor: optimize imports Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3565] refactor: revert fix - bottom tab visible in safe area on backup / restore screen Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3565] refactor: fix failing tests Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3622]: cleared the issues rised by banner bar Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622] refactor: optimize import Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3622]: clear the jitpack issue Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> * [INJIMOB-3622] refactor: reove unused code Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3622] refactor: optimize import Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-3622] refactor: remove jitpack github repo Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> --------- Signed-off-by: jaswanthkumarpolisetty <jaswanthkumar.p@thoughtworks.com> Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> Signed-off-by: jaswanthkumartw <jaswanthkumar.p@thoughtworks.com> Co-authored-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> Co-authored-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
133 lines
3.6 KiB
TypeScript
133 lines
3.6 KiB
TypeScript
import React, {useRef, useState} from 'react';
|
|
import {
|
|
Modal,
|
|
View,
|
|
ScrollView,
|
|
TouchableOpacity,
|
|
Pressable,
|
|
Dimensions,
|
|
findNodeHandle,
|
|
UIManager,
|
|
} from 'react-native';
|
|
import {Theme} from './styleUtils';
|
|
|
|
interface CustomTooltipProps {
|
|
triggerComponent: React.ReactNode;
|
|
toolTipContent: React.ReactNode;
|
|
width?: number;
|
|
maxHeight?: number;
|
|
}
|
|
|
|
export const TOOLTIP_MARGIN = 6;
|
|
export const SCREEN_PADDING = 10;
|
|
export const POINTER_SIZE = 12;
|
|
|
|
export const CustomTooltip = ({
|
|
triggerComponent,
|
|
toolTipContent,
|
|
width = 275,
|
|
maxHeight = 300,
|
|
}: CustomTooltipProps) => {
|
|
const [visible, setVisible] = useState(false);
|
|
const [position, setPosition] = useState({x: 0, y: 0});
|
|
const [pointerLeft, setPointerLeft] = useState(20);
|
|
const [showAbove, setShowAbove] = useState(false);
|
|
|
|
const iconRef = useRef<View>(null);
|
|
const screen = Dimensions.get('window');
|
|
|
|
const showTooltip = () => {
|
|
if (!iconRef.current) return;
|
|
const handle = findNodeHandle(iconRef.current);
|
|
if (!handle) return;
|
|
|
|
try {
|
|
UIManager.measureInWindow(handle, (x, y, w, h) => {
|
|
if (w === 0 && h === 0) return;
|
|
|
|
let tooltipX = x;
|
|
let tooltipY = y + h + TOOLTIP_MARGIN;
|
|
let showAboveTooltip = false;
|
|
const iconCenterX = x + w / 2;
|
|
|
|
if (tooltipX + width > screen.width) {
|
|
tooltipX = screen.width - width - SCREEN_PADDING;
|
|
}
|
|
if (tooltipX < SCREEN_PADDING) {
|
|
tooltipX = SCREEN_PADDING;
|
|
}
|
|
|
|
if (tooltipY + maxHeight > screen.height) {
|
|
tooltipY = y - maxHeight - TOOLTIP_MARGIN * 2;
|
|
showAboveTooltip = true;
|
|
}
|
|
if (tooltipY < SCREEN_PADDING) {
|
|
tooltipY = SCREEN_PADDING;
|
|
showAboveTooltip = false;
|
|
}
|
|
|
|
const calculatedPointerLeft = iconCenterX - tooltipX - POINTER_SIZE / 2;
|
|
setPointerLeft(
|
|
Math.min(
|
|
Math.max(calculatedPointerLeft, SCREEN_PADDING),
|
|
width - SCREEN_PADDING,
|
|
),
|
|
);
|
|
setShowAbove(showAboveTooltip);
|
|
setPosition({x: tooltipX, y: tooltipY});
|
|
setVisible(true);
|
|
});
|
|
} catch (e) {
|
|
console.warn('Tooltip positioning failed:', e);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<View ref={iconRef} collapsable={false}>
|
|
<TouchableOpacity onPress={showTooltip} style={{marginLeft: 5}}>
|
|
{triggerComponent}
|
|
</TouchableOpacity>
|
|
</View>
|
|
|
|
{visible && (
|
|
<Modal
|
|
transparent
|
|
visible={visible}
|
|
animationType="fade"
|
|
hardwareAccelerated
|
|
onRequestClose={() => setVisible(false)}>
|
|
<Pressable
|
|
style={Theme.Styles.tooltipOverlay}
|
|
onPress={() => setVisible(false)}
|
|
/>
|
|
<View
|
|
style={[
|
|
Theme.Styles.tooltip,
|
|
{width, top: position.y, left: position.x},
|
|
]}>
|
|
<View
|
|
style={[
|
|
Theme.Styles.pointer,
|
|
{
|
|
left: pointerLeft,
|
|
top: showAbove ? undefined : -POINTER_SIZE / 2,
|
|
bottom: showAbove ? -POINTER_SIZE / 2 : undefined,
|
|
transform: [{rotate: showAbove ? '180deg' : '0deg'}],
|
|
},
|
|
]}
|
|
/>
|
|
<ScrollView
|
|
nestedScrollEnabled
|
|
keyboardShouldPersistTaps="handled"
|
|
style={{maxHeight, overflow: 'hidden'}}
|
|
contentContainerStyle={{padding: 15}}>
|
|
{toolTipContent}
|
|
</ScrollView>
|
|
</View>
|
|
</Modal>
|
|
)}
|
|
</>
|
|
);
|
|
};
|