BlueWallet/screen/settings/GeneralSettings.tsx
Marcos Rodriguez Velez 70c8c1fa00
REF: Header to TSX
2024-05-03 18:33:23 -04:00

89 lines
2.8 KiB
TypeScript

import React from 'react';
import { Platform, ScrollView, StyleSheet } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents';
import { useStorage } from '../../blue_modules/storage-context';
import ListItem, { PressableWrapper } from '../../components/ListItem';
import { useTheme } from '../../components/themes';
import loc from '../../loc';
import { useSettings } from '../../components/Context/SettingsContext';
const styles = StyleSheet.create({
root: {
flex: 1,
},
});
const GeneralSettings: React.FC = () => {
const { wallets } = useStorage();
const {
isAdvancedModeEnabled,
setIsAdvancedModeEnabledStorage,
isHandOffUseEnabled,
setIsHandOffUseEnabledAsyncStorage,
isLegacyURv1Enabled,
setIsLegacyURv1EnabledStorage,
} = useSettings();
const { navigate } = useNavigation();
const { colors } = useTheme();
const navigateToPrivacy = () => {
// @ts-ignore: Fix later
navigate('SettingsPrivacy');
};
const onHandOffUseEnabledChange = async (value: boolean) => {
await setIsHandOffUseEnabledAsyncStorage(value);
};
const stylesWithThemeHook = {
root: {
backgroundColor: colors.background,
},
};
return (
<ScrollView style={[styles.root, stylesWithThemeHook.root]} automaticallyAdjustContentInsets contentInsetAdjustmentBehavior="automatic">
{wallets.length > 0 && (
<>
{/* @ts-ignore: Fix later */}
<ListItem onPress={() => navigate('DefaultView')} title={loc.settings.default_title} chevron />
</>
)}
<ListItem title={loc.settings.privacy} onPress={navigateToPrivacy} testID="SettingsPrivacy" chevron />
{Platform.OS === 'ios' ? (
<>
<ListItem
hideChevron
title={loc.settings.general_continuity}
Component={PressableWrapper}
switch={{ onValueChange: onHandOffUseEnabledChange, value: isHandOffUseEnabled }}
/>
<BlueCard>
<BlueText>{loc.settings.general_continuity_e}</BlueText>
</BlueCard>
<BlueSpacing20 />
</>
) : null}
<ListItem
Component={PressableWrapper}
title={loc.settings.general_adv_mode}
switch={{ onValueChange: setIsAdvancedModeEnabledStorage, value: isAdvancedModeEnabled, testID: 'AdvancedMode' }}
/>
<BlueCard>
<BlueText>{loc.settings.general_adv_mode_e}</BlueText>
</BlueCard>
<BlueSpacing20 />
<ListItem
Component={PressableWrapper}
title="Legacy URv1 QR"
switch={{ onValueChange: setIsLegacyURv1EnabledStorage, value: isLegacyURv1Enabled }}
/>
<BlueSpacing20 />
</ScrollView>
);
};
export default GeneralSettings;