mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-26 08:55:56 +01:00
34 lines
No EOL
912 B
TypeScript
34 lines
No EOL
912 B
TypeScript
import { useEffect, useCallback } from 'react';
|
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
|
import { useSettings } from './context/useSettings';
|
|
|
|
export const usePrivacy = () => {
|
|
const { isPrivacyBlurEnabled } = useSettings();
|
|
|
|
const enableBlur = useCallback(() => {
|
|
if (!isPrivacyBlurEnabled) return;
|
|
disallowScreenshot(true);
|
|
}, [isPrivacyBlurEnabled]);
|
|
|
|
const disableBlur = useCallback(() => {
|
|
disallowScreenshot(false);
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
// Apply privacy settings when the component mounts or when the setting changes
|
|
if (isPrivacyBlurEnabled) {
|
|
enableBlur();
|
|
} else {
|
|
disableBlur();
|
|
}
|
|
|
|
// Cleanup: Re-enable screenshots when the component unmounts
|
|
return () => {
|
|
disableBlur();
|
|
};
|
|
}, [isPrivacyBlurEnabled, enableBlur, disableBlur]);
|
|
|
|
return { enableBlur, disableBlur };
|
|
};
|
|
|
|
export default usePrivacy; |