BlueWallet/screen/settings/GeneralSettings.tsx

68 lines
2.2 KiB
TypeScript
Raw Normal View History

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