import React, { useEffect, useState } from 'react'; import { Platform, ScrollView, StyleSheet, Text, TouchableWithoutFeedback, View } from 'react-native'; import { openSettings } from 'react-native-permissions'; import A from '../../blue_modules/analytics'; import { Header } from '../../components/Header'; import ListItem, { PressableWrapper } from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; import { useStorage } from '../../hooks/context/useStorage'; import { useSettings } from '../../hooks/context/useSettings'; import { BlueSpacing20 } from '../../BlueComponents'; enum SettingsPrivacySection { None, All, ReadClipboard, QuickActions, Widget, TemporaryScreenshots, TotalBalance, } const SettingsPrivacy: React.FC = () => { const { colors } = useTheme(); const { isStorageEncrypted, wallets } = useStorage(); const { isDoNotTrackEnabled, setDoNotTrackStorage, isPrivacyBlurEnabled, setIsPrivacyBlurEnabled, isWidgetBalanceDisplayAllowed, setIsWidgetBalanceDisplayAllowedStorage, isClipboardGetContentEnabled, setIsClipboardGetContentEnabledStorage, isQuickActionsEnabled, setIsQuickActionsEnabledStorage, isTotalBalanceEnabled, setIsTotalBalanceEnabledStorage, } = useSettings(); const [isLoading, setIsLoading] = useState(SettingsPrivacySection.All); const [storageIsEncrypted, setStorageIsEncrypted] = useState(true); const styleHooks = StyleSheet.create({ root: { backgroundColor: colors.background, }, }); useEffect(() => { (async () => { try { setStorageIsEncrypted(await isStorageEncrypted()); } catch (e) { console.log(e); } setIsLoading(SettingsPrivacySection.None); })(); }, [isStorageEncrypted]); const onDoNotTrackValueChange = async (value: boolean) => { setIsLoading(SettingsPrivacySection.All); try { setDoNotTrackStorage(value); A.setOptOut(value); } catch (e) { console.debug('onDoNotTrackValueChange catch', e); } setIsLoading(SettingsPrivacySection.None); }; const onQuickActionsValueChange = async (value: boolean) => { setIsLoading(SettingsPrivacySection.QuickActions); try { setIsQuickActionsEnabledStorage(value); } catch (e) { console.debug('onQuickActionsValueChange catch', e); } setIsLoading(SettingsPrivacySection.None); }; const onWidgetsTotalBalanceValueChange = async (value: boolean) => { setIsLoading(SettingsPrivacySection.Widget); try { setIsWidgetBalanceDisplayAllowedStorage(value); } catch (e) { console.debug('onWidgetsTotalBalanceValueChange catch', e); } setIsLoading(SettingsPrivacySection.None); }; const onTotalBalanceEnabledValueChange = async (value: boolean) => { setIsLoading(SettingsPrivacySection.TotalBalance); try { setIsTotalBalanceEnabledStorage(value); } catch (e) { console.debug('onTotalBalanceEnabledValueChange catch', e); } setIsLoading(SettingsPrivacySection.None); }; const onTemporaryScreenshotsValueChange = (value: boolean) => { setIsLoading(SettingsPrivacySection.TemporaryScreenshots); setIsPrivacyBlurEnabled(!value); setIsLoading(SettingsPrivacySection.None); }; const openApplicationSettings = () => { openSettings(); }; return ( {Platform.OS === 'android' ? (
) : null} {loc.settings.privacy_quickactions_explanation} {storageIsEncrypted && {loc.settings.encrypted_feature_disabled}} } /> {loc.total_balance_view.explanation}} /> {loc.settings.privacy_temporary_screenshots_instructions}} /> {loc.settings.privacy_do_not_track_explanation}} /> {Platform.OS === 'ios' && ( <>
{loc.settings.total_balance_explanation} {storageIsEncrypted && {loc.settings.encrypted_feature_disabled}} } /> )} ); }; const styles = StyleSheet.create({ root: { flex: 1, }, headerContainer: { paddingVertical: 16, }, subtitleText: { fontSize: 14, marginTop: 5, }, }); export default SettingsPrivacy;