import React, { Component } from 'react' import { View, TextInput, TouchableOpacity } from 'react-native' import nodejs from 'nodejs-mobile-react-native' import AppText from './app-text' import { hasEncryptionObservable } from '../local-storage' import styles from '../styles' import labels from './labels' import { openDbConnection } from '../db' import App from './app' export default class PasswordPrompt extends Component { constructor() { super() this.state = {} hasEncryptionObservable.once((hasEncryption) => { if (hasEncryption) { this.setState({showPasswordPrompt: true}) } else { openDbConnection() this.setState({showApp: true}) } }) nodejs.channel.addListener( 'message', msg => { msg = JSON.parse(msg) if (msg.type === 'password-check-result') { if (msg.message) { this.setState({showApp: true}) } else { this.setState({wrongPassword: true}) } } }, this ) } render() { return ( {this.state.showApp ? : {this.state.showPasswordPrompt && this.setState({password: val})} /> { }} style={styles.settingsButton}> {labels.export.button} {this.state.wrongPassword && Wrong PAssword!} } } ) } }