Merge pull request #5410 from BlueWallet/privacytsx

REF: Privacy from JS to TSX
This commit is contained in:
GLaDOS 2023-03-27 22:22:15 +01:00 committed by GitHub
commit 2f6000c168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 48 deletions

View File

@ -1,21 +0,0 @@
import { useContext, useEffect } from 'react';
import Obscure from 'react-native-obscure';
import { BlueStorageContext } from './storage-context';
const Privacy = () => {
const { isPrivacyBlurEnabled } = useContext(BlueStorageContext);
useEffect(() => {
Privacy.disableBlur();
}, [isPrivacyBlurEnabled]);
Privacy.enableBlur = () => {
if (!isPrivacyBlurEnabled) return;
Obscure.activateObscure();
};
Privacy.disableBlur = () => {
Obscure.deactivateObscure();
};
return null;
};
export default Privacy;

View File

@ -0,0 +1,29 @@
import { useContext, useEffect } from 'react';
// @ts-ignore: react-native-obscure is not in the type definition
import Obscure from 'react-native-obscure';
import { BlueStorageContext } from './storage-context';
interface PrivacyComponent extends React.FC {
enableBlur: (isPrivacyBlurEnabled: boolean) => void;
disableBlur: () => void;
}
const Privacy: PrivacyComponent = () => {
const { isPrivacyBlurEnabled } = useContext(BlueStorageContext);
useEffect(() => {
Obscure.deactivateObscure();
}, [isPrivacyBlurEnabled]);
return null;
};
Privacy.enableBlur = (isPrivacyBlurEnabled: boolean) => {
if (!isPrivacyBlurEnabled) return;
Obscure.activateObscure();
};
Privacy.disableBlur = () => {
Obscure.deactivateObscure();
};
export default Privacy;

View File

@ -1,22 +0,0 @@
import { useContext, useEffect } from 'react';
import { enabled } from 'react-native-privacy-snapshot';
import { BlueStorageContext } from './storage-context';
const Privacy = () => {
const { isPrivacyBlurEnabled } = useContext(BlueStorageContext);
useEffect(() => {
Privacy.disableBlur();
}, [isPrivacyBlurEnabled]);
Privacy.enableBlur = () => {
if (!isPrivacyBlurEnabled) return;
enabled(true);
};
Privacy.disableBlur = () => {
enabled(false);
};
return null;
};
export default Privacy;

View File

@ -0,0 +1,30 @@
import { useContext, useEffect } from 'react';
// @ts-ignore: react-native-obscure is not in the type definition
import { enabled } from 'react-native-privacy-snapshot';
import { BlueStorageContext } from './storage-context';
interface PrivacyComponent extends React.FC {
enableBlur: (isPrivacyBlurEnabled: boolean) => void;
disableBlur: () => void;
}
const Privacy: PrivacyComponent = () => {
const { isPrivacyBlurEnabled } = useContext(BlueStorageContext);
useEffect(() => {
Privacy.disableBlur();
}, [isPrivacyBlurEnabled]);
return null;
};
Privacy.enableBlur = (isPrivacyBlurEnabled: boolean) => {
if (!isPrivacyBlurEnabled) return;
enabled(true);
};
Privacy.disableBlur = () => {
enabled(false);
};
export default Privacy;

View File

@ -1,5 +0,0 @@
export default class Privacy {
static enableBlur() {}
static disableBlur() {}
}

21
blue_modules/Privacy.tsx Normal file
View File

@ -0,0 +1,21 @@
import React from 'react';
interface PrivacyComponent extends React.FC {
enableBlur: () => void;
disableBlur: () => void;
}
const Privacy: PrivacyComponent = () => {
// Define Privacy's behavior
return null;
};
Privacy.enableBlur = () => {
// Define the enableBlur behavior
};
Privacy.disableBlur = () => {
// Define the disableBlur behavior
};
export default Privacy;