import React from 'react';
import { Lbry } from 'lbry-redux';
import {
ActivityIndicator,
Dimensions,
Linking,
NativeModules,
Platform,
Text,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants';
import firstRunStyle from 'styles/firstRun';
import Icon from 'react-native-vector-icons/FontAwesome5';
const firstRunMargins = 80;
class WalletPage extends React.PureComponent {
state = {
password: null,
placeholder: 'password',
statusTries: 0,
walletReady: false,
hasCheckedSync: false,
revealPassword: false,
};
componentDidMount() {
this.checkWalletReady();
}
checkWalletReady = () => {
// make sure the sdk wallet component is ready
Lbry.status()
.then(status => {
if (status.startup_status && status.startup_status.wallet) {
this.setState({ walletReady: true }, () => {
this.props.checkSync();
setTimeout(() => this.setState({ hasCheckedSync: true }), 1000);
});
return;
}
setTimeout(this.checkWalletReady, 1000);
})
.catch(e => {
setTimeout(this.checkWalletReady, 1000);
});
};
handleChangeText = text => {
// save the value to the state email
const { onPasswordChanged } = this.props;
this.setState({ password: text });
if (onPasswordChanged) {
onPasswordChanged(text);
}
};
render() {
const { onPasswordChanged, onWalletViewLayout, getSyncIsPending, hasSyncedWallet, syncApplyIsPending } = this.props;
let content;
if (!this.state.walletReady || !this.state.hasCheckedSync || getSyncIsPending) {
content = (
Retrieving your account information...
);
} else if (syncApplyIsPending) {
content = (
Validating password...
);
} else {
content = (
Password
{hasSyncedWallet
? 'Please enter the password you used to secure your wallet.'
: 'Please enter a password to secure your account and wallet.'}
this.handleChangeText(text)}
onFocus={() => {
if (!this.state.password || this.state.password.length === 0) {
this.setState({ placeholder: '' });
}
}}
onBlur={() => {
if (!this.state.password || this.state.password.length === 0) {
this.setState({ placeholder: 'password' });
}
}}
/>
this.setState({ revealPassword: !this.state.revealPassword })}
>
{(!this.state.password || this.state.password.trim().length === 0) && (
{hasSyncedWallet
? 'If you did not provide a password, please press Use LBRY to continue.'
: 'You can proceed without a password, but this is not recommended.'}
)}
{(!hasSyncedWallet && this.state.password && this.state.password.trim().length) > 0 && (
)}
Note: for wallet security purposes, LBRY is unable to reset your password.
);
}
return {content};
}
}
export default WalletPage;