BlueWallet/screen/plausibledeniability.js

90 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-04-01 00:16:42 +01:00
/* global alert */
import React, { Component } from 'react';
import { ScrollView } from 'react-native';
import { BlueLoading, BlueButton, SafeBlueArea, BlueCard, BlueText, BlueNavigationStyle, BlueSpacing20 } from '../BlueComponents';
2018-04-01 00:16:42 +01:00
import PropTypes from 'prop-types';
/** @type {AppStorage} */
let BlueApp = require('../BlueApp');
let prompt = require('../prompt');
let EV = require('../events');
2018-05-30 00:17:44 +01:00
let loc = require('../loc');
2018-04-01 00:16:42 +01:00
export default class PlausibleDeniability extends Component {
static navigationOptions = {
...BlueNavigationStyle(),
title: loc.plausibledeniability.title,
2018-04-01 00:16:42 +01:00
};
constructor(props) {
super(props);
this.state = {
isLoading: true,
};
}
async componentDidMount() {
this.setState({
isLoading: false,
});
}
render() {
if (this.state.isLoading) {
return <BlueLoading />;
}
return (
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
<BlueCard>
<ScrollView maxHeight={450}>
2018-05-30 00:17:44 +01:00
<BlueText>{loc.plausibledeniability.help}</BlueText>
2018-04-01 00:16:42 +01:00
<BlueText />
2018-05-30 00:17:44 +01:00
<BlueText>{loc.plausibledeniability.help2}</BlueText>
2018-04-01 00:16:42 +01:00
<BlueSpacing20 />
2018-04-01 00:16:42 +01:00
<BlueButton
2018-06-24 23:22:46 +01:00
icon={{
name: 'shield',
type: 'octicon',
color: BlueApp.settings.buttonTextColor,
}}
2018-05-30 00:17:44 +01:00
title={loc.plausibledeniability.create_fake_storage}
2018-04-01 00:16:42 +01:00
onPress={async () => {
let p1 = await prompt(loc.plausibledeniability.create_password, loc.plausibledeniability.create_password_explanation);
2018-04-01 00:16:42 +01:00
if (p1 === BlueApp.cachedPassword) {
2018-07-07 14:04:32 +01:00
return alert(loc.plausibledeniability.password_should_not_match);
2018-04-01 00:16:42 +01:00
}
if (!p1) {
return;
}
2018-05-30 00:17:44 +01:00
let p2 = await prompt(loc.plausibledeniability.retype_password);
2018-04-01 00:16:42 +01:00
if (p1 !== p2) {
2018-05-30 00:17:44 +01:00
return alert(loc.plausibledeniability.passwords_do_not_match);
2018-04-01 00:16:42 +01:00
}
await BlueApp.createFakeStorage(p1);
EV(EV.enum.WALLETS_COUNT_CHANGED);
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED);
2018-05-30 00:17:44 +01:00
alert(loc.plausibledeniability.success);
2018-04-01 00:16:42 +01:00
this.props.navigation.navigate('Wallets');
}}
/>
</ScrollView>
</BlueCard>
</SafeBlueArea>
);
}
}
PlausibleDeniability.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
goBack: PropTypes.func,
}),
};