BlueWallet/screen/settings/GeneralSettings.tsx

72 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-05-20 10:54:13 +01:00
import { useNavigation } from '@react-navigation/native';
2024-05-03 18:33:23 -04:00
import React from 'react';
2024-02-24 06:27:17 -05:00
import { Platform, ScrollView, StyleSheet } from 'react-native';
2024-05-20 10:54:13 +01:00
import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents';
2023-12-16 17:44:35 -04:00
import ListItem, { PressableWrapper } from '../../components/ListItem';
2024-02-24 06:27:17 -05:00
import { useTheme } from '../../components/themes';
import loc from '../../loc';
2024-05-31 13:18:01 -04:00
import { useStorage } from '../../hooks/context/useStorage';
import { useSettings } from '../../hooks/context/useSettings';
2020-03-28 22:06:45 -04:00
const styles = StyleSheet.create({
root: {
flex: 1,
},
});
2023-04-12 13:06:19 -05:00
const GeneralSettings: React.FC = () => {
2024-05-03 18:33:23 -04:00
const { wallets } = useStorage();
const { isHandOffUseEnabled, setIsHandOffUseEnabledAsyncStorage, isLegacyURv1Enabled, setIsLegacyURv1EnabledStorage } = useSettings();
2020-03-29 12:46:22 -04:00
const { navigate } = useNavigation();
2020-07-15 13:32:59 -04:00
const { colors } = useTheme();
2020-03-28 22:06:45 -04:00
2021-04-06 12:31:56 +02:00
const navigateToPrivacy = () => {
2023-04-12 13:06:19 -05:00
// @ts-ignore: Fix later
2021-04-06 12:31:56 +02:00
navigate('SettingsPrivacy');
};
const onHandOffUseEnabledChange = async (value: boolean) => {
await setIsHandOffUseEnabledAsyncStorage(value);
};
2020-07-15 13:32:59 -04:00
const stylesWithThemeHook = {
root: {
backgroundColor: colors.background,
},
};
2024-04-17 21:05:48 -04:00
return (
<ScrollView style={[styles.root, stylesWithThemeHook.root]} automaticallyAdjustContentInsets contentInsetAdjustmentBehavior="automatic">
{wallets.length > 0 && (
2020-07-15 13:32:59 -04:00
<>
2023-04-12 13:06:19 -05:00
{/* @ts-ignore: Fix later */}
2023-12-16 17:44:35 -04:00
<ListItem onPress={() => navigate('DefaultView')} title={loc.settings.default_title} chevron />
2020-07-15 13:32:59 -04:00
</>
)}
2023-12-16 17:44:35 -04:00
<ListItem title={loc.settings.privacy} onPress={navigateToPrivacy} testID="SettingsPrivacy" chevron />
2020-07-15 13:32:59 -04:00
{Platform.OS === 'ios' ? (
<>
2023-12-16 17:44:35 -04:00
<ListItem
2020-07-20 16:38:46 +03:00
title={loc.settings.general_continuity}
2023-12-16 17:44:35 -04:00
Component={PressableWrapper}
switch={{ onValueChange: onHandOffUseEnabledChange, value: isHandOffUseEnabled }}
2020-07-15 13:32:59 -04:00
/>
<BlueCard>
2020-11-22 03:04:04 -05:00
<BlueText>{loc.settings.general_continuity_e}</BlueText>
2020-07-15 13:32:59 -04:00
</BlueCard>
<BlueSpacing20 />
</>
) : null}
<BlueSpacing20 />
2023-12-16 17:44:35 -04:00
<ListItem
Component={PressableWrapper}
2021-07-09 11:52:09 +01:00
title="Legacy URv1 QR"
2024-04-17 21:05:48 -04:00
switch={{ onValueChange: setIsLegacyURv1EnabledStorage, value: isLegacyURv1Enabled }}
2021-07-09 11:52:09 +01:00
/>
<BlueSpacing20 />
2020-07-15 13:32:59 -04:00
</ScrollView>
2020-03-28 22:06:45 -04:00
);
};
export default GeneralSettings;