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';
|
2020-12-25 17:09:53 +01:00
|
|
|
|
2023-10-24 03:28:44 +02:00
|
|
|
import { useNavigation } from '@react-navigation/native';
|
2024-04-18 03:05:48 +02:00
|
|
|
import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents';
|
2024-05-04 00:33:23 +02:00
|
|
|
import { useStorage } from '../../blue_modules/storage-context';
|
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-04-18 03:05:48 +02:00
|
|
|
import { useSettings } from '../../components/Context/SettingsContext';
|
2020-03-29 04:06:45 +02:00
|
|
|
|
2020-05-24 11:17:26 +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();
|
2024-04-18 03:05:48 +02:00
|
|
|
const {
|
|
|
|
isAdvancedModeEnabled,
|
|
|
|
setIsAdvancedModeEnabledStorage,
|
|
|
|
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');
|
|
|
|
};
|
|
|
|
|
2024-04-25 03:32:37 +02:00
|
|
|
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 (
|
2024-04-21 04:34:47 +02:00
|
|
|
<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-15 19:32:59 +02:00
|
|
|
hideChevron
|
2020-07-20 15:38:46 +02:00
|
|
|
title={loc.settings.general_continuity}
|
2023-12-16 22:44:35 +01:00
|
|
|
Component={PressableWrapper}
|
2024-04-25 03:32:37 +02:00
|
|
|
switch={{ onValueChange: onHandOffUseEnabledChange, value: isHandOffUseEnabled }}
|
2020-07-15 19:32:59 +02:00
|
|
|
/>
|
|
|
|
<BlueCard>
|
2020-11-22 09:04:04 +01:00
|
|
|
<BlueText>{loc.settings.general_continuity_e}</BlueText>
|
2020-07-15 19:32:59 +02:00
|
|
|
</BlueCard>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
</>
|
|
|
|
) : null}
|
2023-12-16 22:44:35 +01:00
|
|
|
<ListItem
|
|
|
|
Component={PressableWrapper}
|
2020-07-20 15:38:46 +02:00
|
|
|
title={loc.settings.general_adv_mode}
|
2024-04-18 03:05:48 +02:00
|
|
|
switch={{ onValueChange: setIsAdvancedModeEnabledStorage, value: isAdvancedModeEnabled, testID: 'AdvancedMode' }}
|
2020-07-15 19:32:59 +02:00
|
|
|
/>
|
|
|
|
<BlueCard>
|
2020-11-22 09:04:04 +01:00
|
|
|
<BlueText>{loc.settings.general_adv_mode_e}</BlueText>
|
2020-07-15 19:32:59 +02:00
|
|
|
</BlueCard>
|
|
|
|
<BlueSpacing20 />
|
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;
|