2024-11-10 11:54:19 +00:00
|
|
|
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native';
|
|
|
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
2024-05-04 18:16:57 -04:00
|
|
|
import React, { useCallback, useEffect } from 'react';
|
|
|
|
import { BackHandler, I18nManager, ScrollView, StyleSheet, Text, View } from 'react-native';
|
2024-11-10 11:54:19 +00:00
|
|
|
import { disallowScreenshot } from 'react-native-screen-capture';
|
2023-11-15 04:40:22 -04:00
|
|
|
import Button from '../../components/Button';
|
2024-02-24 06:27:17 -05:00
|
|
|
import { useTheme } from '../../components/themes';
|
2024-11-08 22:38:05 -04:00
|
|
|
import { useSettings } from '../../hooks/context/useSettings';
|
2024-11-10 11:54:19 +00:00
|
|
|
import { useStorage } from '../../hooks/context/useStorage';
|
|
|
|
import loc from '../../loc';
|
|
|
|
import { AddWalletStackParamList } from '../../navigation/AddWalletStack';
|
2024-11-28 20:03:45 -05:00
|
|
|
import { isDesktop } from '../../blue_modules/environment';
|
2024-11-10 11:54:19 +00:00
|
|
|
|
2024-11-18 19:30:16 +00:00
|
|
|
import SeedWords from '../../components/SeedWords';
|
|
|
|
|
2024-11-10 11:54:19 +00:00
|
|
|
type RouteProps = RouteProp<AddWalletStackParamList, 'PleaseBackup'>;
|
|
|
|
type NavigationProp = NativeStackNavigationProp<AddWalletStackParamList, 'PleaseBackup'>;
|
2020-05-24 12:17:26 +03:00
|
|
|
|
2023-10-22 21:59:16 -04:00
|
|
|
const PleaseBackup: React.FC = () => {
|
2024-05-04 18:16:57 -04:00
|
|
|
const { wallets } = useStorage();
|
2024-11-10 11:54:19 +00:00
|
|
|
const { walletID } = useRoute<RouteProps>().params;
|
2024-11-18 19:30:16 +00:00
|
|
|
const wallet = wallets.find(w => w.getID() === walletID)!;
|
2024-11-10 11:54:19 +00:00
|
|
|
const navigation = useNavigation<NavigationProp>();
|
2024-11-08 22:38:05 -04:00
|
|
|
const { isPrivacyBlurEnabled } = useSettings();
|
2020-07-15 13:32:59 -04:00
|
|
|
const { colors } = useTheme();
|
2023-10-22 21:59:16 -04:00
|
|
|
|
2020-10-29 05:26:39 -04:00
|
|
|
const stylesHook = StyleSheet.create({
|
2020-07-15 13:32:59 -04:00
|
|
|
flex: {
|
|
|
|
backgroundColor: colors.elevated,
|
|
|
|
},
|
|
|
|
pleaseText: {
|
|
|
|
color: colors.foregroundColor,
|
|
|
|
},
|
|
|
|
});
|
2019-04-22 12:51:47 +01:00
|
|
|
|
2020-04-27 19:10:42 -04:00
|
|
|
const handleBackButton = useCallback(() => {
|
2023-10-22 21:59:16 -04:00
|
|
|
// @ts-ignore: Ignore
|
2023-11-11 07:33:50 -04:00
|
|
|
navigation.getParent()?.pop();
|
2019-04-22 12:51:47 +01:00
|
|
|
return true;
|
2020-05-27 14:12:17 +03:00
|
|
|
}, [navigation]);
|
2019-04-22 12:51:47 +01:00
|
|
|
|
2020-04-27 19:10:42 -04:00
|
|
|
useEffect(() => {
|
2020-06-06 21:21:14 -04:00
|
|
|
BackHandler.addEventListener('hardwareBackPress', handleBackButton);
|
2024-11-28 20:03:45 -05:00
|
|
|
if (!isDesktop) disallowScreenshot(isPrivacyBlurEnabled);
|
2020-04-27 19:10:42 -04:00
|
|
|
return () => {
|
|
|
|
BackHandler.removeEventListener('hardwareBackPress', handleBackButton);
|
2024-11-28 20:03:45 -05:00
|
|
|
if (!isDesktop) disallowScreenshot(false);
|
2020-04-27 19:10:42 -04:00
|
|
|
};
|
2020-10-29 05:26:39 -04:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, []);
|
2019-04-22 12:51:47 +01:00
|
|
|
|
2023-10-22 21:59:16 -04:00
|
|
|
return (
|
2024-05-04 18:16:57 -04:00
|
|
|
<ScrollView
|
2024-05-05 16:33:06 -04:00
|
|
|
style={styles.root}
|
2024-05-04 18:16:57 -04:00
|
|
|
contentContainerStyle={[styles.flex, stylesHook.flex]}
|
|
|
|
testID="PleaseBackupScrollView"
|
|
|
|
automaticallyAdjustContentInsets
|
|
|
|
contentInsetAdjustmentBehavior="automatic"
|
|
|
|
>
|
|
|
|
<View style={styles.please}>
|
|
|
|
<Text style={[styles.pleaseText, stylesHook.pleaseText]}>{loc.pleasebackup.text}</Text>
|
|
|
|
</View>
|
|
|
|
<View style={styles.list}>
|
2024-11-18 19:30:16 +00:00
|
|
|
<SeedWords seed={wallet.getSecret() ?? ''} />
|
2024-05-04 18:16:57 -04:00
|
|
|
</View>
|
|
|
|
<View style={styles.bottom}>
|
|
|
|
<Button testID="PleasebackupOk" onPress={handleBackButton} title={loc.pleasebackup.ok} />
|
|
|
|
</View>
|
|
|
|
</ScrollView>
|
2020-04-27 19:10:42 -04:00
|
|
|
);
|
2019-04-22 12:51:47 +01:00
|
|
|
};
|
2020-04-27 19:10:42 -04:00
|
|
|
|
2020-10-29 05:26:39 -04:00
|
|
|
const styles = StyleSheet.create({
|
2024-05-05 16:33:06 -04:00
|
|
|
root: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
2021-04-20 16:33:55 +02:00
|
|
|
flex: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'space-around',
|
|
|
|
},
|
2020-10-29 05:26:39 -04:00
|
|
|
please: {
|
2021-04-20 16:33:55 +02:00
|
|
|
flexGrow: 1,
|
|
|
|
paddingHorizontal: 16,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
flexGrow: 8,
|
2024-11-18 19:30:16 +00:00
|
|
|
marginTop: 14,
|
2020-10-29 05:26:39 -04:00
|
|
|
paddingHorizontal: 16,
|
|
|
|
},
|
2021-04-20 16:33:55 +02:00
|
|
|
bottom: {
|
|
|
|
flexGrow: 2,
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
},
|
2020-10-29 05:26:39 -04:00
|
|
|
pleaseText: {
|
2021-04-20 16:33:55 +02:00
|
|
|
marginVertical: 16,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: '500',
|
2021-10-22 01:54:06 -04:00
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
2020-10-29 05:26:39 -04:00
|
|
|
},
|
|
|
|
});
|
2020-04-27 19:10:42 -04:00
|
|
|
|
|
|
|
export default PleaseBackup;
|