import React, { useContext, useEffect, useState } from 'react'; import { ScrollView, Platform, Pressable, TouchableOpacity, StyleSheet } from 'react-native'; import navigationStyle from '../../components/navigationStyle'; import { BlueLoading, BlueText, BlueSpacing20, BlueListItem, BlueCard } from '../../BlueComponents'; import { useNavigation, useTheme } from '@react-navigation/native'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import { isURv1Enabled, clearUseURv1, setUseURv1 } from '../../blue_modules/ur'; const styles = StyleSheet.create({ root: { flex: 1, }, }); const GeneralSettings: React.FC = () => { const { isAdvancedModeEnabled, setIsAdvancedModeEnabled, wallets, isHandOffUseEnabled, setIsHandOffUseEnabledAsyncStorage } = useContext(BlueStorageContext); const [isLoading, setIsLoading] = useState(true); const [isAdvancedModeSwitchEnabled, setIsAdvancedModeSwitchEnabled] = useState(false); const [isURv1SwitchEnabled, setIsURv1SwitchEnabled] = useState(false); const { navigate } = useNavigation(); const { colors } = useTheme(); const onAdvancedModeSwitch = async (value: boolean) => { await setIsAdvancedModeEnabled(value); setIsAdvancedModeSwitchEnabled(value); }; const onLegacyURv1Switch = async (value: boolean) => { setIsURv1SwitchEnabled(value); return value ? setUseURv1() : clearUseURv1(); }; useEffect(() => { (async () => { setIsAdvancedModeSwitchEnabled(await isAdvancedModeEnabled()); setIsURv1SwitchEnabled(await isURv1Enabled()); setIsLoading(false); })(); }); const navigateToPrivacy = () => { // @ts-ignore: Fix later navigate('SettingsPrivacy'); }; const stylesWithThemeHook = { root: { backgroundColor: colors.background, }, }; return isLoading ? ( ) : ( {wallets.length > 1 && ( <> {/* @ts-ignore: Fix later */} navigate('DefaultView')} title={loc.settings.default_title} chevron /> )} {/* @ts-ignore: Fix later */} {Platform.OS === 'ios' ? ( <> {loc.settings.general_continuity_e} ) : null} {loc.settings.general_adv_mode_e} {/* @ts-ignore: Fix later */} ); }; // @ts-ignore: Fix later GeneralSettings.navigationOptions = navigationStyle({}, opts => ({ ...opts, title: loc.settings.general })); export default GeneralSettings;